diff --git a/packages/contracts/contracts/arbitrum/IBridge.sol b/packages/contracts/contracts/arbitrum/IBridge.sol index ff78253fc..536ee075b 100644 --- a/packages/contracts/contracts/arbitrum/IBridge.sol +++ b/packages/contracts/contracts/arbitrum/IBridge.sol @@ -35,12 +35,7 @@ interface IBridge { bytes32 messageDataHash ); - event BridgeCallTriggered( - address indexed outbox, - address indexed destAddr, - uint256 amount, - bytes data - ); + event BridgeCallTriggered(address indexed outbox, address indexed destAddr, uint256 amount, bytes data); event InboxToggle(address indexed inbox, bool enabled); diff --git a/packages/contracts/contracts/arbitrum/IOutbox.sol b/packages/contracts/contracts/arbitrum/IOutbox.sol index 687c86abf..2e4f05bd5 100644 --- a/packages/contracts/contracts/arbitrum/IOutbox.sol +++ b/packages/contracts/contracts/arbitrum/IOutbox.sol @@ -51,8 +51,7 @@ interface IOutbox { function l2ToL1OutputId() external view returns (bytes32); - function processOutgoingMessages(bytes calldata sendsData, uint256[] calldata sendLengths) - external; + function processOutgoingMessages(bytes calldata sendsData, uint256[] calldata sendLengths) external; function outboxEntryExists(uint256 batchNum) external view returns (bool); } diff --git a/packages/contracts/contracts/bancor/BancorFormula.sol b/packages/contracts/contracts/bancor/BancorFormula.sol index 9cb41a502..689eebaba 100644 --- a/packages/contracts/contracts/bancor/BancorFormula.sol +++ b/packages/contracts/contracts/bancor/BancorFormula.sol @@ -324,9 +324,7 @@ contract BancorFormula { uint256 _amount ) public view returns (uint256) { // validate input - require( - _supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2 - ); + require(_supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2); // special case for 0 amount if (_amount == 0) return 0; @@ -364,11 +362,7 @@ contract BancorFormula { ) public view returns (uint256) { // validate input require( - _supply > 0 && - _reserveBalance > 0 && - _totalRatio > 1 && - _totalRatio <= MAX_RATIO * 2 && - _amount <= _supply + _supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2 && _amount <= _supply ); // special case for 0 amount @@ -407,12 +401,7 @@ contract BancorFormula { * This functions assumes that "_expN < 2 ^ 256 / log(MAX_NUM - 1)", otherwise the multiplication should be replaced with a "safeMul". * Since we rely on unsigned-integer arithmetic and "base < 1" ==> "log(base) < 0", this function does not support "_baseN < _baseD". */ - function power( - uint256 _baseN, - uint256 _baseD, - uint32 _expN, - uint32 _expD - ) internal view returns (uint256, uint8) { + function power(uint256 _baseN, uint256 _baseD, uint32 _expN, uint32 _expD) internal view returns (uint256, uint8) { require(_baseN < MAX_NUM); uint256 baseLog; @@ -428,10 +417,7 @@ contract BancorFormula { return (optimalExp(baseLogTimesExp), MAX_PRECISION); } else { uint8 precision = findPositionInMaxExpArray(baseLogTimesExp); - return ( - generalExp(baseLogTimesExp >> (MAX_PRECISION - precision), precision), - precision - ); + return (generalExp(baseLogTimesExp >> (MAX_PRECISION - precision), precision), precision); } } @@ -642,37 +628,21 @@ contract BancorFormula { z = y = x - FIXED_1; w = (y * y) / FIXED_1; - res += - (z * (0x100000000000000000000000000000000 - y)) / - 0x100000000000000000000000000000000; + res += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02 - res += - (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / - 0x200000000000000000000000000000000; + res += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^03 / 03 - y^04 / 04 - res += - (z * (0x099999999999999999999999999999999 - y)) / - 0x300000000000000000000000000000000; + res += (z * (0x099999999999999999999999999999999 - y)) / 0x300000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^05 / 05 - y^06 / 06 - res += - (z * (0x092492492492492492492492492492492 - y)) / - 0x400000000000000000000000000000000; + res += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^07 / 07 - y^08 / 08 - res += - (z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) / - 0x500000000000000000000000000000000; + res += (z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) / 0x500000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^09 / 09 - y^10 / 10 - res += - (z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) / - 0x600000000000000000000000000000000; + res += (z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) / 0x600000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^11 / 11 - y^12 / 12 - res += - (z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) / - 0x700000000000000000000000000000000; + res += (z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) / 0x700000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^13 / 13 - y^14 / 14 - res += - (z * (0x088888888888888888888888888888888 - y)) / - 0x800000000000000000000000000000000; // add y^15 / 15 - y^16 / 16 + res += (z * (0x088888888888888888888888888888888 - y)) / 0x800000000000000000000000000000000; // add y^15 / 15 - y^16 / 16 return res; } diff --git a/packages/contracts/contracts/curation/Curation.sol b/packages/contracts/contracts/curation/Curation.sol index 487bf8a4c..bd3032046 100644 --- a/packages/contracts/contracts/curation/Curation.sol +++ b/packages/contracts/contracts/curation/Curation.sol @@ -57,12 +57,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @dev Emitted when `curator` burned `signal` for a `subgraphDeploymentID`. * The curator will receive `tokens` according to the value of the bonding curve. */ - event Burned( - address indexed curator, - bytes32 indexed subgraphDeploymentID, - uint256 tokens, - uint256 signal - ); + event Burned(address indexed curator, bytes32 indexed subgraphDeploymentID, uint256 tokens, uint256 signal); /** * @dev Emitted when `tokens` amount were collected for `subgraphDeploymentID` as part of fees @@ -113,11 +108,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @notice Update the minimum deposit amount to `_minimumCurationDeposit` * @param _minimumCurationDeposit Minimum amount of tokens required deposit */ - function setMinimumCurationDeposit(uint256 _minimumCurationDeposit) - external - override - onlyGovernor - { + function setMinimumCurationDeposit(uint256 _minimumCurationDeposit) external override onlyGovernor { _setMinimumCurationDeposit(_minimumCurationDeposit); } @@ -149,10 +140,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { require(msg.sender == address(staking()), "Caller must be the staking contract"); // Must be curated to accept tokens - require( - isCurated(_subgraphDeploymentID), - "Subgraph deployment must be curated to collect fees" - ); + require(isCurated(_subgraphDeploymentID), "Subgraph deployment must be curated to collect fees"); // Collect new funds into reserve CurationPool storage curationPool = pools[_subgraphDeploymentID]; @@ -193,9 +181,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { // If no signal token for the pool - create one if (address(curationPool.gcs) == address(0)) { // Use a minimal proxy to reduce gas cost - IGraphCurationToken gcs = IGraphCurationToken( - ClonesUpgradeable.clone(curationTokenMaster) - ); + IGraphCurationToken gcs = IGraphCurationToken(ClonesUpgradeable.clone(curationTokenMaster)); gcs.initialize(address(this)); curationPool.gcs = gcs; } @@ -238,10 +224,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { // Validations require(_signalIn != 0, "Cannot burn zero signal"); - require( - getCuratorSignal(curator, _subgraphDeploymentID) >= _signalIn, - "Cannot burn more signal than you own" - ); + require(getCuratorSignal(curator, _subgraphDeploymentID) >= _signalIn, "Cannot burn more signal than you own"); // Get the amount of tokens to refund based on returned signal uint256 tokensOut = signalToTokens(_subgraphDeploymentID, _signalIn); @@ -277,12 +260,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _subgraphDeploymentID Subgraph deployment curation poool * @return Amount of token reserves in the curation pool */ - function getCurationPoolTokens(bytes32 _subgraphDeploymentID) - external - view - override - returns (uint256) - { + function getCurationPoolTokens(bytes32 _subgraphDeploymentID) external view override returns (uint256) { return pools[_subgraphDeploymentID].tokens; } @@ -301,12 +279,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _subgraphDeploymentID Subgraph deployment curation pool * @return Amount of signal owned by a curator for the subgraph deployment */ - function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256) - { + function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) public view override returns (uint256) { IGraphCurationToken gcs = pools[_subgraphDeploymentID].gcs; return (address(gcs) == address(0)) ? 0 : gcs.balanceOf(_curator); } @@ -316,12 +289,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _subgraphDeploymentID Subgraph deployment curation poool * @return Amount of signal minted for the subgraph deployment */ - function getCurationPoolSignal(bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256) - { + function getCurationPoolSignal(bytes32 _subgraphDeploymentID) public view override returns (uint256) { IGraphCurationToken gcs = pools[_subgraphDeploymentID].gcs; return (address(gcs) == address(0)) ? 0 : gcs.totalSupply(); } @@ -334,12 +302,10 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @return Amount of signal that can be bought * @return Amount of tokens that will be burned as curation tax */ - function tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - public - view - override - returns (uint256, uint256) - { + function tokensToSignal( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) public view override returns (uint256, uint256) { // NOTE: We're aware that this function rounds down and tax can be 0 for small amounts // of tokens but since minimumCurationDeposit is 1 GRT tax will always be greater than 0. uint256 curationTax = _tokensIn.mul(uint256(curationTaxPercentage)).div(MAX_PPM); @@ -353,20 +319,13 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of signal that can be bought with tokens */ - function _tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - private - view - returns (uint256) - { + function _tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) private view returns (uint256) { // Get curation pool tokens and signal CurationPool memory curationPool = pools[_subgraphDeploymentID]; // Init curation pool if (curationPool.tokens == 0) { - require( - _tokensIn >= minimumCurationDeposit, - "Curation deposit is below minimum required" - ); + require(_tokensIn >= minimumCurationDeposit, "Curation deposit is below minimum required"); return BancorFormula(bondingCurve) .calculatePurchaseReturn( @@ -393,22 +352,11 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _signalIn Amount of signal to burn * @return Amount of tokens to get for the specified amount of signal */ - function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) - public - view - override - returns (uint256) - { + function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) public view override returns (uint256) { CurationPool memory curationPool = pools[_subgraphDeploymentID]; uint256 curationPoolSignal = getCurationPoolSignal(_subgraphDeploymentID); - require( - curationPool.tokens != 0, - "Subgraph deployment must be curated to perform calculations" - ); - require( - curationPoolSignal >= _signalIn, - "Signal must be above or equal to signal issued in the curation pool" - ); + require(curationPool.tokens != 0, "Subgraph deployment must be curated to perform calculations"); + require(curationPoolSignal >= _signalIn, "Signal must be above or equal to signal issued in the curation pool"); return BancorFormula(bondingCurve).calculateSaleReturn( @@ -427,10 +375,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { function _setDefaultReserveRatio(uint32 _defaultReserveRatio) private { // Reserve Ratio must be within 0% to 100% (inclusive, in PPM) require(_defaultReserveRatio != 0, "Default reserve ratio must be > 0"); - require( - _defaultReserveRatio <= MAX_PPM, - "Default reserve ratio cannot be higher than MAX_PPM" - ); + require(_defaultReserveRatio <= MAX_PPM, "Default reserve ratio cannot be higher than MAX_PPM"); defaultReserveRatio = _defaultReserveRatio; emit ParameterUpdated("defaultReserveRatio"); @@ -453,10 +398,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _percentage Curation tax charged when depositing GRT tokens in PPM */ function _setCurationTaxPercentage(uint32 _percentage) private { - require( - _percentage <= MAX_PPM, - "Curation tax percentage must be below or equal to MAX_PPM" - ); + require(_percentage <= MAX_PPM, "Curation tax percentage must be below or equal to MAX_PPM"); curationTaxPercentage = _percentage; emit ParameterUpdated("curationTaxPercentage"); @@ -468,10 +410,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { */ function _setCurationTokenMaster(address _curationTokenMaster) private { require(_curationTokenMaster != address(0), "Token master must be non-empty"); - require( - AddressUpgradeable.isContract(_curationTokenMaster), - "Token master must be a contract" - ); + require(AddressUpgradeable.isContract(_curationTokenMaster), "Token master must be a contract"); curationTokenMaster = _curationTokenMaster; emit ParameterUpdated("curationTokenMaster"); diff --git a/packages/contracts/contracts/curation/ICuration.sol b/packages/contracts/contracts/curation/ICuration.sol index dffff46cd..d92aa9c69 100644 --- a/packages/contracts/contracts/curation/ICuration.sol +++ b/packages/contracts/contracts/curation/ICuration.sol @@ -56,11 +56,7 @@ interface ICuration { * @param _tokensOutMin Expected minimum amount of tokens to receive * @return Tokens returned */ - function burn( - bytes32 _subgraphDeploymentID, - uint256 _signalIn, - uint256 _tokensOutMin - ) external returns (uint256); + function burn(bytes32 _subgraphDeploymentID, uint256 _signalIn, uint256 _tokensOutMin) external returns (uint256); /** * @notice Assign Graph Tokens collected as curation fees to the curation pool reserve. @@ -84,10 +80,7 @@ interface ICuration { * @param _subgraphDeploymentID Subgraph deployment curation pool * @return Amount of signal owned by a curator for the subgraph deployment */ - function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) - external - view - returns (uint256); + function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) external view returns (uint256); /** * @notice Get the amount of signal in a curation pool. @@ -111,10 +104,7 @@ interface ICuration { * @return Amount of signal that can be bought * @return Amount of tokens that will be burned as curation tax */ - function tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - view - returns (uint256, uint256); + function tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) external view returns (uint256, uint256); /** * @notice Calculate number of tokens to get when burning signal from a curation pool. @@ -122,10 +112,7 @@ interface ICuration { * @param _signalIn Amount of signal to burn * @return Amount of tokens to get for the specified amount of signal */ - function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) - external - view - returns (uint256); + function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) external view returns (uint256); /** * @notice Tax charged when curators deposit funds. diff --git a/packages/contracts/contracts/discovery/GNS.sol b/packages/contracts/contracts/discovery/GNS.sol index 1430288cc..3cbb9ca8a 100644 --- a/packages/contracts/contracts/discovery/GNS.sol +++ b/packages/contracts/contracts/discovery/GNS.sol @@ -100,11 +100,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { /** * @dev Emitted when a subgraph is created. */ - event SubgraphPublished( - uint256 indexed subgraphID, - bytes32 indexed subgraphDeploymentID, - uint32 reserveRatio - ); + event SubgraphPublished(uint256 indexed subgraphID, bytes32 indexed subgraphDeploymentID, uint32 reserveRatio); /** * @dev Emitted when a subgraph is upgraded to point to a new @@ -126,12 +122,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { /** * @dev Emitted when a curator withdraws GRT from a deprecated subgraph */ - event GRTWithdrawn( - uint256 indexed subgraphID, - address indexed curator, - uint256 nSignalBurnt, - uint256 withdrawnGRT - ); + event GRTWithdrawn(uint256 indexed subgraphID, address indexed curator, uint256 nSignalBurnt, uint256 withdrawnGRT); /** * @dev Emitted when the counterpart (L1/L2) GNS address is updated @@ -230,11 +221,10 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _subgraphID Subgraph ID * @param _subgraphMetadata IPFS hash for the subgraph metadata */ - function updateSubgraphMetadata(uint256 _subgraphID, bytes32 _subgraphMetadata) - external - override - onlySubgraphAuth(_subgraphID) - { + function updateSubgraphMetadata( + uint256 _subgraphID, + bytes32 _subgraphMetadata + ) external override onlySubgraphAuth(_subgraphID) { _setSubgraphMetadata(_subgraphID, _subgraphMetadata); } @@ -311,31 +301,18 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { if (subgraphData.nSignal != 0) { // Burn all version signal in the name pool for tokens (w/no slippage protection) // Sell all signal from the old deployment - uint256 tokens = curation.burn( - subgraphData.subgraphDeploymentID, - subgraphData.vSignal, - 0 - ); + uint256 tokens = curation.burn(subgraphData.subgraphDeploymentID, subgraphData.vSignal, 0); // Take the owner cut of the curation tax, add it to the total // Upgrade is only callable by the owner, we assume then that msg.sender = owner address subgraphOwner = msg.sender; - uint256 tokensWithTax = _chargeOwnerTax( - tokens, - subgraphOwner, - curation.curationTaxPercentage() - ); + uint256 tokensWithTax = _chargeOwnerTax(tokens, subgraphOwner, curation.curationTaxPercentage()); // Update pool: constant nSignal, vSignal can change (w/no slippage protection) // Buy all signal from the new deployment (subgraphData.vSignal, ) = curation.mint(_subgraphDeploymentID, tokensWithTax, 0); - emit SubgraphUpgraded( - _subgraphID, - subgraphData.vSignal, - tokensWithTax, - _subgraphDeploymentID - ); + emit SubgraphUpgraded(_subgraphID, subgraphData.vSignal, tokensWithTax, _subgraphDeploymentID); } // Update target deployment @@ -350,22 +327,13 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * Can only be done by the subgraph owner. * @param _subgraphID Subgraph ID */ - function deprecateSubgraph(uint256 _subgraphID) - external - override - notPaused - onlySubgraphAuth(_subgraphID) - { + function deprecateSubgraph(uint256 _subgraphID) external override notPaused onlySubgraphAuth(_subgraphID) { // Subgraph check SubgraphData storage subgraphData = _getSubgraphOrRevert(_subgraphID); // Burn signal only if it has any available if (subgraphData.nSignal != 0) { - subgraphData.withdrawableGRT = curation().burn( - subgraphData.subgraphDeploymentID, - subgraphData.vSignal, - 0 - ); + subgraphData.withdrawableGRT = curation().burn(subgraphData.subgraphDeploymentID, subgraphData.vSignal, 0); } // Deprecate the subgraph and do cleanup @@ -431,10 +399,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { // Curator balance checks address curator = msg.sender; uint256 curatorNSignal = subgraphData.curatorNSignal[curator]; - require( - _nSignal <= curatorNSignal, - "GNS: Curator cannot withdraw more nSignal than they have" - ); + require(_nSignal <= curatorNSignal, "GNS: Curator cannot withdraw more nSignal than they have"); // Get tokens for name signal amount to burn uint256 vSignal = nSignalToVSignal(_subgraphID, _nSignal); @@ -474,9 +439,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { // Move the signal subgraphData.curatorNSignal[curator] = subgraphData.curatorNSignal[curator].sub(_amount); - subgraphData.curatorNSignal[_recipient] = subgraphData.curatorNSignal[_recipient].add( - _amount - ); + subgraphData.curatorNSignal[_recipient] = subgraphData.curatorNSignal[_recipient].add(_amount); emit SignalTransferred(_subgraphID, curator, _recipient, _amount); } @@ -499,9 +462,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { require(curatorNSignal != 0, "GNS: No signal to withdraw GRT"); // Get curator share of tokens to be withdrawn - uint256 tokensOut = curatorNSignal.mul(subgraphData.withdrawableGRT).div( - subgraphData.nSignal - ); + uint256 tokensOut = curatorNSignal.mul(subgraphData.withdrawableGRT).div(subgraphData.nSignal); subgraphData.curatorNSignal[curator] = 0; subgraphData.nSignal = subgraphData.nSignal.sub(curatorNSignal); subgraphData.withdrawableGRT = subgraphData.withdrawableGRT.sub(tokensOut); @@ -518,22 +479,14 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _subgraphNumber The sequence number of the created subgraph * @param _subgraphMetadata IPFS hash for the subgraph metadata */ - function migrateLegacySubgraph( - address _graphAccount, - uint256 _subgraphNumber, - bytes32 _subgraphMetadata - ) external { + function migrateLegacySubgraph(address _graphAccount, uint256 _subgraphNumber, bytes32 _subgraphMetadata) external { // Must be an existing legacy subgraph - bool legacySubgraphExists = legacySubgraphData[_graphAccount][_subgraphNumber] - .subgraphDeploymentID != 0; + bool legacySubgraphExists = legacySubgraphData[_graphAccount][_subgraphNumber].subgraphDeploymentID != 0; require(legacySubgraphExists == true, "GNS: Subgraph does not exist"); // Must not be a claimed subgraph uint256 subgraphID = _buildLegacySubgraphID(_graphAccount, _subgraphNumber); - require( - legacySubgraphKeys[subgraphID].account == address(0), - "GNS: Subgraph was already claimed" - ); + require(legacySubgraphKeys[subgraphID].account == address(0), "GNS: Subgraph was already claimed"); // Store a reference for a legacy subgraph legacySubgraphKeys[subgraphID] = IGNS.LegacySubgraphKey({ @@ -592,16 +545,10 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _tokensIn Tokens being exchanged for subgraph signal * @return Amount of subgraph signal and curation tax */ - function tokensToNSignal(uint256 _subgraphID, uint256 _tokensIn) - public - view - override - returns ( - uint256, - uint256, - uint256 - ) - { + function tokensToNSignal( + uint256 _subgraphID, + uint256 _tokensIn + ) public view override returns (uint256, uint256, uint256) { SubgraphData storage subgraphData = _getSubgraphData(_subgraphID); (uint256 vSignal, uint256 curationTax) = curation().tokensToSignal( subgraphData.subgraphDeploymentID, @@ -617,12 +564,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _nSignalIn Subgraph signal being exchanged for tokens * @return Amount of tokens returned for an amount of subgraph signal */ - function nSignalToTokens(uint256 _subgraphID, uint256 _nSignalIn) - public - view - override - returns (uint256, uint256) - { + function nSignalToTokens(uint256 _subgraphID, uint256 _nSignalIn) public view override returns (uint256, uint256) { // Get subgraph or revert if not published // It does not make sense to convert signal from a disabled or non-existing one SubgraphData storage subgraphData = _getSubgraphOrRevert(_subgraphID); @@ -637,12 +579,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _vSignalIn Amount of subgraph deployment signal to exchange for subgraph signal * @return Amount of subgraph signal that can be bought */ - function vSignalToNSignal(uint256 _subgraphID, uint256 _vSignalIn) - public - view - override - returns (uint256) - { + function vSignalToNSignal(uint256 _subgraphID, uint256 _vSignalIn) public view override returns (uint256) { SubgraphData storage subgraphData = _getSubgraphData(_subgraphID); // Handle initialization by using 1:1 version to name signal @@ -659,12 +596,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _nSignalIn Subgraph signal being exchanged for subgraph deployment signal * @return Amount of subgraph deployment signal that can be returned */ - function nSignalToVSignal(uint256 _subgraphID, uint256 _nSignalIn) - public - view - override - returns (uint256) - { + function nSignalToVSignal(uint256 _subgraphID, uint256 _nSignalIn) public view override returns (uint256) { SubgraphData storage subgraphData = _getSubgraphData(_subgraphID); return subgraphData.vSignal.mul(_nSignalIn).div(subgraphData.nSignal); } @@ -675,12 +607,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _curator Curator address * @return Amount of subgraph signal owned by a curator */ - function getCuratorSignal(uint256 _subgraphID, address _curator) - public - view - override - returns (uint256) - { + function getCuratorSignal(uint256 _subgraphID, address _curator) public view override returns (uint256) { return _getSubgraphData(_subgraphID).curatorNSignal[_curator]; } @@ -699,12 +626,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @return account Account that created the subgraph (or 0 if it's not a legacy subgraph) * @return seqID Sequence number for the subgraph */ - function getLegacySubgraphKey(uint256 _subgraphID) - public - view - override - returns (address account, uint256 seqID) - { + function getLegacySubgraphKey(uint256 _subgraphID) public view override returns (address account, uint256 seqID) { LegacySubgraphKey storage legacySubgraphKey = legacySubgraphKeys[_subgraphID]; account = legacySubgraphKey.account; seqID = legacySubgraphKey.accountSeqID; @@ -822,12 +744,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _subgraphID Subgraph ID * @return Subgraph Data */ - function _getSubgraphData(uint256 _subgraphID) - internal - view - virtual - returns (SubgraphData storage) - { + function _getSubgraphData(uint256 _subgraphID) internal view virtual returns (SubgraphData storage) { // If there is a legacy subgraph created return it LegacySubgraphKey storage legacySubgraphKey = legacySubgraphKeys[_subgraphID]; if (legacySubgraphKey.account != address(0)) { @@ -851,11 +768,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _subgraphID Subgraph ID * @return Subgraph Data */ - function _getSubgraphOrRevert(uint256 _subgraphID) - internal - view - returns (SubgraphData storage) - { + function _getSubgraphOrRevert(uint256 _subgraphID) internal view returns (SubgraphData storage) { SubgraphData storage subgraphData = _getSubgraphData(_subgraphID); require(_isPublished(subgraphData) == true, "GNS: Must be active"); return subgraphData; @@ -867,11 +780,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * Subgraph ID is the keccak hash of account+seqID * @return Subgraph ID */ - function _buildLegacySubgraphID(address _account, uint256 _seqID) - internal - pure - returns (uint256) - { + function _buildLegacySubgraphID(address _account, uint256 _seqID) internal pure returns (uint256) { return uint256(keccak256(abi.encodePacked(_account, _seqID))); } diff --git a/packages/contracts/contracts/discovery/IGNS.sol b/packages/contracts/contracts/discovery/IGNS.sol index c3a6e0378..9267c70d2 100644 --- a/packages/contracts/contracts/discovery/IGNS.sol +++ b/packages/contracts/contracts/discovery/IGNS.sol @@ -87,11 +87,7 @@ interface IGNS { * @param _subgraphDeploymentID Subgraph deployment ID of the new version * @param _versionMetadata IPFS hash for the subgraph version metadata */ - function publishNewVersion( - uint256 _subgraphID, - bytes32 _subgraphDeploymentID, - bytes32 _versionMetadata - ) external; + function publishNewVersion(uint256 _subgraphID, bytes32 _subgraphDeploymentID, bytes32 _versionMetadata) external; /** * @notice Deprecate a subgraph. The bonding curve is destroyed, the vSignal is burned, and the GNS @@ -109,11 +105,7 @@ interface IGNS { * @param _tokensIn The amount of tokens the nameCurator wants to deposit * @param _nSignalOutMin Expected minimum amount of name signal to receive */ - function mintSignal( - uint256 _subgraphID, - uint256 _tokensIn, - uint256 _nSignalOutMin - ) external; + function mintSignal(uint256 _subgraphID, uint256 _tokensIn, uint256 _nSignalOutMin) external; /** * @notice Burn signal for a subgraph and return the GRT. @@ -121,11 +113,7 @@ interface IGNS { * @param _nSignal The amount of nSignal the nameCurator wants to burn * @param _tokensOutMin Expected minimum amount of tokens to receive */ - function burnSignal( - uint256 _subgraphID, - uint256 _nSignal, - uint256 _tokensOutMin - ) external; + function burnSignal(uint256 _subgraphID, uint256 _nSignal, uint256 _tokensOutMin) external; /** * @notice Move subgraph signal from sender to `_recipient` @@ -133,11 +121,7 @@ interface IGNS { * @param _recipient Address to send the signal to * @param _amount The amount of nSignal to transfer */ - function transferSignal( - uint256 _subgraphID, - address _recipient, - uint256 _amount - ) external; + function transferSignal(uint256 _subgraphID, address _recipient, uint256 _amount) external; /** * @notice Withdraw tokens from a deprecated subgraph. @@ -176,14 +160,7 @@ interface IGNS { * @param _tokensIn Tokens being exchanged for subgraph signal * @return Amount of subgraph signal and curation tax */ - function tokensToNSignal(uint256 _subgraphID, uint256 _tokensIn) - external - view - returns ( - uint256, - uint256, - uint256 - ); + function tokensToNSignal(uint256 _subgraphID, uint256 _tokensIn) external view returns (uint256, uint256, uint256); /** * @notice Calculate tokens returned for an amount of subgraph signal. @@ -191,10 +168,7 @@ interface IGNS { * @param _nSignalIn Subgraph signal being exchanged for tokens * @return Amount of tokens returned for an amount of subgraph signal */ - function nSignalToTokens(uint256 _subgraphID, uint256 _nSignalIn) - external - view - returns (uint256, uint256); + function nSignalToTokens(uint256 _subgraphID, uint256 _nSignalIn) external view returns (uint256, uint256); /** * @notice Calculate subgraph signal to be returned for an amount of subgraph deployment signal. @@ -202,10 +176,7 @@ interface IGNS { * @param _vSignalIn Amount of subgraph deployment signal to exchange for subgraph signal * @return Amount of subgraph signal that can be bought */ - function vSignalToNSignal(uint256 _subgraphID, uint256 _vSignalIn) - external - view - returns (uint256); + function vSignalToNSignal(uint256 _subgraphID, uint256 _vSignalIn) external view returns (uint256); /** * @notice Calculate subgraph deployment signal to be returned for an amount of subgraph signal. @@ -213,10 +184,7 @@ interface IGNS { * @param _nSignalIn Subgraph signal being exchanged for subgraph deployment signal * @return Amount of subgraph deployment signal that can be returned */ - function nSignalToVSignal(uint256 _subgraphID, uint256 _nSignalIn) - external - view - returns (uint256); + function nSignalToVSignal(uint256 _subgraphID, uint256 _nSignalIn) external view returns (uint256); /** * @notice Get the amount of subgraph signal a curator has. @@ -224,10 +192,7 @@ interface IGNS { * @param _curator Curator address * @return Amount of subgraph signal owned by a curator */ - function getCuratorSignal(uint256 _subgraphID, address _curator) - external - view - returns (uint256); + function getCuratorSignal(uint256 _subgraphID, address _curator) external view returns (uint256); /** * @notice Return whether a subgraph is published. @@ -249,8 +214,5 @@ interface IGNS { * @return account Account that created the subgraph (or 0 if it's not a legacy subgraph) * @return seqID Sequence number for the subgraph */ - function getLegacySubgraphKey(uint256 _subgraphID) - external - view - returns (address account, uint256 seqID); + function getLegacySubgraphKey(uint256 _subgraphID) external view returns (address account, uint256 seqID); } diff --git a/packages/contracts/contracts/discovery/IServiceRegistry.sol b/packages/contracts/contracts/discovery/IServiceRegistry.sol index 25eb07477..da284a409 100644 --- a/packages/contracts/contracts/discovery/IServiceRegistry.sol +++ b/packages/contracts/contracts/discovery/IServiceRegistry.sol @@ -10,11 +10,7 @@ interface IServiceRegistry { function register(string calldata _url, string calldata _geohash) external; - function registerFor( - address _indexer, - string calldata _url, - string calldata _geohash - ) external; + function registerFor(address _indexer, string calldata _url, string calldata _geohash) external; function unregister() external; diff --git a/packages/contracts/contracts/discovery/L1GNS.sol b/packages/contracts/contracts/discovery/L1GNS.sol index a2d15e1a7..31e9b0fb3 100644 --- a/packages/contracts/contracts/discovery/L1GNS.sol +++ b/packages/contracts/contracts/discovery/L1GNS.sol @@ -60,10 +60,7 @@ contract L1GNS is GNS, L1GNSV1Storage { uint256 _maxSubmissionCost ) external payable notPartialPaused { require(!subgraphTransferredToL2[_subgraphID], "ALREADY_DONE"); - require( - msg.value == _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)), - "INVALID_ETH_VALUE" - ); + require(msg.value == _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)), "INVALID_ETH_VALUE"); SubgraphData storage subgraphData = _getSubgraphOrRevert(_subgraphID); // This is just like onlySubgraphAuth, but we want it to run after the subgraphTransferredToL2 check @@ -71,11 +68,7 @@ contract L1GNS is GNS, L1GNSV1Storage { require(ownerOf(_subgraphID) == msg.sender, "GNS: Must be authorized"); subgraphTransferredToL2[_subgraphID] = true; - uint256 curationTokens = curation().burn( - subgraphData.subgraphDeploymentID, - subgraphData.vSignal, - 0 - ); + uint256 curationTokens = curation().burn(subgraphData.subgraphDeploymentID, subgraphData.vSignal, 0); subgraphData.disabled = true; subgraphData.vSignal = 0; @@ -93,19 +86,9 @@ contract L1GNS is GNS, L1GNSV1Storage { subgraphData.nSignal = totalSignal.sub(ownerNSignal); subgraphData.withdrawableGRT = curationTokens.sub(tokensForL2); - bytes memory extraData = abi.encode( - uint8(IL2GNS.L1MessageCodes.RECEIVE_SUBGRAPH_CODE), - _subgraphID, - _l2Owner - ); + bytes memory extraData = abi.encode(uint8(IL2GNS.L1MessageCodes.RECEIVE_SUBGRAPH_CODE), _subgraphID, _l2Owner); - _sendTokensAndMessageToL2GNS( - tokensForL2, - _maxGas, - _gasPriceBid, - _maxSubmissionCost, - extraData - ); + _sendTokensAndMessageToL2GNS(tokensForL2, _maxGas, _gasPriceBid, _maxSubmissionCost, extraData); subgraphData.__DEPRECATED_reserveRatio = 0; _burnNFT(_subgraphID); @@ -138,10 +121,7 @@ contract L1GNS is GNS, L1GNSV1Storage { uint256 _maxSubmissionCost ) external payable notPartialPaused { require(subgraphTransferredToL2[_subgraphID], "!TRANSFERRED"); - require( - msg.value == _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)), - "INVALID_ETH_VALUE" - ); + require(msg.value == _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)), "INVALID_ETH_VALUE"); // The Arbitrum bridge will check this too, we just check here for an early exit require(_maxSubmissionCost != 0, "NO_SUBMISSION_COST"); @@ -165,13 +145,7 @@ contract L1GNS is GNS, L1GNSV1Storage { subgraphData.withdrawableGRT = withdrawableGRT.sub(tokensForL2); // Send the tokens and data to L2 using the L1GraphTokenGateway - _sendTokensAndMessageToL2GNS( - tokensForL2, - _maxGas, - _gasPriceBid, - _maxSubmissionCost, - extraData - ); + _sendTokensAndMessageToL2GNS(tokensForL2, _maxGas, _gasPriceBid, _maxSubmissionCost, extraData); emit CuratorBalanceSentToL2(_subgraphID, msg.sender, _beneficiary, tokensForL2); } diff --git a/packages/contracts/contracts/discovery/ServiceRegistry.sol b/packages/contracts/contracts/discovery/ServiceRegistry.sol index 228210bf1..1eb1393d3 100644 --- a/packages/contracts/contracts/discovery/ServiceRegistry.sol +++ b/packages/contracts/contracts/discovery/ServiceRegistry.sol @@ -49,11 +49,7 @@ contract ServiceRegistry is ServiceRegistryV1Storage, GraphUpgradeable, IService * @param _url URL of the indexer service * @param _geohash Geohash of the indexer service location */ - function registerFor( - address _indexer, - string calldata _url, - string calldata _geohash - ) external override { + function registerFor(address _indexer, string calldata _url, string calldata _geohash) external override { _register(_indexer, _url, _geohash); } @@ -63,11 +59,7 @@ contract ServiceRegistry is ServiceRegistryV1Storage, GraphUpgradeable, IService * @param _url URL of the indexer service * @param _geohash Geohash of the indexer service location */ - function _register( - address _indexer, - string calldata _url, - string calldata _geohash - ) private { + function _register(address _indexer, string calldata _url, string calldata _geohash) private { require(_isAuth(_indexer), "!auth"); require(bytes(_url).length > 0, "Service must specify a URL"); diff --git a/packages/contracts/contracts/discovery/SubgraphNFT.sol b/packages/contracts/contracts/discovery/SubgraphNFT.sol index c6dadaa81..3c514718c 100644 --- a/packages/contracts/contracts/discovery/SubgraphNFT.sol +++ b/packages/contracts/contracts/discovery/SubgraphNFT.sol @@ -114,11 +114,7 @@ contract SubgraphNFT is Governed, ERC721, ISubgraphNFT { * @param _tokenId ID of the NFT * @param _subgraphMetadata IPFS hash for the metadata */ - function setSubgraphMetadata(uint256 _tokenId, bytes32 _subgraphMetadata) - external - override - onlyMinter - { + function setSubgraphMetadata(uint256 _tokenId, bytes32 _subgraphMetadata) external override onlyMinter { require(_exists(_tokenId), "ERC721Metadata: URI set of nonexistent token"); _subgraphMetadataHashes[_tokenId] = _subgraphMetadata; emit SubgraphMetadataUpdated(_tokenId, _subgraphMetadata); @@ -127,24 +123,13 @@ contract SubgraphNFT is Governed, ERC721, ISubgraphNFT { // -- NFT display -- /// @inheritdoc ERC721 - function tokenURI(uint256 _tokenId) - public - view - override(ERC721, ISubgraphNFT) - returns (string memory) - { + function tokenURI(uint256 _tokenId) public view override(ERC721, ISubgraphNFT) returns (string memory) { require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token"); // Delegates rendering of the metadata to the token descriptor if existing // This allows for some flexibility in adapting the token URI if (address(tokenDescriptor) != address(0)) { - return - tokenDescriptor.tokenURI( - minter, - _tokenId, - baseURI(), - _subgraphMetadataHashes[_tokenId] - ); + return tokenDescriptor.tokenURI(minter, _tokenId, baseURI(), _subgraphMetadataHashes[_tokenId]); } // Default token URI diff --git a/packages/contracts/contracts/discovery/SubgraphNFTDescriptor.sol b/packages/contracts/contracts/discovery/SubgraphNFTDescriptor.sol index 751db2353..81f6da696 100644 --- a/packages/contracts/contracts/discovery/SubgraphNFTDescriptor.sol +++ b/packages/contracts/contracts/discovery/SubgraphNFTDescriptor.sol @@ -9,14 +9,12 @@ import "./ISubgraphNFTDescriptor.sol"; contract SubgraphNFTDescriptor is ISubgraphNFTDescriptor { /// @inheritdoc ISubgraphNFTDescriptor function tokenURI( - address, /* _minter */ - uint256, /* _tokenId */ + address /* _minter */, + uint256 /* _tokenId */, string calldata _baseURI, bytes32 _subgraphMetadata ) external pure override returns (string memory) { - bytes memory b58 = Base58Encoder.encode( - abi.encodePacked(Base58Encoder.sha256MultiHash, _subgraphMetadata) - ); + bytes memory b58 = Base58Encoder.encode(abi.encodePacked(Base58Encoder.sha256MultiHash, _subgraphMetadata)); if (bytes(_baseURI).length == 0) { return string(b58); } diff --git a/packages/contracts/contracts/discovery/erc1056/EthereumDIDRegistry.sol b/packages/contracts/contracts/discovery/erc1056/EthereumDIDRegistry.sol index dce0e830a..e8545dd4a 100644 --- a/packages/contracts/contracts/discovery/erc1056/EthereumDIDRegistry.sol +++ b/packages/contracts/contracts/discovery/erc1056/EthereumDIDRegistry.sol @@ -62,21 +62,13 @@ contract EthereumDIDRegistry { return signer; } - function validDelegate( - address identity, - bytes32 delegateType, - address delegate - ) public view returns (bool) { + function validDelegate(address identity, bytes32 delegateType, address delegate) public view returns (bool) { uint256 validity = delegates[identity][keccak256(abi.encode(delegateType))][delegate]; /* solium-disable-next-line security/no-block-members*/ return (validity > block.timestamp); } - function changeOwner( - address identity, - address actor, - address newOwner - ) internal onlyOwner(identity, actor) { + function changeOwner(address identity, address actor, address newOwner) internal onlyOwner(identity, actor) { owners[identity] = newOwner; emit DIDOwnerChanged(identity, newOwner, changed[identity]); changed[identity] = block.number; @@ -86,13 +78,7 @@ contract EthereumDIDRegistry { changeOwner(identity, msg.sender, newOwner); } - function changeOwnerSigned( - address identity, - uint8 sigV, - bytes32 sigR, - bytes32 sigS, - address newOwner - ) public { + function changeOwnerSigned(address identity, uint8 sigV, bytes32 sigR, bytes32 sigS, address newOwner) public { bytes32 hash = keccak256( abi.encodePacked( bytes1(0x19), @@ -115,9 +101,7 @@ contract EthereumDIDRegistry { uint256 validity ) internal onlyOwner(identity, actor) { /* solium-disable-next-line security/no-block-members*/ - delegates[identity][keccak256(abi.encode(delegateType))][delegate] = - block.timestamp + - validity; + delegates[identity][keccak256(abi.encode(delegateType))][delegate] = block.timestamp + validity; emit DIDDelegateChanged( identity, delegateType, @@ -129,12 +113,7 @@ contract EthereumDIDRegistry { changed[identity] = block.number; } - function addDelegate( - address identity, - bytes32 delegateType, - address delegate, - uint256 validity - ) public { + function addDelegate(address identity, bytes32 delegateType, address delegate, uint256 validity) public { addDelegate(identity, msg.sender, delegateType, delegate, validity); } @@ -160,13 +139,7 @@ contract EthereumDIDRegistry { validity ) ); - addDelegate( - identity, - checkSignature(identity, sigV, sigR, sigS, hash), - delegateType, - delegate, - validity - ); + addDelegate(identity, checkSignature(identity, sigV, sigR, sigS, hash), delegateType, delegate, validity); } function revokeDelegate( @@ -178,21 +151,11 @@ contract EthereumDIDRegistry { /* solium-disable-next-line security/no-block-members*/ delegates[identity][keccak256(abi.encode(delegateType))][delegate] = block.timestamp; /* solium-disable-next-line security/no-block-members*/ - emit DIDDelegateChanged( - identity, - delegateType, - delegate, - block.timestamp, - changed[identity] - ); + emit DIDDelegateChanged(identity, delegateType, delegate, block.timestamp, changed[identity]); changed[identity] = block.number; } - function revokeDelegate( - address identity, - bytes32 delegateType, - address delegate - ) public { + function revokeDelegate(address identity, bytes32 delegateType, address delegate) public { revokeDelegate(identity, msg.sender, delegateType, delegate); } @@ -216,12 +179,7 @@ contract EthereumDIDRegistry { delegate ) ); - revokeDelegate( - identity, - checkSignature(identity, sigV, sigR, sigS, hash), - delegateType, - delegate - ); + revokeDelegate(identity, checkSignature(identity, sigV, sigR, sigS, hash), delegateType, delegate); } function setAttribute( @@ -232,22 +190,11 @@ contract EthereumDIDRegistry { uint256 validity ) internal onlyOwner(identity, actor) { /* solium-disable-next-line security/no-block-members*/ - emit DIDAttributeChanged( - identity, - name, - value, - block.timestamp + validity, - changed[identity] - ); + emit DIDAttributeChanged(identity, name, value, block.timestamp + validity, changed[identity]); changed[identity] = block.number; } - function setAttribute( - address identity, - bytes32 name, - bytes memory value, - uint256 validity - ) public { + function setAttribute(address identity, bytes32 name, bytes memory value, uint256 validity) public { setAttribute(identity, msg.sender, name, value, validity); } @@ -273,13 +220,7 @@ contract EthereumDIDRegistry { validity ) ); - setAttribute( - identity, - checkSignature(identity, sigV, sigR, sigS, hash), - name, - value, - validity - ); + setAttribute(identity, checkSignature(identity, sigV, sigR, sigS, hash), name, value, validity); } function revokeAttribute( @@ -292,11 +233,7 @@ contract EthereumDIDRegistry { changed[identity] = block.number; } - function revokeAttribute( - address identity, - bytes32 name, - bytes memory value - ) public { + function revokeAttribute(address identity, bytes32 name, bytes memory value) public { revokeAttribute(identity, msg.sender, name, value); } diff --git a/packages/contracts/contracts/discovery/erc1056/IEthereumDIDRegistry.sol b/packages/contracts/contracts/discovery/erc1056/IEthereumDIDRegistry.sol index 10a383f85..8de69f304 100644 --- a/packages/contracts/contracts/discovery/erc1056/IEthereumDIDRegistry.sol +++ b/packages/contracts/contracts/discovery/erc1056/IEthereumDIDRegistry.sol @@ -5,10 +5,5 @@ pragma solidity ^0.7.6; interface IEthereumDIDRegistry { function identityOwner(address identity) external view returns (address); - function setAttribute( - address identity, - bytes32 name, - bytes calldata value, - uint256 validity - ) external; + function setAttribute(address identity, bytes32 name, bytes calldata value, uint256 validity) external; } diff --git a/packages/contracts/contracts/disputes/DisputeManager.sol b/packages/contracts/contracts/disputes/DisputeManager.sol index 8122b86b7..6700ec341 100644 --- a/packages/contracts/contracts/disputes/DisputeManager.sol +++ b/packages/contracts/contracts/disputes/DisputeManager.sol @@ -42,13 +42,10 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa // -- EIP-712 -- bytes32 private constant DOMAIN_TYPE_HASH = - keccak256( - "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)" - ); + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)"); bytes32 private constant DOMAIN_NAME_HASH = keccak256("Graph Protocol"); bytes32 private constant DOMAIN_VERSION_HASH = keccak256("0"); - bytes32 private constant DOMAIN_SALT = - 0xa070ffb1cd7409649bf77822cce74495468e06dbfaef09556838bf188679b9c2; + bytes32 private constant DOMAIN_SALT = 0xa070ffb1cd7409649bf77822cce74495468e06dbfaef09556838bf188679b9c2; bytes32 private constant RECEIPT_TYPE_HASH = keccak256("Receipt(bytes32 requestCID,bytes32 responseCID,bytes32 subgraphDeploymentID)"); @@ -126,12 +123,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @dev Emitted when arbitrator draw a `disputeID` for `indexer` created by `fisherman`. * The event emits the amount `tokens` used as deposit and returned to the fisherman. */ - event DisputeDrawn( - bytes32 indexed disputeID, - address indexed indexer, - address indexed fisherman, - uint256 tokens - ); + event DisputeDrawn(bytes32 indexed disputeID, address indexed indexer, address indexed fisherman, uint256 tokens); /** * @dev Emitted when two disputes are in conflict to link them. @@ -156,10 +148,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa modifier onlyPendingDispute(bytes32 _disputeID) { require(isDisputeCreated(_disputeID), "Dispute does not exist"); - require( - disputes[_disputeID].status == IDisputeManager.DisputeStatus.Pending, - "Dispute must be pending" - ); + require(disputes[_disputeID].status == IDisputeManager.DisputeStatus.Pending, "Dispute must be pending"); _; } @@ -268,11 +257,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _qryPercentage Percentage slashing for query disputes * @param _idxPercentage Percentage slashing for indexing disputes */ - function setSlashingPercentage(uint32 _qryPercentage, uint32 _idxPercentage) - external - override - onlyGovernor - { + function setSlashingPercentage(uint32 _qryPercentage, uint32 _idxPercentage) external override onlyGovernor { _setSlashingPercentage(_qryPercentage, _idxPercentage); } @@ -349,12 +334,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _attestation Attestation * @return Indexer address */ - function getAttestationIndexer(Attestation memory _attestation) - public - view - override - returns (address) - { + function getAttestationIndexer(Attestation memory _attestation) public view override returns (address) { // Get attestation signer. Indexers signs with the allocationID address allocationID = _recoverAttestationSigner(_attestation); @@ -374,11 +354,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _attestationData Attestation bytes submitted by the fisherman * @param _deposit Amount of tokens staked as deposit */ - function createQueryDispute(bytes calldata _attestationData, uint256 _deposit) - external - override - returns (bytes32) - { + function createQueryDispute(bytes calldata _attestationData, uint256 _deposit) external override returns (bytes32) { // Get funds from submitter _pullSubmitterDeposit(_deposit); @@ -415,25 +391,12 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa Attestation memory attestation2 = _parseAttestation(_attestationData2); // Test that attestations are conflicting - require( - areConflictingAttestations(attestation1, attestation2), - "Attestations must be in conflict" - ); + require(areConflictingAttestations(attestation1, attestation2), "Attestations must be in conflict"); // Create the disputes // The deposit is zero for conflicting attestations - bytes32 dID1 = _createQueryDisputeWithAttestation( - fisherman, - 0, - attestation1, - _attestationData1 - ); - bytes32 dID2 = _createQueryDisputeWithAttestation( - fisherman, - 0, - attestation2, - _attestationData2 - ); + bytes32 dID1 = _createQueryDisputeWithAttestation(fisherman, 0, attestation1, _attestationData1); + bytes32 dID2 = _createQueryDisputeWithAttestation(fisherman, 0, attestation2, _attestationData2); // Store the linked disputes to be resolved disputes[dID1].relatedDisputeID = dID2; @@ -512,11 +475,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _allocationID The allocation to dispute * @param _deposit Amount of tokens staked as deposit */ - function createIndexingDispute(address _allocationID, uint256 _deposit) - external - override - returns (bytes32) - { + function createIndexingDispute(address _allocationID, uint256 _deposit) external override returns (bytes32) { // Get funds from submitter _pullSubmitterDeposit(_deposit); @@ -573,23 +532,14 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @notice Accept a dispute with ID `_disputeID` * @param _disputeID ID of the dispute to be accepted */ - function acceptDispute(bytes32 _disputeID) - external - override - onlyArbitrator - onlyPendingDispute(_disputeID) - { + function acceptDispute(bytes32 _disputeID) external override onlyArbitrator onlyPendingDispute(_disputeID) { Dispute storage dispute = disputes[_disputeID]; // store the dispute status dispute.status = IDisputeManager.DisputeStatus.Accepted; // Slash - (, uint256 tokensToReward) = _slashIndexer( - dispute.indexer, - dispute.fisherman, - dispute.disputeType - ); + (, uint256 tokensToReward) = _slashIndexer(dispute.indexer, dispute.fisherman, dispute.disputeType); // Give the fisherman their deposit back TokenUtils.pushTokens(graphToken(), dispute.fisherman, dispute.deposit); @@ -598,12 +548,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa rejectDispute(dispute.relatedDisputeID); } - emit DisputeAccepted( - _disputeID, - dispute.indexer, - dispute.fisherman, - dispute.deposit.add(tokensToReward) - ); + emit DisputeAccepted(_disputeID, dispute.indexer, dispute.fisherman, dispute.deposit.add(tokensToReward)); } /** @@ -611,12 +556,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @notice Reject a dispute with ID `_disputeID` * @param _disputeID ID of the dispute to be rejected */ - function rejectDispute(bytes32 _disputeID) - public - override - onlyArbitrator - onlyPendingDispute(_disputeID) - { + function rejectDispute(bytes32 _disputeID) public override onlyArbitrator onlyPendingDispute(_disputeID) { Dispute storage dispute = disputes[_disputeID]; // store dispute status @@ -639,12 +579,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @notice Ignore a dispute with ID `_disputeID` * @param _disputeID ID of the dispute to be disregarded */ - function drawDispute(bytes32 _disputeID) - public - override - onlyArbitrator - onlyPendingDispute(_disputeID) - { + function drawDispute(bytes32 _disputeID) public override onlyArbitrator onlyPendingDispute(_disputeID) { Dispute storage dispute = disputes[_disputeID]; // Return deposit to the fisherman @@ -667,8 +602,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa function _isDisputeInConflict(Dispute memory _dispute) private view returns (bool) { bytes32 relatedID = _dispute.relatedDisputeID; // this is so the check returns false when rejecting the related dispute. - return - relatedID != 0 && disputes[relatedID].status == IDisputeManager.DisputeStatus.Pending; + return relatedID != 0 && disputes[relatedID].status == IDisputeManager.DisputeStatus.Pending; } /** @@ -718,9 +652,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa uint256 slashableAmount = staking.getIndexerStakedTokens(_indexer); // slashable tokens // Get slash amount - slashAmount = _getSlashingPercentageForDisputeType(_disputeType).mul(slashableAmount).div( - MAX_PPM - ); + slashAmount = _getSlashingPercentageForDisputeType(_disputeType).mul(slashableAmount).div(MAX_PPM); require(slashAmount > 0, "Dispute has zero tokens to slash"); // Get rewards amount @@ -736,11 +668,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _disputeType Dispute type * @return Slashing percentage to use for the dispute type */ - function _getSlashingPercentageForDisputeType(DisputeType _disputeType) - private - view - returns (uint256) - { + function _getSlashingPercentageForDisputeType(DisputeType _disputeType) private view returns (uint256) { if (_disputeType == DisputeType.QueryDispute) return uint256(qrySlashingPercentage); if (_disputeType == DisputeType.IndexingDispute) return uint256(idxSlashingPercentage); return 0; @@ -751,11 +679,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _attestation The attestation struct * @return Signer address */ - function _recoverAttestationSigner(Attestation memory _attestation) - private - view - returns (address) - { + function _recoverAttestationSigner(Attestation memory _attestation) private view returns (address) { // Obtain the hash of the fully-encoded message, per EIP-712 encoding Receipt memory receipt = Receipt( _attestation.requestCID, @@ -766,11 +690,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa // Obtain the signer of the fully-encoded EIP-712 message hash // NOTE: The signer of the attestation is the indexer that served the request - return - ECDSA.recover( - messageHash, - abi.encodePacked(_attestation.r, _attestation.s, _attestation.v) - ); + return ECDSA.recover(messageHash, abi.encodePacked(_attestation.r, _attestation.s, _attestation.v)); } /** diff --git a/packages/contracts/contracts/disputes/IDisputeManager.sol b/packages/contracts/contracts/disputes/IDisputeManager.sol index 9c872f890..8c6668371 100644 --- a/packages/contracts/contracts/disputes/IDisputeManager.sol +++ b/packages/contracts/contracts/disputes/IDisputeManager.sol @@ -74,18 +74,14 @@ interface IDisputeManager { // -- Dispute -- - function createQueryDispute(bytes calldata _attestationData, uint256 _deposit) - external - returns (bytes32); + function createQueryDispute(bytes calldata _attestationData, uint256 _deposit) external returns (bytes32); function createQueryDisputeConflict( bytes calldata _attestationData1, bytes calldata _attestationData2 ) external returns (bytes32, bytes32); - function createIndexingDispute(address _allocationID, uint256 _deposit) - external - returns (bytes32); + function createIndexingDispute(address _allocationID, uint256 _deposit) external returns (bytes32); function acceptDispute(bytes32 _disputeID) external; diff --git a/packages/contracts/contracts/epochs/EpochManager.sol b/packages/contracts/contracts/epochs/EpochManager.sol index 3f022d4af..281b63896 100644 --- a/packages/contracts/contracts/epochs/EpochManager.sol +++ b/packages/contracts/contracts/epochs/EpochManager.sol @@ -93,10 +93,7 @@ contract EpochManager is EpochManagerV1Storage, GraphUpgradeable, IEpochManager uint256 currentBlock = blockNum(); require(_block < currentBlock, "Can only retrieve past block hashes"); - require( - currentBlock < 256 || _block >= currentBlock - 256, - "Can only retrieve hashes for last 256 blocks" - ); + require(currentBlock < 256 || _block >= currentBlock - 256, "Can only retrieve hashes for last 256 blocks"); return blockhash(_block); } diff --git a/packages/contracts/contracts/gateway/GraphTokenGateway.sol b/packages/contracts/contracts/gateway/GraphTokenGateway.sol index ca2ad4c95..fb992afc2 100644 --- a/packages/contracts/contracts/gateway/GraphTokenGateway.sol +++ b/packages/contracts/contracts/gateway/GraphTokenGateway.sol @@ -19,10 +19,7 @@ abstract contract GraphTokenGateway is GraphUpgradeable, Pausable, Managed, ITok * @dev Check if the caller is the Controller's governor or this contract's pause guardian. */ modifier onlyGovernorOrGuardian() { - require( - msg.sender == controller.getGovernor() || msg.sender == pauseGuardian, - "Only Governor or Guardian" - ); + require(msg.sender == controller.getGovernor() || msg.sender == pauseGuardian, "Only Governor or Guardian"); _; } diff --git a/packages/contracts/contracts/gateway/ICallhookReceiver.sol b/packages/contracts/contracts/gateway/ICallhookReceiver.sol index ff0fbfab1..885b0cdb2 100644 --- a/packages/contracts/contracts/gateway/ICallhookReceiver.sol +++ b/packages/contracts/contracts/gateway/ICallhookReceiver.sol @@ -15,9 +15,5 @@ interface ICallhookReceiver { * @param _amount Amount of tokens that were transferred * @param _data ABI-encoded callhook data */ - function onTokenTransfer( - address _from, - uint256 _amount, - bytes calldata _data - ) external; + function onTokenTransfer(address _from, uint256 _amount, bytes calldata _data) external; } diff --git a/packages/contracts/contracts/gateway/L1GraphTokenGateway.sol b/packages/contracts/contracts/gateway/L1GraphTokenGateway.sol index cfa71e6a0..7fad927ad 100644 --- a/packages/contracts/contracts/gateway/L1GraphTokenGateway.sol +++ b/packages/contracts/contracts/gateway/L1GraphTokenGateway.sol @@ -207,10 +207,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess * @param _l2IssuancePerBlock New issuancePerBlock that has been set in L2 * @param _updateBlockNum L1 Block number at which issuancePerBlock was updated in L2 */ - function updateL2MintAllowance(uint256 _l2IssuancePerBlock, uint256 _updateBlockNum) - external - onlyGovernor - { + function updateL2MintAllowance(uint256 _l2IssuancePerBlock, uint256 _updateBlockNum) external onlyGovernor { require(_updateBlockNum < block.number, "BLOCK_MUST_BE_PAST"); require(_updateBlockNum > lastL2MintAllowanceUpdateBlock, "BLOCK_MUST_BE_INCREMENTING"); accumulatedL2MintAllowanceSnapshot = accumulatedL2MintAllowanceAtBlock(_updateBlockNum); @@ -290,30 +287,15 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess { bytes memory extraData; (from, maxSubmissionCost, extraData) = _parseOutboundData(_data); - require( - extraData.length == 0 || callhookAllowlist[msg.sender] == true, - "CALL_HOOK_DATA_NOT_ALLOWED" - ); + require(extraData.length == 0 || callhookAllowlist[msg.sender] == true, "CALL_HOOK_DATA_NOT_ALLOWED"); require(maxSubmissionCost != 0, "NO_SUBMISSION_COST"); outboundCalldata = getOutboundCalldata(_l1Token, from, _to, _amount, extraData); } { - L2GasParams memory gasParams = L2GasParams( - maxSubmissionCost, - _maxGas, - _gasPriceBid - ); + L2GasParams memory gasParams = L2GasParams(maxSubmissionCost, _maxGas, _gasPriceBid); // transfer tokens to escrow token.transferFrom(from, escrow, _amount); - seqNum = sendTxToL2( - inbox, - l2Counterpart, - from, - msg.value, - 0, - gasParams, - outboundCalldata - ); + seqNum = sendTxToL2(inbox, l2Counterpart, from, msg.value, 0, gasParams, outboundCalldata); } } emit DepositInitiated(_l1Token, from, _to, seqNum, _amount); @@ -425,15 +407,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess * @return Base ether value required to keep retryable ticket alive * @return Additional data sent to L2 */ - function _parseOutboundData(bytes calldata _data) - private - view - returns ( - address, - uint256, - bytes memory - ) - { + function _parseOutboundData(bytes calldata _data) private view returns (address, uint256, bytes memory) { address from; uint256 maxSubmissionCost; bytes memory extraData; diff --git a/packages/contracts/contracts/governance/Controller.sol b/packages/contracts/contracts/governance/Controller.sol index bc287d2be..affb29a05 100644 --- a/packages/contracts/contracts/governance/Controller.sol +++ b/packages/contracts/contracts/governance/Controller.sol @@ -32,10 +32,7 @@ contract Controller is Governed, Pausable, IController { * @dev Check if the caller is the governor or pause guardian. */ modifier onlyGovernorOrGuardian() { - require( - msg.sender == governor || msg.sender == pauseGuardian, - "Only Governor or Guardian can call" - ); + require(msg.sender == governor || msg.sender == pauseGuardian, "Only Governor or Guardian can call"); _; } @@ -53,11 +50,7 @@ contract Controller is Governed, Pausable, IController { * @param _id Contract id (keccak256 hash of contract name) * @param _contractAddress Contract address */ - function setContractProxy(bytes32 _id, address _contractAddress) - external - override - onlyGovernor - { + function setContractProxy(bytes32 _id, address _contractAddress) external override onlyGovernor { require(_contractAddress != address(0), "Contract address must be set"); _registry[_id] = _contractAddress; emit SetContractProxy(_id, _contractAddress); diff --git a/packages/contracts/contracts/l2/curation/IL2Curation.sol b/packages/contracts/contracts/l2/curation/IL2Curation.sol index 235eec28a..bbbfd82ff 100644 --- a/packages/contracts/contracts/l2/curation/IL2Curation.sol +++ b/packages/contracts/contracts/l2/curation/IL2Curation.sol @@ -14,9 +14,7 @@ interface IL2Curation { * @param _tokensIn Amount of Graph Tokens to deposit * @return Signal minted */ - function mintTaxFree(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - returns (uint256); + function mintTaxFree(bytes32 _subgraphDeploymentID, uint256 _tokensIn) external returns (uint256); /** * @notice Calculate amount of signal that can be bought with tokens in a curation pool, @@ -25,10 +23,7 @@ interface IL2Curation { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of signal that can be bought */ - function tokensToSignalNoTax(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - view - returns (uint256); + function tokensToSignalNoTax(bytes32 _subgraphDeploymentID, uint256 _tokensIn) external view returns (uint256); /** * @notice Calculate the amount of tokens that would be recovered if minting signal with @@ -38,8 +33,8 @@ interface IL2Curation { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of tokens that would be recovered after minting and burning signal */ - function tokensToSignalToTokensNoTax(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - view - returns (uint256); + function tokensToSignalToTokensNoTax( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) external view returns (uint256); } diff --git a/packages/contracts/contracts/l2/curation/L2Curation.sol b/packages/contracts/contracts/l2/curation/L2Curation.sol index 0da3ce768..4d51bf3f1 100644 --- a/packages/contracts/contracts/l2/curation/L2Curation.sol +++ b/packages/contracts/contracts/l2/curation/L2Curation.sol @@ -59,12 +59,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @dev Emitted when `curator` burned `signal` for a `subgraphDeploymentID`. * The curator will receive `tokens` according to the value of the bonding curve. */ - event Burned( - address indexed curator, - bytes32 indexed subgraphDeploymentID, - uint256 tokens, - uint256 signal - ); + event Burned(address indexed curator, bytes32 indexed subgraphDeploymentID, uint256 tokens, uint256 signal); /** * @dev Emitted when `tokens` amount were collected for `subgraphDeploymentID` as part of fees @@ -116,11 +111,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @notice Update the minimum deposit amount to `_minimumCurationDeposit` * @param _minimumCurationDeposit Minimum amount of tokens required deposit */ - function setMinimumCurationDeposit(uint256 _minimumCurationDeposit) - external - override - onlyGovernor - { + function setMinimumCurationDeposit(uint256 _minimumCurationDeposit) external override onlyGovernor { _setMinimumCurationDeposit(_minimumCurationDeposit); } @@ -152,10 +143,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { require(msg.sender == address(staking()), "Caller must be the staking contract"); // Must be curated to accept tokens - require( - isCurated(_subgraphDeploymentID), - "Subgraph deployment must be curated to collect fees" - ); + require(isCurated(_subgraphDeploymentID), "Subgraph deployment must be curated to collect fees"); // Collect new funds into reserve CurationPool storage curationPool = pools[_subgraphDeploymentID]; @@ -196,9 +184,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { // If no signal token for the pool - create one if (address(curationPool.gcs) == address(0)) { // Use a minimal proxy to reduce gas cost - IGraphCurationToken gcs = IGraphCurationToken( - ClonesUpgradeable.clone(curationTokenMaster) - ); + IGraphCurationToken gcs = IGraphCurationToken(ClonesUpgradeable.clone(curationTokenMaster)); gcs.initialize(address(this)); curationPool.gcs = gcs; } @@ -232,13 +218,10 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _tokensIn Amount of Graph Tokens to deposit * @return Signal minted */ - function mintTaxFree(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - override - notPartialPaused - onlyGNS - returns (uint256) - { + function mintTaxFree( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) external override notPartialPaused onlyGNS returns (uint256) { // Need to deposit some funds require(_tokensIn != 0, "Cannot deposit zero tokens"); @@ -256,9 +239,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { // If no signal token for the pool - create one if (address(curationPool.gcs) == address(0)) { // Use a minimal proxy to reduce gas cost - IGraphCurationToken gcs = IGraphCurationToken( - ClonesUpgradeable.clone(curationTokenMaster) - ); + IGraphCurationToken gcs = IGraphCurationToken(ClonesUpgradeable.clone(curationTokenMaster)); gcs.initialize(address(this)); curationPool.gcs = gcs; } @@ -299,10 +280,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { // Validations require(_signalIn != 0, "Cannot burn zero signal"); - require( - getCuratorSignal(curator, _subgraphDeploymentID) >= _signalIn, - "Cannot burn more signal than you own" - ); + require(getCuratorSignal(curator, _subgraphDeploymentID) >= _signalIn, "Cannot burn more signal than you own"); // Get the amount of tokens to refund based on returned signal uint256 tokensOut = signalToTokens(_subgraphDeploymentID, _signalIn); @@ -337,12 +315,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _subgraphDeploymentID Subgraph deployment curation poool * @return Amount of token reserves in the curation pool */ - function getCurationPoolTokens(bytes32 _subgraphDeploymentID) - external - view - override - returns (uint256) - { + function getCurationPoolTokens(bytes32 _subgraphDeploymentID) external view override returns (uint256) { return pools[_subgraphDeploymentID].tokens; } @@ -361,12 +334,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _subgraphDeploymentID Subgraph deployment curation pool * @return Amount of signal owned by a curator for the subgraph deployment */ - function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256) - { + function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) public view override returns (uint256) { IGraphCurationToken gcs = pools[_subgraphDeploymentID].gcs; return (address(gcs) == address(0)) ? 0 : gcs.balanceOf(_curator); } @@ -376,12 +344,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _subgraphDeploymentID Subgraph deployment curation poool * @return Amount of signal minted for the subgraph deployment */ - function getCurationPoolSignal(bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256) - { + function getCurationPoolSignal(bytes32 _subgraphDeploymentID) public view override returns (uint256) { IGraphCurationToken gcs = pools[_subgraphDeploymentID].gcs; return (address(gcs) == address(0)) ? 0 : gcs.totalSupply(); } @@ -394,18 +357,13 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @return Amount of signal that can be bought * @return Amount of GRT that would be subtracted as curation tax */ - function tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - public - view - override - returns (uint256, uint256) - { + function tokensToSignal( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) public view override returns (uint256, uint256) { // Calculate tokens after tax first, subtract that from the tokens in // to get the curation tax to avoid rounding down to zero. - uint256 tokensAfterCurationTax = uint256(MAX_PPM) - .sub(curationTaxPercentage) - .mul(_tokensIn) - .div(MAX_PPM); + uint256 tokensAfterCurationTax = uint256(MAX_PPM).sub(curationTaxPercentage).mul(_tokensIn).div(MAX_PPM); uint256 curationTax = _tokensIn.sub(tokensAfterCurationTax); uint256 signalOut = _tokensToSignal(_subgraphDeploymentID, tokensAfterCurationTax); return (signalOut, curationTax); @@ -418,12 +376,10 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of signal that can be bought */ - function tokensToSignalNoTax(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - public - view - override - returns (uint256) - { + function tokensToSignalNoTax( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) public view override returns (uint256) { return _tokensToSignal(_subgraphDeploymentID, _tokensIn); } @@ -435,12 +391,10 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of tokens that would be recovered after minting and burning signal */ - function tokensToSignalToTokensNoTax(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - view - override - returns (uint256) - { + function tokensToSignalToTokensNoTax( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) external view override returns (uint256) { require(_tokensIn != 0, "Can't calculate with 0 tokens"); uint256 signal = _tokensToSignal(_subgraphDeploymentID, _tokensIn); CurationPool memory curationPool = pools[_subgraphDeploymentID]; @@ -455,22 +409,11 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _signalIn Amount of signal to burn * @return Amount of tokens to get for an amount of signal */ - function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) - public - view - override - returns (uint256) - { + function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) public view override returns (uint256) { CurationPool memory curationPool = pools[_subgraphDeploymentID]; uint256 curationPoolSignal = getCurationPoolSignal(_subgraphDeploymentID); - require( - curationPool.tokens != 0, - "Subgraph deployment must be curated to perform calculations" - ); - require( - curationPoolSignal >= _signalIn, - "Signal must be above or equal to signal issued in the curation pool" - ); + require(curationPool.tokens != 0, "Subgraph deployment must be curated to perform calculations"); + require(curationPoolSignal >= _signalIn, "Signal must be above or equal to signal issued in the curation pool"); return curationPool.tokens.mul(_signalIn).div(curationPoolSignal); } @@ -492,10 +435,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _percentage Curation tax percentage charged when depositing GRT tokens */ function _setCurationTaxPercentage(uint32 _percentage) private { - require( - _percentage <= MAX_PPM, - "Curation tax percentage must be below or equal to MAX_PPM" - ); + require(_percentage <= MAX_PPM, "Curation tax percentage must be below or equal to MAX_PPM"); curationTaxPercentage = _percentage; emit ParameterUpdated("curationTaxPercentage"); @@ -507,10 +447,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { */ function _setCurationTokenMaster(address _curationTokenMaster) private { require(_curationTokenMaster != address(0), "Token master must be non-empty"); - require( - AddressUpgradeable.isContract(_curationTokenMaster), - "Token master must be a contract" - ); + require(AddressUpgradeable.isContract(_curationTokenMaster), "Token master must be a contract"); curationTokenMaster = _curationTokenMaster; emit ParameterUpdated("curationTokenMaster"); @@ -533,25 +470,16 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of signal that can be bought with tokens */ - function _tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - private - view - returns (uint256) - { + function _tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) private view returns (uint256) { // Get curation pool tokens and signal CurationPool memory curationPool = pools[_subgraphDeploymentID]; // Init curation pool if (curationPool.tokens == 0) { - require( - _tokensIn >= minimumCurationDeposit, - "Curation deposit is below minimum required" - ); + require(_tokensIn >= minimumCurationDeposit, "Curation deposit is below minimum required"); return SIGNAL_PER_MINIMUM_DEPOSIT.add( - SIGNAL_PER_MINIMUM_DEPOSIT.mul(_tokensIn.sub(minimumCurationDeposit)).div( - minimumCurationDeposit - ) + SIGNAL_PER_MINIMUM_DEPOSIT.mul(_tokensIn.sub(minimumCurationDeposit)).div(minimumCurationDeposit) ); } diff --git a/packages/contracts/contracts/l2/discovery/L2GNS.sol b/packages/contracts/contracts/l2/discovery/L2GNS.sol index f2c4c9a83..34d47d400 100644 --- a/packages/contracts/contracts/l2/discovery/L2GNS.sol +++ b/packages/contracts/contracts/l2/discovery/L2GNS.sol @@ -91,10 +91,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { bytes calldata _data ) external override notPartialPaused onlyL2Gateway { require(_from == counterpartGNSAddress, "ONLY_L1_GNS_THROUGH_BRIDGE"); - (uint8 code, uint256 l1SubgraphID, address beneficiary) = abi.decode( - _data, - (uint8, uint256, address) - ); + (uint8 code, uint256 l1SubgraphID, address beneficiary) = abi.decode(_data, (uint8, uint256, address)); if (code == uint8(L1MessageCodes.RECEIVE_SUBGRAPH_CODE)) { _receiveSubgraphFromL1(l1SubgraphID, beneficiary, _amount); @@ -138,10 +135,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { { // This can't revert because the bridge ensures that _tokensIn is > 0, // and the minimum curation in L2 is 1 wei GRT - uint256 tokensAfter = curation.tokensToSignalToTokensNoTax( - _subgraphDeploymentID, - tokens - ); + uint256 tokensAfter = curation.tokensToSignalToTokensNoTax(_subgraphDeploymentID, tokens); roundingError = tokens.sub(tokensAfter).mul(MAX_PPM).div(tokens); } if (roundingError <= MAX_ROUNDING_ERROR) { @@ -151,11 +145,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { emit SubgraphUpgraded(_l2SubgraphID, vSignal, tokens, _subgraphDeploymentID); } else { graphToken().transfer(msg.sender, tokens); - emit CuratorBalanceReturnedToBeneficiary( - getUnaliasedL1SubgraphID(_l2SubgraphID), - msg.sender, - tokens - ); + emit CuratorBalanceReturnedToBeneficiary(getUnaliasedL1SubgraphID(_l2SubgraphID), msg.sender, tokens); emit SubgraphUpgraded(_l2SubgraphID, vSignal, 0, _subgraphDeploymentID); } @@ -209,31 +199,18 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { if (subgraphData.nSignal != 0) { // Burn all version signal in the name pool for tokens (w/no slippage protection) // Sell all signal from the old deployment - uint256 tokens = curation.burn( - subgraphData.subgraphDeploymentID, - subgraphData.vSignal, - 0 - ); + uint256 tokens = curation.burn(subgraphData.subgraphDeploymentID, subgraphData.vSignal, 0); // Take the owner cut of the curation tax, add it to the total // Upgrade is only callable by the owner, we assume then that msg.sender = owner address subgraphOwner = msg.sender; - uint256 tokensWithTax = _chargeOwnerTax( - tokens, - subgraphOwner, - curation.curationTaxPercentage() - ); + uint256 tokensWithTax = _chargeOwnerTax(tokens, subgraphOwner, curation.curationTaxPercentage()); // Update pool: constant nSignal, vSignal can change (w/no slippage protection) // Buy all signal from the new deployment (subgraphData.vSignal, ) = curation.mint(_subgraphDeploymentID, tokensWithTax, 0); - emit SubgraphUpgraded( - _subgraphID, - subgraphData.vSignal, - tokensWithTax, - _subgraphDeploymentID - ); + emit SubgraphUpgraded(_subgraphID, subgraphData.vSignal, tokensWithTax, _subgraphDeploymentID); } // Update target deployment @@ -256,12 +233,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { * @param _l2SubgraphID L2 subgraph ID * @return L1subgraph ID */ - function getUnaliasedL1SubgraphID(uint256 _l2SubgraphID) - public - pure - override - returns (uint256) - { + function getUnaliasedL1SubgraphID(uint256 _l2SubgraphID) public pure override returns (uint256) { return _l2SubgraphID - SUBGRAPH_ID_ALIAS_OFFSET; } @@ -273,11 +245,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { * @param _subgraphOwner Owner of the subgraph * @param _tokens Tokens to be deposited in the subgraph */ - function _receiveSubgraphFromL1( - uint256 _l1SubgraphID, - address _subgraphOwner, - uint256 _tokens - ) internal { + function _receiveSubgraphFromL1(uint256 _l1SubgraphID, address _subgraphOwner, uint256 _tokens) internal { uint256 l2SubgraphID = getAliasedL2SubgraphID(_l1SubgraphID); SubgraphData storage subgraphData = _getSubgraphData(l2SubgraphID); IL2GNS.SubgraphL2TransferData storage transferData = subgraphL2TransferData[l2SubgraphID]; @@ -307,11 +275,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { * @param _curator Curator address * @param _tokensIn The amount of tokens the nameCurator wants to deposit */ - function _mintSignalFromL1( - uint256 _l1SubgraphID, - address _curator, - uint256 _tokensIn - ) internal { + function _mintSignalFromL1(uint256 _l1SubgraphID, address _curator, uint256 _tokensIn) internal { uint256 l2SubgraphID = getAliasedL2SubgraphID(_l1SubgraphID); IL2GNS.SubgraphL2TransferData storage transferData = subgraphL2TransferData[l2SubgraphID]; SubgraphData storage subgraphData = _getSubgraphData(l2SubgraphID); @@ -321,10 +285,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { if (transferData.l2Done && !subgraphData.disabled) { // This can't revert because the bridge ensures that _tokensIn is > 0, // and the minimum curation in L2 is 1 wei GRT - uint256 tokensAfter = curation.tokensToSignalToTokensNoTax( - subgraphData.subgraphDeploymentID, - _tokensIn - ); + uint256 tokensAfter = curation.tokensToSignalToTokensNoTax(subgraphData.subgraphDeploymentID, _tokensIn); roundingError = _tokensIn.sub(tokensAfter).mul(MAX_PPM).div(_tokensIn); } // If subgraph transfer wasn't finished, we should send the tokens to the curator @@ -339,9 +300,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { // Update pools subgraphData.vSignal = subgraphData.vSignal.add(vSignal); subgraphData.nSignal = subgraphData.nSignal.add(nSignal); - subgraphData.curatorNSignal[_curator] = subgraphData.curatorNSignal[_curator].add( - nSignal - ); + subgraphData.curatorNSignal[_curator] = subgraphData.curatorNSignal[_curator].add(nSignal); emit SignalMinted(l2SubgraphID, _curator, nSignal, vSignal, _tokensIn); emit CuratorBalanceReceived(_l1SubgraphID, l2SubgraphID, _curator, _tokensIn); @@ -355,12 +314,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { * @param _subgraphID Subgraph ID * @return Subgraph Data */ - function _getSubgraphData(uint256 _subgraphID) - internal - view - override - returns (SubgraphData storage) - { + function _getSubgraphData(uint256 _subgraphID) internal view override returns (SubgraphData storage) { // Return new subgraph type return subgraphs[_subgraphID]; } diff --git a/packages/contracts/contracts/l2/gateway/L2GraphTokenGateway.sol b/packages/contracts/contracts/l2/gateway/L2GraphTokenGateway.sol index 03417a59a..be8f212b8 100644 --- a/packages/contracts/contracts/l2/gateway/L2GraphTokenGateway.sol +++ b/packages/contracts/contracts/l2/gateway/L2GraphTokenGateway.sol @@ -39,12 +39,7 @@ contract L2GraphTokenGateway is GraphTokenGateway, L2ArbitrumMessenger, Reentran } /// Emitted when an incoming transfer is finalized, i.e. tokens were deposited from L1 to L2 - event DepositFinalized( - address indexed l1Token, - address indexed from, - address indexed to, - uint256 amount - ); + event DepositFinalized(address indexed l1Token, address indexed from, address indexed to, uint256 amount); /// Emitted when an outbound transfer is initiated, i.e. tokens are being withdrawn from L2 back to L1 event WithdrawalInitiated( @@ -68,10 +63,7 @@ contract L2GraphTokenGateway is GraphTokenGateway, L2ArbitrumMessenger, Reentran * gateway on L1. */ modifier onlyL1Counterpart() { - require( - msg.sender == AddressAliasHelper.applyL1ToL2Alias(l1Counterpart), - "ONLY_COUNTERPART_GATEWAY" - ); + require(msg.sender == AddressAliasHelper.applyL1ToL2Alias(l1Counterpart), "ONLY_COUNTERPART_GATEWAY"); _; } @@ -216,13 +208,7 @@ contract L2GraphTokenGateway is GraphTokenGateway, L2ArbitrumMessenger, Reentran 0, outboundCalldata.from, l1Counterpart, - getOutboundCalldata( - _l1Token, - outboundCalldata.from, - _to, - _amount, - outboundCalldata.extraData - ) + getOutboundCalldata(_l1Token, outboundCalldata.from, _to, _amount, outboundCalldata.extraData) ); // we don't need to track exitNums (b/c we have no fast exits) so we always use 0 diff --git a/packages/contracts/contracts/l2/staking/IL2StakingBase.sol b/packages/contracts/contracts/l2/staking/IL2StakingBase.sol index 8b8cd92ab..6f701ec89 100644 --- a/packages/contracts/contracts/l2/staking/IL2StakingBase.sol +++ b/packages/contracts/contracts/l2/staking/IL2StakingBase.sol @@ -10,9 +10,5 @@ import { ICallhookReceiver } from "../../gateway/ICallhookReceiver.sol"; * @dev Note it includes only the L2-specific functionality, not the full IStaking interface. */ interface IL2StakingBase is ICallhookReceiver { - event TransferredDelegationReturnedToDelegator( - address indexed indexer, - address indexed delegator, - uint256 amount - ); + event TransferredDelegationReturnedToDelegator(address indexed indexer, address indexed delegator, uint256 amount); } diff --git a/packages/contracts/contracts/l2/staking/L2Staking.sol b/packages/contracts/contracts/l2/staking/L2Staking.sol index 7e561b990..3f9d28e5a 100644 --- a/packages/contracts/contracts/l2/staking/L2Staking.sol +++ b/packages/contracts/contracts/l2/staking/L2Staking.sol @@ -28,12 +28,7 @@ contract L2Staking is Staking, IL2StakingBase { * This is copied from IStakingExtension, but we can't inherit from it because we * don't implement the full interface here. */ - event StakeDelegated( - address indexed indexer, - address indexed delegator, - uint256 tokens, - uint256 shares - ); + event StakeDelegated(address indexed indexer, address indexed delegator, uint256 tokens, uint256 shares); /** * @dev Checks that the sender is the L2GraphTokenGateway as configured on the Controller. @@ -92,10 +87,7 @@ contract L2Staking is Staking, IL2StakingBase { * @param _amount Amount of tokens that were transferred * @param _indexerData struct containing the indexer's address */ - function _receiveIndexerStake( - uint256 _amount, - IL2Staking.ReceiveIndexerStakeData memory _indexerData - ) internal { + function _receiveIndexerStake(uint256 _amount, IL2Staking.ReceiveIndexerStakeData memory _indexerData) internal { address _indexer = _indexerData.indexer; // Deposit tokens into the indexer stake __stakes[_indexer].deposit(_amount); @@ -116,10 +108,7 @@ contract L2Staking is Staking, IL2StakingBase { * @param _amount Amount of tokens that were transferred * @param _delegationData struct containing the delegator's address and the indexer's address */ - function _receiveDelegation( - uint256 _amount, - IL2Staking.ReceiveDelegationData memory _delegationData - ) internal { + function _receiveDelegation(uint256 _amount, IL2Staking.ReceiveDelegationData memory _delegationData) internal { // Get the delegation pool of the indexer DelegationPool storage pool = __delegationPools[_delegationData.indexer]; Delegation storage delegation = pool.delegators[_delegationData.delegator]; @@ -132,11 +121,7 @@ contract L2Staking is Staking, IL2StakingBase { // or if the amount is under the minimum delegation (which could be part of a rounding attack), // return the tokens to the delegator graphToken().transfer(_delegationData.delegator, _amount); - emit TransferredDelegationReturnedToDelegator( - _delegationData.indexer, - _delegationData.delegator, - _amount - ); + emit TransferredDelegationReturnedToDelegator(_delegationData.indexer, _delegationData.delegator, _amount); } else { // Update the delegation pool pool.tokens = pool.tokens.add(_amount); @@ -145,12 +130,7 @@ contract L2Staking is Staking, IL2StakingBase { // Update the individual delegation delegation.shares = delegation.shares.add(shares); - emit StakeDelegated( - _delegationData.indexer, - _delegationData.delegator, - _amount, - shares - ); + emit StakeDelegated(_delegationData.indexer, _delegationData.delegator, _amount, shares); } } } diff --git a/packages/contracts/contracts/l2/token/GraphTokenUpgradeable.sol b/packages/contracts/contracts/l2/token/GraphTokenUpgradeable.sol index 3f7882b5c..0f5cf0ecb 100644 --- a/packages/contracts/contracts/l2/token/GraphTokenUpgradeable.sol +++ b/packages/contracts/contracts/l2/token/GraphTokenUpgradeable.sol @@ -30,21 +30,16 @@ abstract contract GraphTokenUpgradeable is GraphUpgradeable, Governed, ERC20Burn /// @dev Hash of the EIP-712 Domain type bytes32 private immutable DOMAIN_TYPE_HASH = - keccak256( - "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)" - ); + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)"); /// @dev Hash of the EIP-712 Domain name bytes32 private immutable DOMAIN_NAME_HASH = keccak256("Graph Token"); /// @dev Hash of the EIP-712 Domain version bytes32 private immutable DOMAIN_VERSION_HASH = keccak256("0"); /// @dev EIP-712 Domain salt - bytes32 private immutable DOMAIN_SALT = - 0xe33842a7acd1d5a1d28f25a931703e5605152dc48d64dc4716efdae1f5659591; // Randomly generated salt + bytes32 private immutable DOMAIN_SALT = 0xe33842a7acd1d5a1d28f25a931703e5605152dc48d64dc4716efdae1f5659591; // Randomly generated salt /// @dev Hash of the EIP-712 permit type bytes32 private immutable PERMIT_TYPEHASH = - keccak256( - "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" - ); + keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); // -- State -- @@ -94,9 +89,7 @@ abstract contract GraphTokenUpgradeable is GraphUpgradeable, Governed, ERC20Burn abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, - keccak256( - abi.encode(PERMIT_TYPEHASH, _owner, _spender, _value, nonces[_owner], _deadline) - ) + keccak256(abi.encode(PERMIT_TYPEHASH, _owner, _spender, _value, nonces[_owner], _deadline)) ) ); diff --git a/packages/contracts/contracts/payments/AllocationExchange.sol b/packages/contracts/contracts/payments/AllocationExchange.sol index 6a45d03ad..3a05112fe 100644 --- a/packages/contracts/contracts/payments/AllocationExchange.sol +++ b/packages/contracts/contracts/payments/AllocationExchange.sol @@ -31,7 +31,7 @@ contract AllocationExchange is Governed { // -- Constants -- - uint256 private constant MAX_UINT256 = 2**256 - 1; + uint256 private constant MAX_UINT256 = 2 ** 256 - 1; uint256 private constant SIGNATURE_LENGTH = 65; // -- State -- @@ -56,12 +56,7 @@ contract AllocationExchange is Governed { * @param _governor Account capable of withdrawing funds and setting the authority * @param _authority Account that can sign the vouchers that this contract will redeem */ - constructor( - IGraphToken _graphToken, - IStaking _staking, - address _governor, - address _authority - ) { + constructor(IGraphToken _graphToken, IStaking _staking, address _governor, address _authority) { require(_governor != address(0), "Exchange: governor must be set"); Governed._initialize(_governor); @@ -148,10 +143,7 @@ contract AllocationExchange is Governed { require(_voucher.signature.length == SIGNATURE_LENGTH, "Exchange: invalid signature"); // Already redeemed check - require( - !allocationsRedeemed[_voucher.allocationID], - "Exchange: allocation already redeemed" - ); + require(!allocationsRedeemed[_voucher.allocationID], "Exchange: allocation already redeemed"); // Signature check bytes32 messageHash = keccak256(abi.encodePacked(_voucher.allocationID, _voucher.amount)); diff --git a/packages/contracts/contracts/rewards/IRewardsManager.sol b/packages/contracts/contracts/rewards/IRewardsManager.sol index 87d3c2455..4c062e774 100644 --- a/packages/contracts/contracts/rewards/IRewardsManager.sol +++ b/packages/contracts/contracts/rewards/IRewardsManager.sol @@ -25,8 +25,7 @@ interface IRewardsManager { function setDenied(bytes32 _subgraphDeploymentID, bool _deny) external; - function setDeniedMany(bytes32[] calldata _subgraphDeploymentID, bool[] calldata _deny) - external; + function setDeniedMany(bytes32[] calldata _subgraphDeploymentID, bool[] calldata _deny) external; function isDenied(bytes32 _subgraphDeploymentID) external view returns (bool); @@ -36,15 +35,9 @@ interface IRewardsManager { function getAccRewardsPerSignal() external view returns (uint256); - function getAccRewardsForSubgraph(bytes32 _subgraphDeploymentID) - external - view - returns (uint256); + function getAccRewardsForSubgraph(bytes32 _subgraphDeploymentID) external view returns (uint256); - function getAccRewardsPerAllocatedToken(bytes32 _subgraphDeploymentID) - external - view - returns (uint256, uint256); + function getAccRewardsPerAllocatedToken(bytes32 _subgraphDeploymentID) external view returns (uint256, uint256); function getRewards(address _allocationID) external view returns (uint256); diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index f7b7f6384..03cadacb0 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -38,12 +38,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa /** * @dev Emitted when rewards are assigned to an indexer. */ - event RewardsAssigned( - address indexed indexer, - address indexed allocationID, - uint256 epoch, - uint256 amount - ); + event RewardsAssigned(address indexed indexer, address indexed allocationID, uint256 epoch, uint256 amount); /** * @dev Emitted when rewards are denied to an indexer. @@ -58,10 +53,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa // -- Modifiers -- modifier onlySubgraphAvailabilityOracle() { - require( - msg.sender == address(subgraphAvailabilityOracle), - "Caller must be the subgraph availability oracle" - ); + require(msg.sender == address(subgraphAvailabilityOracle), "Caller must be the subgraph availability oracle"); _; } @@ -103,11 +95,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @dev Sets the subgraph oracle allowed to denegate distribution of rewards to subgraphs. * @param _subgraphAvailabilityOracle Address of the subgraph availability oracle */ - function setSubgraphAvailabilityOracle(address _subgraphAvailabilityOracle) - external - override - onlyGovernor - { + function setSubgraphAvailabilityOracle(address _subgraphAvailabilityOracle) external override onlyGovernor { subgraphAvailabilityOracle = _subgraphAvailabilityOracle; emit ParameterUpdated("subgraphAvailabilityOracle"); } @@ -120,8 +108,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa function setMinimumSubgraphSignal(uint256 _minimumSubgraphSignal) external override { // Caller can be the SAO or the governor require( - msg.sender == address(subgraphAvailabilityOracle) || - msg.sender == controller.getGovernor(), + msg.sender == address(subgraphAvailabilityOracle) || msg.sender == controller.getGovernor(), "Not authorized" ); minimumSubgraphSignal = _minimumSubgraphSignal; @@ -136,11 +123,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @param _subgraphDeploymentID Subgraph deployment ID * @param _deny Whether to set the subgraph as denied for claiming rewards or not */ - function setDenied(bytes32 _subgraphDeploymentID, bool _deny) - external - override - onlySubgraphAvailabilityOracle - { + function setDenied(bytes32 _subgraphDeploymentID, bool _deny) external override onlySubgraphAvailabilityOracle { _setDenied(_subgraphDeploymentID, _deny); } @@ -150,11 +133,10 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @param _subgraphDeploymentID Array of subgraph deployment ID * @param _deny Array of denied status for claiming rewards for each subgraph */ - function setDeniedMany(bytes32[] calldata _subgraphDeploymentID, bool[] calldata _deny) - external - override - onlySubgraphAvailabilityOracle - { + function setDeniedMany( + bytes32[] calldata _subgraphDeploymentID, + bool[] calldata _deny + ) external override onlySubgraphAvailabilityOracle { require(_subgraphDeploymentID.length == _deny.length, "!length"); for (uint256 i = 0; i < _subgraphDeploymentID.length; i++) { _setDenied(_subgraphDeploymentID[i], _deny[i]); @@ -233,12 +215,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @param _subgraphDeploymentID Subgraph deployment * @return Accumulated rewards for subgraph */ - function getAccRewardsForSubgraph(bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256) - { + function getAccRewardsForSubgraph(bytes32 _subgraphDeploymentID) public view override returns (uint256) { Subgraph storage subgraph = subgraphs[_subgraphDeploymentID]; // Get tokens signalled on the subgraph @@ -246,10 +223,9 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa // Only accrue rewards if over a threshold uint256 newRewards = (subgraphSignalledTokens >= minimumSubgraphSignal) // Accrue new rewards since last snapshot - ? getAccRewardsPerSignal() - .sub(subgraph.accRewardsPerSignalSnapshot) - .mul(subgraphSignalledTokens) - .div(FIXED_POINT_SCALING_FACTOR) + ? getAccRewardsPerSignal().sub(subgraph.accRewardsPerSignalSnapshot).mul(subgraphSignalledTokens).div( + FIXED_POINT_SCALING_FACTOR + ) : 0; return subgraph.accRewardsForSubgraph.add(newRewards); } @@ -260,12 +236,9 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @return Accumulated rewards per allocated token for the subgraph * @return Accumulated rewards for subgraph */ - function getAccRewardsPerAllocatedToken(bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256, uint256) - { + function getAccRewardsPerAllocatedToken( + bytes32 _subgraphDeploymentID + ) public view override returns (uint256, uint256) { Subgraph storage subgraph = subgraphs[_subgraphDeploymentID]; uint256 accRewardsForSubgraph = getAccRewardsForSubgraph(_subgraphDeploymentID); @@ -274,20 +247,15 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa subgraph.accRewardsForSubgraphSnapshot ); - uint256 subgraphAllocatedTokens = staking().getSubgraphAllocatedTokens( - _subgraphDeploymentID - ); + uint256 subgraphAllocatedTokens = staking().getSubgraphAllocatedTokens(_subgraphDeploymentID); if (subgraphAllocatedTokens == 0) { return (0, accRewardsForSubgraph); } - uint256 newRewardsPerAllocatedToken = newRewardsForSubgraph - .mul(FIXED_POINT_SCALING_FACTOR) - .div(subgraphAllocatedTokens); - return ( - subgraph.accRewardsPerAllocatedToken.add(newRewardsPerAllocatedToken), - accRewardsForSubgraph + uint256 newRewardsPerAllocatedToken = newRewardsForSubgraph.mul(FIXED_POINT_SCALING_FACTOR).div( + subgraphAllocatedTokens ); + return (subgraph.accRewardsPerAllocatedToken.add(newRewardsPerAllocatedToken), accRewardsForSubgraph); } // -- Updates -- @@ -311,11 +279,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @param _subgraphDeploymentID Subgraph deployment * @return Accumulated rewards for subgraph */ - function onSubgraphSignalUpdate(bytes32 _subgraphDeploymentID) - external - override - returns (uint256) - { + function onSubgraphSignalUpdate(bytes32 _subgraphDeploymentID) external override returns (uint256) { // Called since `total signalled GRT` will change updateAccRewardsPerSignal(); @@ -334,16 +298,11 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @param _subgraphDeploymentID Subgraph deployment * @return Accumulated rewards per allocated token for a subgraph */ - function onSubgraphAllocationUpdate(bytes32 _subgraphDeploymentID) - public - override - returns (uint256) - { + function onSubgraphAllocationUpdate(bytes32 _subgraphDeploymentID) public override returns (uint256) { Subgraph storage subgraph = subgraphs[_subgraphDeploymentID]; - ( - uint256 accRewardsPerAllocatedToken, - uint256 accRewardsForSubgraph - ) = getAccRewardsPerAllocatedToken(_subgraphDeploymentID); + (uint256 accRewardsPerAllocatedToken, uint256 accRewardsForSubgraph) = getAccRewardsPerAllocatedToken( + _subgraphDeploymentID + ); subgraph.accRewardsPerAllocatedToken = accRewardsPerAllocatedToken; subgraph.accRewardsForSubgraphSnapshot = accRewardsForSubgraph; return subgraph.accRewardsPerAllocatedToken; @@ -362,15 +321,8 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa IStaking.Allocation memory alloc = staking().getAllocation(_allocationID); - (uint256 accRewardsPerAllocatedToken, ) = getAccRewardsPerAllocatedToken( - alloc.subgraphDeploymentID - ); - return - _calcRewards( - alloc.tokens, - alloc.accRewardsPerAllocatedToken, - accRewardsPerAllocatedToken - ); + (uint256 accRewardsPerAllocatedToken, ) = getAccRewardsPerAllocatedToken(alloc.subgraphDeploymentID); + return _calcRewards(alloc.tokens, alloc.accRewardsPerAllocatedToken, accRewardsPerAllocatedToken); } /** @@ -402,9 +354,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa require(msg.sender == address(staking), "Caller must be the staking contract"); IStaking.Allocation memory alloc = staking.getAllocation(_allocationID); - uint256 accRewardsPerAllocatedToken = onSubgraphAllocationUpdate( - alloc.subgraphDeploymentID - ); + uint256 accRewardsPerAllocatedToken = onSubgraphAllocationUpdate(alloc.subgraphDeploymentID); // Do not do rewards on denied subgraph deployments ID if (isDenied(alloc.subgraphDeploymentID)) { @@ -413,11 +363,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa } // Calculate rewards accrued by this allocation - uint256 rewards = _calcRewards( - alloc.tokens, - alloc.accRewardsPerAllocatedToken, - accRewardsPerAllocatedToken - ); + uint256 rewards = _calcRewards(alloc.tokens, alloc.accRewardsPerAllocatedToken, accRewardsPerAllocatedToken); if (rewards > 0) { // Mint directly to staking contract for the reward amount // The staking contract will do bookkeeping of the reward and diff --git a/packages/contracts/contracts/staking/IL1StakingBase.sol b/packages/contracts/contracts/staking/IL1StakingBase.sol index 58749a247..fad2136c2 100644 --- a/packages/contracts/contracts/staking/IL1StakingBase.sol +++ b/packages/contracts/contracts/staking/IL1StakingBase.sol @@ -39,9 +39,7 @@ interface IL1StakingBase { * @dev This function can only be called by the governor. * @param _l1GraphTokenLockTransferTool Address of the L1GraphTokenLockTransferTool contract */ - function setL1GraphTokenLockTransferTool( - IL1GraphTokenLockTransferTool _l1GraphTokenLockTransferTool - ) external; + function setL1GraphTokenLockTransferTool(IL1GraphTokenLockTransferTool _l1GraphTokenLockTransferTool) external; /** * @notice Send an indexer's stake to L2. diff --git a/packages/contracts/contracts/staking/IStakingBase.sol b/packages/contracts/contracts/staking/IStakingBase.sol index 5f1dec63c..b30d00499 100644 --- a/packages/contracts/contracts/staking/IStakingBase.sol +++ b/packages/contracts/contracts/staking/IStakingBase.sol @@ -380,8 +380,5 @@ interface IStakingBase is IStakingData { * @param _subgraphDeploymentID Deployment ID for the subgraph * @return Total tokens allocated to subgraph */ - function getSubgraphAllocatedTokens(bytes32 _subgraphDeploymentID) - external - view - returns (uint256); + function getSubgraphAllocatedTokens(bytes32 _subgraphDeploymentID) external view returns (uint256); } diff --git a/packages/contracts/contracts/staking/IStakingExtension.sol b/packages/contracts/contracts/staking/IStakingExtension.sol index 36e6dce92..6a60dc9eb 100644 --- a/packages/contracts/contracts/staking/IStakingExtension.sol +++ b/packages/contracts/contracts/staking/IStakingExtension.sol @@ -32,12 +32,7 @@ interface IStakingExtension is IStakingData { * @dev Emitted when `delegator` delegated `tokens` to the `indexer`, the delegator * gets `shares` for the delegation pool proportionally to the tokens staked. */ - event StakeDelegated( - address indexed indexer, - address indexed delegator, - uint256 tokens, - uint256 shares - ); + event StakeDelegated(address indexed indexer, address indexed delegator, uint256 tokens, uint256 shares); /** * @dev Emitted when `delegator` undelegated `tokens` from `indexer`. @@ -54,22 +49,13 @@ interface IStakingExtension is IStakingData { /** * @dev Emitted when `delegator` withdrew delegated `tokens` from `indexer`. */ - event StakeDelegatedWithdrawn( - address indexed indexer, - address indexed delegator, - uint256 tokens - ); + event StakeDelegatedWithdrawn(address indexed indexer, address indexed delegator, uint256 tokens); /** * @dev Emitted when `indexer` was slashed for a total of `tokens` amount. * Tracks `reward` amount of tokens given to `beneficiary`. */ - event StakeSlashed( - address indexed indexer, - uint256 tokens, - uint256 reward, - address beneficiary - ); + event StakeSlashed(address indexed indexer, uint256 tokens, uint256 reward, address beneficiary); /** * @dev Emitted when `caller` set `slasher` address as `allowed` to slash stakes. @@ -139,12 +125,7 @@ interface IStakingExtension is IStakingData { * @param _reward Amount of reward tokens to send to a beneficiary * @param _beneficiary Address of a beneficiary to receive a reward for the slashing */ - function slash( - address _indexer, - uint256 _tokens, - uint256 _reward, - address _beneficiary - ) external; + function slash(address _indexer, uint256 _tokens, uint256 _reward, address _beneficiary) external; /** * @notice Return the delegation from a delegator to an indexer. @@ -152,10 +133,7 @@ interface IStakingExtension is IStakingData { * @param _delegator Address of the delegator * @return Delegation data */ - function getDelegation(address _indexer, address _delegator) - external - view - returns (Delegation memory); + function getDelegation(address _indexer, address _delegator) external view returns (Delegation memory); /** * @notice Return whether the delegator has delegated to the indexer. @@ -170,10 +148,7 @@ interface IStakingExtension is IStakingData { * @param _delegation Delegation of tokens from delegator to indexer * @return Amount of tokens to withdraw */ - function getWithdraweableDelegatedTokens(Delegation memory _delegation) - external - view - returns (uint256); + function getWithdraweableDelegatedTokens(Delegation memory _delegation) external view returns (uint256); /** * @notice Getter for the delegationRatio, i.e. the delegation capacity multiplier: @@ -313,8 +288,5 @@ interface IStakingExtension is IStakingData { * @param _allocationID Allocation ID for which to query the allocation information * @return The specified allocation, as an IStakingData.Allocation struct */ - function allocations(address _allocationID) - external - view - returns (IStakingData.Allocation memory); + function allocations(address _allocationID) external view returns (IStakingData.Allocation memory); } diff --git a/packages/contracts/contracts/staking/L1Staking.sol b/packages/contracts/contracts/staking/L1Staking.sol index cf9bca304..df4e145bd 100644 --- a/packages/contracts/contracts/staking/L1Staking.sol +++ b/packages/contracts/contracts/staking/L1Staking.sol @@ -31,10 +31,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { * transfer of stake/delegation for vesting lock wallets. */ receive() external payable { - require( - msg.sender == address(l1GraphTokenLockTransferTool), - "Only transfer tool can send ETH" - ); + require(msg.sender == address(l1GraphTokenLockTransferTool), "Only transfer tool can send ETH"); } /** @@ -73,19 +70,8 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { uint256 _gasPriceBid, uint256 _maxSubmissionCost ) external payable override notPartialPaused { - require( - msg.value == _maxSubmissionCost.add(_gasPriceBid.mul(_maxGas)), - "INVALID_ETH_AMOUNT" - ); - _transferStakeToL2( - msg.sender, - _l2Beneficiary, - _amount, - _maxGas, - _gasPriceBid, - _maxSubmissionCost, - msg.value - ); + require(msg.value == _maxSubmissionCost.add(_gasPriceBid.mul(_maxGas)), "INVALID_ETH_AMOUNT"); + _transferStakeToL2(msg.sender, _l2Beneficiary, _amount, _maxGas, _gasPriceBid, _maxSubmissionCost, msg.value); } /** @@ -118,15 +104,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { uint256 ethAmount = _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)); l1GraphTokenLockTransferTool.pullETH(msg.sender, ethAmount); require(address(this).balance == balance.add(ethAmount), "ETH TRANSFER FAILED"); - _transferStakeToL2( - msg.sender, - l2Beneficiary, - _amount, - _maxGas, - _gasPriceBid, - _maxSubmissionCost, - ethAmount - ); + _transferStakeToL2(msg.sender, l2Beneficiary, _amount, _maxGas, _gasPriceBid, _maxSubmissionCost, ethAmount); } /** @@ -152,10 +130,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { uint256 _gasPriceBid, uint256 _maxSubmissionCost ) external payable override notPartialPaused { - require( - msg.value == _maxSubmissionCost.add(_gasPriceBid.mul(_maxGas)), - "INVALID_ETH_AMOUNT" - ); + require(msg.value == _maxSubmissionCost.add(_gasPriceBid.mul(_maxGas)), "INVALID_ETH_AMOUNT"); _transferDelegationToL2( msg.sender, _indexer, @@ -216,11 +191,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { * and can be withdrawn with `withdrawDelegated()` immediately after calling this. * @param _indexer Address of the indexer (in L1, before transferring to L2) */ - function unlockDelegationToTransferredIndexer(address _indexer) - external - override - notPartialPaused - { + function unlockDelegationToTransferredIndexer(address _indexer) external override notPartialPaused { require( indexerTransferredToL2[_indexer] != address(0) && __stakes[_indexer].tokensStaked == 0, "indexer not transferred" @@ -269,10 +240,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { require(_l2Beneficiary != address(0), "l2Beneficiary == 0"); if (indexerTransferredToL2[_indexer] != address(0)) { - require( - indexerTransferredToL2[_indexer] == _l2Beneficiary, - "l2Beneficiary != previous" - ); + require(indexerTransferredToL2[_indexer] == _l2Beneficiary, "l2Beneficiary != previous"); } else { indexerTransferredToL2[_indexer] = _l2Beneficiary; require(_amount >= __minimumIndexerStake, "!minimumIndexerStake sent"); @@ -292,10 +260,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { } else { // require that the indexer has enough stake to cover all allocations uint256 tokensDelegatedCap = indexerStake.tokensStaked.mul(uint256(__delegationRatio)); - uint256 tokensDelegatedCapacity = MathUtils.min( - delegationPool.tokens, - tokensDelegatedCap - ); + uint256 tokensDelegatedCapacity = MathUtils.min(delegationPool.tokens, tokensDelegatedCap); require( indexerStake.tokensUsed() <= indexerStake.tokensStaked.add(tokensDelegatedCapacity), "! allocation capacity" @@ -310,14 +275,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { abi.encode(functionData) ); - _sendTokensAndMessageToL2Staking( - _amount, - _maxGas, - _gasPriceBid, - _maxSubmissionCost, - _ethAmount, - extraData - ); + _sendTokensAndMessageToL2Staking(_amount, _maxGas, _gasPriceBid, _maxSubmissionCost, _ethAmount, extraData); emit IndexerStakeTransferredToL2(_indexer, _l2Beneficiary, _amount); } @@ -369,10 +327,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { IL2Staking.ReceiveDelegationData memory functionData; functionData.indexer = indexerTransferredToL2[_indexer]; functionData.delegator = _l2Beneficiary; - extraData = abi.encode( - uint8(IL2Staking.L1MessageCodes.RECEIVE_DELEGATION_CODE), - abi.encode(functionData) - ); + extraData = abi.encode(uint8(IL2Staking.L1MessageCodes.RECEIVE_DELEGATION_CODE), abi.encode(functionData)); } _sendTokensAndMessageToL2Staking( diff --git a/packages/contracts/contracts/staking/Staking.sol b/packages/contracts/contracts/staking/Staking.sol index b82c17bdf..e9da34440 100644 --- a/packages/contracts/contracts/staking/Staking.sol +++ b/packages/contracts/contracts/staking/Staking.sol @@ -212,12 +212,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M uint32 _lambdaNumerator, uint32 _lambdaDenominator ) external override onlyGovernor { - _setRebateParameters( - _alphaNumerator, - _alphaDenominator, - _lambdaNumerator, - _lambdaDenominator - ); + _setRebateParameters(_alphaNumerator, _alphaDenominator, _lambdaNumerator, _lambdaDenominator); } /** @@ -384,12 +379,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M // -- Collect curation fees -- // Only if the subgraph deployment is curated - curationFees = _collectCurationFees( - graphToken, - subgraphDeploymentID, - queryFees, - __curationPercentage - ); + curationFees = _collectCurationFees(graphToken, subgraphDeploymentID, queryFees, __curationPercentage); queryFees = queryFees.sub(curationFees); // -- Process rebate reward -- @@ -478,12 +468,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _allocationID Address used as allocation identifier * @return Allocation data */ - function getAllocation(address _allocationID) - external - view - override - returns (Allocation memory) - { + function getAllocation(address _allocationID) external view override returns (Allocation memory) { return __allocations[_allocationID]; } @@ -492,12 +477,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _allocationID Allocation identifier * @return AllocationState enum with the state of the allocation */ - function getAllocationState(address _allocationID) - external - view - override - returns (AllocationState) - { + function getAllocationState(address _allocationID) external view override returns (AllocationState) { return _getAllocationState(_allocationID); } @@ -506,12 +486,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _subgraphDeploymentID Deployment ID for the subgraph * @return Total tokens allocated to subgraph */ - function getSubgraphAllocatedTokens(bytes32 _subgraphDeploymentID) - external - view - override - returns (uint256) - { + function getSubgraphAllocatedTokens(bytes32 _subgraphDeploymentID) external view override returns (uint256) { return __subgraphAllocations[_subgraphDeploymentID]; } @@ -563,9 +538,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M Stakes.Indexer memory indexerStake = __stakes[_indexer]; uint256 tokensDelegated = __delegationPools[_indexer].tokens; - uint256 tokensDelegatedCap = indexerStake.tokensSecureStake().mul( - uint256(__delegationRatio) - ); + uint256 tokensDelegatedCap = indexerStake.tokensSecureStake().mul(uint256(__delegationRatio)); uint256 tokensDelegatedCapacity = MathUtils.min(tokensDelegated, tokensDelegatedCap); return indexerStake.tokensAvailableWithDelegation(tokensDelegatedCapacity); @@ -661,11 +634,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _indexingRewardCut Percentage of indexing rewards left for delegators * @param _queryFeeCut Percentage of query fees left for delegators */ - function _setDelegationParameters( - address _indexer, - uint32 _indexingRewardCut, - uint32 _queryFeeCut - ) internal { + function _setDelegationParameters(address _indexer, uint32 _indexingRewardCut, uint32 _queryFeeCut) internal { // Incentives must be within bounds require(_queryFeeCut <= MAX_PPM, ">queryFeeCut"); require(_indexingRewardCut <= MAX_PPM, ">indexingRewardCut"); @@ -690,10 +659,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M */ function _stake(address _indexer, uint256 _tokens) internal { // Ensure minimum stake - require( - __stakes[_indexer].tokensSecureStake().add(_tokens) >= __minimumIndexerStake, - "!minimumIndexerStake" - ); + require(__stakes[_indexer].tokensSecureStake().add(_tokens) >= __minimumIndexerStake, "!minimumIndexerStake"); // Deposit tokens into the indexer stake __stakes[_indexer].deposit(_tokens); @@ -750,10 +716,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M bytes32 digest = ECDSA.toEthSignedMessageHash(messageHash); require(ECDSA.recover(digest, _proof) == _allocationID, "!proof"); - require( - __stakes[_indexer].tokensSecureStake() >= __minimumIndexerStake, - "!minimumIndexerStake" - ); + require(__stakes[_indexer].tokensSecureStake() >= __minimumIndexerStake, "!minimumIndexerStake"); if (_tokens > 0) { // Needs to have free capacity not used for other purposes to allocate require(getIndexerCapacity(_indexer) >= _tokens, "!capacity"); @@ -784,9 +747,9 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M // Track total allocations per subgraph // Used for rewards calculations - __subgraphAllocations[alloc.subgraphDeploymentID] = __subgraphAllocations[ - alloc.subgraphDeploymentID - ].add(alloc.tokens); + __subgraphAllocations[alloc.subgraphDeploymentID] = __subgraphAllocations[alloc.subgraphDeploymentID].add( + alloc.tokens + ); } emit AllocationCreated( @@ -845,9 +808,9 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M // Track total allocations per subgraph // Used for rewards calculations - __subgraphAllocations[alloc.subgraphDeploymentID] = __subgraphAllocations[ - alloc.subgraphDeploymentID - ].sub(alloc.tokens); + __subgraphAllocations[alloc.subgraphDeploymentID] = __subgraphAllocations[alloc.subgraphDeploymentID].sub( + alloc.tokens + ); } emit AllocationClosed( @@ -869,10 +832,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _tokens Total tokens received used to calculate the amount of fees to collect * @return Amount of delegation rewards */ - function _collectDelegationQueryRewards(address _indexer, uint256 _tokens) - private - returns (uint256) - { + function _collectDelegationQueryRewards(address _indexer, uint256 _tokens) private returns (uint256) { uint256 delegationRewards = 0; DelegationPool storage pool = __delegationPools[_indexer]; if (pool.tokens > 0 && pool.queryFeeCut < MAX_PPM) { @@ -890,10 +850,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _tokens Total tokens received used to calculate the amount of fees to collect * @return Amount of delegation rewards */ - function _collectDelegationIndexingRewards(address _indexer, uint256 _tokens) - private - returns (uint256) - { + function _collectDelegationIndexingRewards(address _indexer, uint256 _tokens) private returns (uint256) { uint256 delegationRewards = 0; DelegationPool storage pool = __delegationPools[_indexer]; if (pool.tokens > 0 && pool.indexingRewardCut < MAX_PPM) { @@ -929,10 +886,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M if (isCurationEnabled && curation.isCurated(_subgraphDeploymentID)) { // Calculate the tokens after curation fees first, and subtact that, // to prevent curation fees from rounding down to zero - uint256 tokensAfterCurationFees = uint256(MAX_PPM) - .sub(_curationPercentage) - .mul(_tokens) - .div(MAX_PPM); + uint256 tokensAfterCurationFees = uint256(MAX_PPM).sub(_curationPercentage).mul(_tokens).div(MAX_PPM); uint256 curationFees = _tokens.sub(tokensAfterCurationFees); if (curationFees > 0) { // Transfer and call collect() @@ -954,11 +908,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _percentage Percentage of tokens to burn as tax * @return Amount of tax charged */ - function _collectTax( - IGraphToken _graphToken, - uint256 _tokens, - uint256 _percentage - ) private returns (uint256) { + function _collectTax(IGraphToken _graphToken, uint256 _tokens, uint256 _percentage) private returns (uint256) { // Calculate tokens after tax first, and subtract that, // to prevent the tax from rounding down to zero uint256 tokensAfterTax = uint256(MAX_PPM).sub(_percentage).mul(_tokens).div(MAX_PPM); @@ -1004,12 +954,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M uint256 indexerRewards = totalRewards.sub(delegationRewards); // Send the indexer rewards - _sendRewards( - graphToken(), - indexerRewards, - _indexer, - __rewardsDestination[_indexer] == address(0) - ); + _sendRewards(graphToken(), indexerRewards, _indexer, __rewardsDestination[_indexer] == address(0)); } /** @@ -1019,12 +964,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _beneficiary Address of the beneficiary of rewards * @param _restake Whether to restake or not */ - function _sendRewards( - IGraphToken _graphToken, - uint256 _amount, - address _beneficiary, - bool _restake - ) private { + function _sendRewards(IGraphToken _graphToken, uint256 _amount, address _beneficiary, bool _restake) private { if (_amount == 0) return; if (_restake) { @@ -1033,11 +973,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M } else { // Transfer funds to the beneficiary's designated rewards destination if set address destination = __rewardsDestination[_beneficiary]; - TokenUtils.pushTokens( - _graphToken, - destination == address(0) ? _beneficiary : destination, - _amount - ); + TokenUtils.pushTokens(_graphToken, destination == address(0) ? _beneficiary : destination, _amount); } } diff --git a/packages/contracts/contracts/staking/StakingExtension.sol b/packages/contracts/contracts/staking/StakingExtension.sol index 08839ca2a..ee38364b5 100644 --- a/packages/contracts/contracts/staking/StakingExtension.sol +++ b/packages/contracts/contracts/staking/StakingExtension.sol @@ -82,11 +82,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @dev This function is only callable by the governor * @param _delegationUnbondingPeriod Period in epochs to wait for token withdrawals after undelegating */ - function setDelegationUnbondingPeriod(uint32 _delegationUnbondingPeriod) - external - override - onlyGovernor - { + function setDelegationUnbondingPeriod(uint32 _delegationUnbondingPeriod) external override onlyGovernor { _setDelegationUnbondingPeriod(_delegationUnbondingPeriod); } @@ -107,12 +103,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _tokens Amount of tokens to delegate * @return Amount of shares issued from the delegation pool */ - function delegate(address _indexer, uint256 _tokens) - external - override - notPartialPaused - returns (uint256) - { + function delegate(address _indexer, uint256 _tokens) external override notPartialPaused returns (uint256) { address delegator = msg.sender; // Transfer tokens to delegate to this contract @@ -128,12 +119,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _shares Amount of shares to return and undelegate tokens * @return Amount of tokens returned for the shares of the delegation pool */ - function undelegate(address _indexer, uint256 _shares) - external - override - notPartialPaused - returns (uint256) - { + function undelegate(address _indexer, uint256 _shares) external override notPartialPaused returns (uint256) { return _undelegate(msg.sender, _indexer, _shares); } @@ -143,12 +129,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _indexer Withdraw available tokens delegated to indexer * @param _newIndexer Re-delegate to indexer address if non-zero, withdraw if zero address */ - function withdrawDelegated(address _indexer, address _newIndexer) - external - override - notPaused - returns (uint256) - { + function withdrawDelegated(address _indexer, address _newIndexer) external override notPaused returns (uint256) { return _withdrawDelegated(msg.sender, _indexer, _newIndexer); } @@ -211,12 +192,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _delegator Address of the delegator * @return Delegation data */ - function getDelegation(address _indexer, address _delegator) - external - view - override - returns (Delegation memory) - { + function getDelegation(address _indexer, address _delegator) external view override returns (Delegation memory) { return __delegationPools[_indexer].delegators[_delegator]; } @@ -254,12 +230,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _indexer Address of the indexer for which to query the delegation pool * @return Delegation pool as a DelegationPoolReturn struct */ - function delegationPools(address _indexer) - external - view - override - returns (DelegationPoolReturn memory) - { + function delegationPools(address _indexer) external view override returns (DelegationPoolReturn memory) { DelegationPool storage pool = __delegationPools[_indexer]; return DelegationPoolReturn( @@ -289,12 +260,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _maybeOperator The address that may or may not be an operator * @return True if the operator is authorized to operate on behalf of the indexer */ - function operatorAuth(address _indexer, address _maybeOperator) - external - view - override - returns (bool) - { + function operatorAuth(address _indexer, address _maybeOperator) external view override returns (bool) { return __operatorAuth[_indexer][_maybeOperator]; } @@ -304,12 +270,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _subgraphDeploymentId The subgraph deployment for which to query the allocations * @return The amount of tokens allocated to the subgraph deployment */ - function subgraphAllocations(bytes32 _subgraphDeploymentId) - external - view - override - returns (uint256) - { + function subgraphAllocations(bytes32 _subgraphDeploymentId) external view override returns (uint256) { return __subgraphAllocations[_subgraphDeploymentId]; } @@ -418,12 +379,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _allocationID Allocation ID for which to query the allocation information * @return The specified allocation, as an IStakingData.Allocation struct */ - function allocations(address _allocationID) - external - view - override - returns (IStakingData.Allocation memory) - { + function allocations(address _allocationID) external view override returns (IStakingData.Allocation memory) { return __allocations[_allocationID]; } @@ -442,12 +398,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _delegation Delegation of tokens from delegator to indexer * @return Amount of tokens to withdraw */ - function getWithdraweableDelegatedTokens(Delegation memory _delegation) - public - view - override - returns (uint256) - { + function getWithdraweableDelegatedTokens(Delegation memory _delegation) public view override returns (uint256) { // There must be locked tokens and period passed uint256 currentEpoch = epochManager().currentEpoch(); if (_delegation.tokensLockedUntil > 0 && currentEpoch >= _delegation.tokensLockedUntil) { @@ -495,11 +446,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _tokens Amount of tokens to delegate * @return Amount of shares issued of the delegation pool */ - function _delegate( - address _delegator, - address _indexer, - uint256 _tokens - ) private returns (uint256) { + function _delegate(address _delegator, address _indexer, uint256 _tokens) private returns (uint256) { // Only allow delegations over a minimum, to prevent rounding attacks require(_tokens >= MINIMUM_DELEGATION, "!minimum-delegation"); // Only delegate to non-empty address @@ -516,9 +463,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi uint256 delegatedTokens = _tokens.sub(delegationTax); // Calculate shares to issue - uint256 shares = (pool.tokens == 0) - ? delegatedTokens - : delegatedTokens.mul(pool.shares).div(pool.tokens); + uint256 shares = (pool.tokens == 0) ? delegatedTokens : delegatedTokens.mul(pool.shares).div(pool.tokens); require(shares > 0, "!shares"); // Update the delegation pool @@ -540,11 +485,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _shares Amount of shares to return and undelegate tokens * @return Amount of tokens returned for the shares of the delegation pool */ - function _undelegate( - address _delegator, - address _indexer, - uint256 _shares - ) private returns (uint256) { + function _undelegate(address _delegator, address _indexer, uint256 _shares) private returns (uint256) { // Can only undelegate a non-zero amount of shares require(_shares > 0, "!shares"); @@ -581,17 +522,9 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi require(remainingDelegation >= MINIMUM_DELEGATION, "!minimum-delegation"); } delegation.tokensLocked = delegation.tokensLocked.add(tokens); - delegation.tokensLockedUntil = epochManager().currentEpoch().add( - __delegationUnbondingPeriod - ); - - emit StakeDelegatedLocked( - _indexer, - _delegator, - tokens, - _shares, - delegation.tokensLockedUntil - ); + delegation.tokensLockedUntil = epochManager().currentEpoch().add(__delegationUnbondingPeriod); + + emit StakeDelegatedLocked(_indexer, _delegator, tokens, _shares, delegation.tokensLockedUntil); return tokens; } @@ -642,11 +575,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _percentage Percentage of tokens to burn as tax * @return Amount of tax charged */ - function _collectTax( - IGraphToken _graphToken, - uint256 _tokens, - uint256 _percentage - ) private returns (uint256) { + function _collectTax(IGraphToken _graphToken, uint256 _tokens, uint256 _percentage) private returns (uint256) { uint256 tax = uint256(_percentage).mul(_tokens).div(MAX_PPM); TokenUtils.burnTokens(_graphToken, tax); // Burn tax if any return tax; diff --git a/packages/contracts/contracts/staking/libs/Exponential.sol b/packages/contracts/contracts/staking/libs/Exponential.sol index 303b6790b..c9370342e 100644 --- a/packages/contracts/contracts/staking/libs/Exponential.sol +++ b/packages/contracts/contracts/staking/libs/Exponential.sol @@ -54,10 +54,7 @@ library LibExponential { } // Compute `1 - alpha * exp ^(-exponent)` - int256 factor = LibFixedMath.sub( - LibFixedMath.one(), - LibFixedMath.mul(alpha, LibFixedMath.exp(-exponent)) - ); + int256 factor = LibFixedMath.sub(LibFixedMath.one(), LibFixedMath.mul(alpha, LibFixedMath.exp(-exponent))); // Weight the fees by the factor return LibFixedMath.uintMul(factor, fees); diff --git a/packages/contracts/contracts/staking/libs/LibFixedMath.sol b/packages/contracts/contracts/staking/libs/LibFixedMath.sol index b8e5e39a5..ae8c9b69e 100644 --- a/packages/contracts/contracts/staking/libs/LibFixedMath.sol +++ b/packages/contracts/contracts/staking/libs/LibFixedMath.sol @@ -24,24 +24,20 @@ pragma solidity ^0.7.6; /// @dev Signed, fixed-point, 127-bit precision math library. library LibFixedMath { // 1 - int256 private constant FIXED_1 = - int256(0x0000000000000000000000000000000080000000000000000000000000000000); + int256 private constant FIXED_1 = int256(0x0000000000000000000000000000000080000000000000000000000000000000); // 2**255 - int256 private constant MIN_FIXED_VAL = - int256(0x8000000000000000000000000000000000000000000000000000000000000000); + int256 private constant MIN_FIXED_VAL = int256(0x8000000000000000000000000000000000000000000000000000000000000000); // 1^2 (in fixed-point) int256 private constant FIXED_1_SQUARED = int256(0x4000000000000000000000000000000000000000000000000000000000000000); // 1 int256 private constant LN_MAX_VAL = FIXED_1; // e ^ -63.875 - int256 private constant LN_MIN_VAL = - int256(0x0000000000000000000000000000000000000000000000000000000733048c5a); + int256 private constant LN_MIN_VAL = int256(0x0000000000000000000000000000000000000000000000000000000733048c5a); // 0 int256 private constant EXP_MAX_VAL = 0; // -63.875 - int256 private constant EXP_MIN_VAL = - -int256(0x0000000000000000000000000000001ff0000000000000000000000000000000); + int256 private constant EXP_MIN_VAL = -int256(0x0000000000000000000000000000001ff0000000000000000000000000000000); /// @dev Get one as a fixed-point number. function one() internal pure returns (int256 f) { @@ -72,11 +68,7 @@ library LibFixedMath { } /// @dev Performs (a * n) / d, without scaling for precision. - function mulDiv( - int256 a, - int256 n, - int256 d - ) internal pure returns (int256 c) { + function mulDiv(int256 a, int256 n, int256 d) internal pure returns (int256 c) { c = _div(_mul(a, n), d); } @@ -172,65 +164,47 @@ library LibFixedMath { // e ^ -32 if (x <= int256(0x00000000000000000000000000000000000000000001c8464f76164760000000)) { r -= int256(0x0000000000000000000000000000001000000000000000000000000000000000); // - 32 - x = - (x * FIXED_1) / - int256(0x00000000000000000000000000000000000000000001c8464f76164760000000); // / e ^ -32 + x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000000001c8464f76164760000000); // / e ^ -32 } // e ^ -16 if (x <= int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000)) { r -= int256(0x0000000000000000000000000000000800000000000000000000000000000000); // - 16 - x = - (x * FIXED_1) / - int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000); // / e ^ -16 + x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000); // / e ^ -16 } // e ^ -8 if (x <= int256(0x00000000000000000000000000000000000afe10820813d78000000000000000)) { r -= int256(0x0000000000000000000000000000000400000000000000000000000000000000); // - 8 - x = - (x * FIXED_1) / - int256(0x00000000000000000000000000000000000afe10820813d78000000000000000); // / e ^ -8 + x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000afe10820813d78000000000000000); // / e ^ -8 } // e ^ -4 if (x <= int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000)) { r -= int256(0x0000000000000000000000000000000200000000000000000000000000000000); // - 4 - x = - (x * FIXED_1) / - int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000); // / e ^ -4 + x = (x * FIXED_1) / int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000); // / e ^ -4 } // e ^ -2 if (x <= int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000)) { r -= int256(0x0000000000000000000000000000000100000000000000000000000000000000); // - 2 - x = - (x * FIXED_1) / - int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000); // / e ^ -2 + x = (x * FIXED_1) / int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000); // / e ^ -2 } // e ^ -1 if (x <= int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000)) { r -= int256(0x0000000000000000000000000000000080000000000000000000000000000000); // - 1 - x = - (x * FIXED_1) / - int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000); // / e ^ -1 + x = (x * FIXED_1) / int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000); // / e ^ -1 } // e ^ -0.5 if (x <= int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000)) { r -= int256(0x0000000000000000000000000000000040000000000000000000000000000000); // - 0.5 - x = - (x * FIXED_1) / - int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000); // / e ^ -0.5 + x = (x * FIXED_1) / int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000); // / e ^ -0.5 } // e ^ -0.25 if (x <= int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000)) { r -= int256(0x0000000000000000000000000000000020000000000000000000000000000000); // - 0.25 - x = - (x * FIXED_1) / - int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000); // / e ^ -0.25 + x = (x * FIXED_1) / int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000); // / e ^ -0.25 } // e ^ -0.125 if (x <= int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d)) { r -= int256(0x0000000000000000000000000000000010000000000000000000000000000000); // - 0.125 - x = - (x * FIXED_1) / - int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d); // / e ^ -0.125 + x = (x * FIXED_1) / int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d); // / e ^ -0.125 } // `x` is now our residual in the range of 1 <= x <= 2 (or close enough). diff --git a/packages/contracts/contracts/staking/libs/MathUtils.sol b/packages/contracts/contracts/staking/libs/MathUtils.sol index c20a1c3b0..0fb20389a 100644 --- a/packages/contracts/contracts/staking/libs/MathUtils.sol +++ b/packages/contracts/contracts/staking/libs/MathUtils.sol @@ -27,10 +27,7 @@ library MathUtils { uint256 valueB, uint256 weightB ) internal pure returns (uint256) { - return - valueA.mul(weightA).add(valueB.mul(weightB)).add(weightA.add(weightB).sub(1)).div( - weightA.add(weightB) - ); + return valueA.mul(weightA).add(valueB.mul(weightB)).add(weightA.add(weightB).sub(1)).div(weightA.add(weightB)); } /** diff --git a/packages/contracts/contracts/staking/libs/Stakes.sol b/packages/contracts/contracts/staking/libs/Stakes.sol index 38b5f5daa..b0524b14c 100644 --- a/packages/contracts/contracts/staking/libs/Stakes.sol +++ b/packages/contracts/contracts/staking/libs/Stakes.sol @@ -65,11 +65,7 @@ library Stakes { * @param _tokens Amount of tokens to unstake * @param _period Period in blocks that need to pass before withdrawal */ - function lockTokens( - Stakes.Indexer storage stake, - uint256 _tokens, - uint256 _period - ) internal { + function lockTokens(Stakes.Indexer storage stake, uint256 _tokens, uint256 _period) internal { // Take into account period averaging for multiple unstake requests uint256 lockingPeriod = _period; if (stake.tokensLocked > 0) { @@ -158,11 +154,10 @@ library Stakes { * @param _delegatedCapacity Amount of tokens used from delegators to calculate availability * @return Token amount */ - function tokensAvailableWithDelegation(Stakes.Indexer memory stake, uint256 _delegatedCapacity) - internal - pure - returns (uint256) - { + function tokensAvailableWithDelegation( + Stakes.Indexer memory stake, + uint256 _delegatedCapacity + ) internal pure returns (uint256) { uint256 tokensCapacity = stake.tokensStaked.add(_delegatedCapacity); uint256 _tokensUsed = stake.tokensUsed(); // If more tokens are used than the current capacity, the indexer is overallocated. diff --git a/packages/contracts/contracts/tests/CallhookReceiverMock.sol b/packages/contracts/contracts/tests/CallhookReceiverMock.sol index 1e71cf86f..e2418f3c8 100644 --- a/packages/contracts/contracts/tests/CallhookReceiverMock.sol +++ b/packages/contracts/contracts/tests/CallhookReceiverMock.sol @@ -18,11 +18,7 @@ contract CallhookReceiverMock is ICallhookReceiver { * @param _amount Amount of tokens that were transferred * @param _data ABI-encoded callhook data */ - function onTokenTransfer( - address _from, - uint256 _amount, - bytes calldata _data - ) external override { + function onTokenTransfer(address _from, uint256 _amount, bytes calldata _data) external override { uint256 foo; uint256 bar; (foo, bar) = abi.decode(_data, (uint256, uint256)); diff --git a/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolBadMock.sol b/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolBadMock.sol index 2dcb6e53a..f540b1b96 100644 --- a/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolBadMock.sol +++ b/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolBadMock.sol @@ -12,10 +12,7 @@ contract L1GraphTokenLockTransferToolBadMock { // Sends 1 wei less than requested function pullETH(address _l1Wallet, uint256 _amount) external { - require( - l2WalletAddress[_l1Wallet] != address(0), - "L1GraphTokenLockTransferToolMock: unknown L1 wallet" - ); + require(l2WalletAddress[_l1Wallet] != address(0), "L1GraphTokenLockTransferToolMock: unknown L1 wallet"); (bool success, ) = payable(msg.sender).call{ value: _amount - 1 }(""); require(success, "L1GraphTokenLockTransferToolMock: ETH pull failed"); } diff --git a/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolMock.sol b/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolMock.sol index 7a786beed..a1321d62f 100644 --- a/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolMock.sol +++ b/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolMock.sol @@ -11,10 +11,7 @@ contract L1GraphTokenLockTransferToolMock { } function pullETH(address _l1Wallet, uint256 _amount) external { - require( - l2WalletAddress[_l1Wallet] != address(0), - "L1GraphTokenLockTransferToolMock: unknown L1 wallet" - ); + require(l2WalletAddress[_l1Wallet] != address(0), "L1GraphTokenLockTransferToolMock: unknown L1 wallet"); (bool success, ) = payable(msg.sender).call{ value: _amount }(""); require(success, "L1GraphTokenLockTransferToolMock: ETH pull failed"); } diff --git a/packages/contracts/contracts/tests/LegacyGNSMock.sol b/packages/contracts/contracts/tests/LegacyGNSMock.sol index 0e1e94be4..b2b4088b9 100644 --- a/packages/contracts/contracts/tests/LegacyGNSMock.sol +++ b/packages/contracts/contracts/tests/LegacyGNSMock.sol @@ -28,11 +28,7 @@ contract LegacyGNSMock is L1GNS { * @param subgraphID Subgraph ID * @return subgraphDeploymentID Subgraph deployment ID */ - function getSubgraphDeploymentID(uint256 subgraphID) - external - view - returns (bytes32 subgraphDeploymentID) - { + function getSubgraphDeploymentID(uint256 subgraphID) external view returns (bytes32 subgraphDeploymentID) { IGNS.SubgraphData storage subgraph = _getSubgraphData(subgraphID); subgraphDeploymentID = subgraph.subgraphDeploymentID; } diff --git a/packages/contracts/contracts/tests/arbitrum/BridgeMock.sol b/packages/contracts/contracts/tests/arbitrum/BridgeMock.sol index 4f2848288..77be89b4e 100644 --- a/packages/contracts/contracts/tests/arbitrum/BridgeMock.sol +++ b/packages/contracts/contracts/tests/arbitrum/BridgeMock.sol @@ -33,14 +33,7 @@ contract BridgeMock is IBridge { ) external payable override returns (uint256) { messageIndex = messageIndex + 1; inboxAccs.push(keccak256(abi.encodePacked(inbox, _kind, _sender, _messageDataHash))); - emit MessageDelivered( - messageIndex, - inboxAccs[messageIndex - 1], - msg.sender, - _kind, - _sender, - _messageDataHash - ); + emit MessageDelivered(messageIndex, inboxAccs[messageIndex - 1], msg.sender, _kind, _sender, _messageDataHash); return messageIndex; } diff --git a/packages/contracts/contracts/tests/arbitrum/InboxMock.sol b/packages/contracts/contracts/tests/arbitrum/InboxMock.sol index b600ec3ac..57af6941c 100644 --- a/packages/contracts/contracts/tests/arbitrum/InboxMock.sol +++ b/packages/contracts/contracts/tests/arbitrum/InboxMock.sol @@ -171,11 +171,7 @@ contract InboxMock is IInbox { * @param _messageData Encoded message data * @return Message number returned by the bridge */ - function _deliverMessage( - uint8 _kind, - address _sender, - bytes memory _messageData - ) internal returns (uint256) { + function _deliverMessage(uint8 _kind, address _sender, bytes memory _messageData) internal returns (uint256) { uint256 msgNum = deliverToBridge(_kind, _sender, keccak256(_messageData)); emit InboxMessageDelivered(msgNum, _messageData); return msgNum; @@ -188,11 +184,7 @@ contract InboxMock is IInbox { * @param _messageDataHash keccak256 hash of the encoded message data * @return Message number returned by the bridge */ - function deliverToBridge( - uint8 _kind, - address _sender, - bytes32 _messageDataHash - ) internal returns (uint256) { + function deliverToBridge(uint8 _kind, address _sender, bytes32 _messageDataHash) internal returns (uint256) { return bridge.deliverMessageToInbox{ value: msg.value }(_kind, _sender, _messageDataHash); } } diff --git a/packages/contracts/contracts/tests/arbitrum/OutboxMock.sol b/packages/contracts/contracts/tests/arbitrum/OutboxMock.sol index a529a975a..92b9bb246 100644 --- a/packages/contracts/contracts/tests/arbitrum/OutboxMock.sol +++ b/packages/contracts/contracts/tests/arbitrum/OutboxMock.sol @@ -136,11 +136,7 @@ contract OutboxMock is IOutbox { * @param _amount Callvalue for the function call * @param _data Calldata for the function call */ - function executeBridgeCall( - address _destAddr, - uint256 _amount, - bytes memory _data - ) internal { + function executeBridgeCall(address _destAddr, uint256 _amount, bytes memory _data) internal { (bool success, bytes memory returndata) = bridge.executeCall(_destAddr, _amount, _data); if (!success) { if (returndata.length > 0) { diff --git a/packages/contracts/contracts/tests/ens/IENS.sol b/packages/contracts/contracts/tests/ens/IENS.sol index 9de0b357c..f03cb651c 100644 --- a/packages/contracts/contracts/tests/ens/IENS.sol +++ b/packages/contracts/contracts/tests/ens/IENS.sol @@ -5,11 +5,5 @@ interface IENS { function owner(bytes32 node) external view returns (address); // Must call setRecord, not setOwner, We must namehash it ourselves as well - function setSubnodeRecord( - bytes32 node, - bytes32 label, - address owner, - address resolver, - uint64 ttl - ) external; + function setSubnodeRecord(bytes32 node, bytes32 label, address owner, address resolver, uint64 ttl) external; } diff --git a/packages/contracts/contracts/tests/ens/IPublicResolver.sol b/packages/contracts/contracts/tests/ens/IPublicResolver.sol index 7f0676837..06ce2243b 100644 --- a/packages/contracts/contracts/tests/ens/IPublicResolver.sol +++ b/packages/contracts/contracts/tests/ens/IPublicResolver.sol @@ -4,9 +4,5 @@ pragma solidity ^0.7.6; interface IPublicResolver { function text(bytes32 node, string calldata key) external view returns (string memory); - function setText( - bytes32 node, - string calldata key, - string calldata value - ) external; + function setText(bytes32 node, string calldata key, string calldata value) external; } diff --git a/packages/contracts/contracts/token/GraphToken.sol b/packages/contracts/contracts/token/GraphToken.sol index 2b354e57c..53496b9a5 100644 --- a/packages/contracts/contracts/token/GraphToken.sol +++ b/packages/contracts/contracts/token/GraphToken.sol @@ -29,17 +29,12 @@ contract GraphToken is Governed, ERC20, ERC20Burnable { // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#definition-of-domainseparator bytes32 private constant DOMAIN_TYPE_HASH = - keccak256( - "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)" - ); + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)"); bytes32 private constant DOMAIN_NAME_HASH = keccak256("Graph Token"); bytes32 private constant DOMAIN_VERSION_HASH = keccak256("0"); - bytes32 private constant DOMAIN_SALT = - 0x51f3d585afe6dfeb2af01bba0889a36c1db03beec88c6a4d0c53817069026afa; // Randomly generated salt + bytes32 private constant DOMAIN_SALT = 0x51f3d585afe6dfeb2af01bba0889a36c1db03beec88c6a4d0c53817069026afa; // Randomly generated salt bytes32 private constant PERMIT_TYPEHASH = - keccak256( - "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" - ); + keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); // -- State -- @@ -106,9 +101,7 @@ contract GraphToken is Governed, ERC20, ERC20Burnable { abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, - keccak256( - abi.encode(PERMIT_TYPEHASH, _owner, _spender, _value, nonces[_owner], _deadline) - ) + keccak256(abi.encode(PERMIT_TYPEHASH, _owner, _spender, _value, nonces[_owner], _deadline)) ) ); nonces[_owner] = nonces[_owner].add(1); diff --git a/packages/contracts/contracts/upgrades/GraphProxy.sol b/packages/contracts/contracts/upgrades/GraphProxy.sol index d3f6eacec..7d227b065 100644 --- a/packages/contracts/contracts/upgrades/GraphProxy.sol +++ b/packages/contracts/contracts/upgrades/GraphProxy.sol @@ -47,13 +47,8 @@ contract GraphProxy is GraphProxyStorage, IGraphProxy { */ constructor(address _impl, address _admin) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); - assert( - IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1) - ); - assert( - PENDING_IMPLEMENTATION_SLOT == - bytes32(uint256(keccak256("eip1967.proxy.pendingImplementation")) - 1) - ); + assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); + assert(PENDING_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.pendingImplementation")) - 1)); _setAdmin(_admin); _setPendingImplementation(_impl); diff --git a/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol b/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol index d96dbd449..7d809d5ec 100644 --- a/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol +++ b/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol @@ -86,10 +86,7 @@ contract GraphProxyAdmin is Governed { * @param _implementation Address of the implementation accepting the proxy. * @param _proxy Address of the proxy being accepted. */ - function acceptProxy(GraphUpgradeable _implementation, IGraphProxy _proxy) - external - onlyGovernor - { + function acceptProxy(GraphUpgradeable _implementation, IGraphProxy _proxy) external onlyGovernor { _implementation.acceptProxy(_proxy); } diff --git a/packages/contracts/contracts/upgrades/GraphProxyStorage.sol b/packages/contracts/contracts/upgrades/GraphProxyStorage.sol index b308c0a0c..05b922647 100644 --- a/packages/contracts/contracts/upgrades/GraphProxyStorage.sol +++ b/packages/contracts/contracts/upgrades/GraphProxyStorage.sol @@ -14,8 +14,7 @@ abstract contract GraphProxyStorage { * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ - bytes32 internal constant IMPLEMENTATION_SLOT = - 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; + bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Storage slot with the address of the pending implementation. @@ -30,8 +29,7 @@ abstract contract GraphProxyStorage { * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ - bytes32 internal constant ADMIN_SLOT = - 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; + bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when pendingImplementation is changed. @@ -45,10 +43,7 @@ abstract contract GraphProxyStorage { * @dev Emitted when pendingImplementation is accepted, * which means contract implementation is updated. */ - event ImplementationUpdated( - address indexed oldImplementation, - address indexed newImplementation - ); + event ImplementationUpdated(address indexed oldImplementation, address indexed newImplementation); /** * @dev Emitted when the admin account has changed. diff --git a/packages/contracts/contracts/upgrades/GraphUpgradeable.sol b/packages/contracts/contracts/upgrades/GraphUpgradeable.sol index 92ce80ad7..862f7e7d5 100644 --- a/packages/contracts/contracts/upgrades/GraphUpgradeable.sol +++ b/packages/contracts/contracts/upgrades/GraphUpgradeable.sol @@ -14,8 +14,7 @@ abstract contract GraphUpgradeable { * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ - bytes32 internal constant IMPLEMENTATION_SLOT = - 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; + bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Check if the caller is the proxy admin. @@ -60,10 +59,7 @@ abstract contract GraphUpgradeable { * @param _proxy Proxy to accept * @param _data Calldata for the initialization function call (including selector) */ - function acceptProxyAndCall(IGraphProxy _proxy, bytes calldata _data) - external - onlyProxyAdmin(_proxy) - { + function acceptProxyAndCall(IGraphProxy _proxy, bytes calldata _data) external onlyProxyAdmin(_proxy) { _proxy.acceptUpgradeAndCall(_data); } } diff --git a/packages/contracts/contracts/utils/TokenUtils.sol b/packages/contracts/contracts/utils/TokenUtils.sol index cbb23ce97..265f918a5 100644 --- a/packages/contracts/contracts/utils/TokenUtils.sol +++ b/packages/contracts/contracts/utils/TokenUtils.sol @@ -11,11 +11,7 @@ library TokenUtils { * @param _from Address sending the tokens * @param _amount Amount of tokens to transfer */ - function pullTokens( - IGraphToken _graphToken, - address _from, - uint256 _amount - ) internal { + function pullTokens(IGraphToken _graphToken, address _from, uint256 _amount) internal { if (_amount > 0) { require(_graphToken.transferFrom(_from, address(this), _amount), "!transfer"); } @@ -27,11 +23,7 @@ library TokenUtils { * @param _to Address receiving the tokens * @param _amount Amount of tokens to transfer */ - function pushTokens( - IGraphToken _graphToken, - address _to, - uint256 _amount - ) internal { + function pushTokens(IGraphToken _graphToken, address _to, uint256 _amount) internal { if (_amount > 0) { require(_graphToken.transfer(_to, _amount), "!transfer"); } diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 48d52d57d..656b14121 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -68,7 +68,10 @@ "isomorphic-fetch": "^3.0.0", "lint-staged": "^10.5.4", "p-queue": "^6.6.1", - "solhint": "^3.3.6", + "prettier": "^3.2.5", + "prettier-plugin-solidity": "^1.3.1", + "solhint": "^4.1.1", + "solhint-graph-config": "workspace:^0.0.1", "solidity-coverage": "^0.7.16", "ts-node": "^10.9.1", "typechain": "^5.0.0", @@ -91,12 +94,8 @@ "test:coverage": "scripts/coverage", "test:upgrade": "scripts/upgrade", "lint": "yarn lint:ts && yarn lint:sol", - "lint:fix": "yarn lint:ts && yarn lint:sol:fix", "lint:ts": "eslint '**/*.{js,ts}' --fix", - "lint:sol": "solhint 'contracts/**/*.sol'", - "lint:sol:fix": "yarn prettier:sol && solhint --fix 'contracts/**/*.sol'", - "prettier": "yarn prettier:ts && yarn prettier:sol", - "prettier:sol": "prettier --write 'contracts/**/*.sol'", + "lint:sol": "prettier --write 'contracts/**/*.sol' && solhint --fix --noPrompt contracts/**/*.sol --config node_modules/solhint-graph-config/index.js", "analyze": "scripts/analyze", "myth": "scripts/myth", "flatten": "scripts/flatten && scripts/clean", @@ -106,7 +105,7 @@ }, "lint-staged": { "contracts/**/*.sol": [ - "yarn lint:sol:fix" + "yarn lint:sol" ], "**/*.ts": [ "yarn lint:ts" diff --git a/packages/contracts/prettier.config.js b/packages/contracts/prettier.config.js new file mode 100644 index 000000000..5b8e866f2 --- /dev/null +++ b/packages/contracts/prettier.config.js @@ -0,0 +1,2 @@ +const prettierGraphConfig = require('solhint-graph-config/prettier') +module.exports = prettierGraphConfig diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json index 60037c936..a12f7de23 100644 --- a/packages/contracts/tsconfig.json +++ b/packages/contracts/tsconfig.json @@ -12,6 +12,7 @@ ".solcover.js", "truffle.js", "eslint.config.js", + "prettier.config.js", "hardhat.config.ts", "index.d.ts", "scripts/**/*.ts", diff --git a/packages/solhint-graph-config/README.md b/packages/solhint-graph-config/README.md index 48f05f269..7a724946b 100644 --- a/packages/solhint-graph-config/README.md +++ b/packages/solhint-graph-config/README.md @@ -25,7 +25,7 @@ Run `solhint` with `node_modules/solhint-graph-config/index.js` as the configura { "scripts": { - "lint": "solhint --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js" + "lint": "solhint --fix --noPrompt contracts/**/*.sol --config node_modules/solhint-graph-config/index.js" } } diff --git a/yarn.lock b/yarn.lock index cdb16edb9..105d1827e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2674,7 +2674,10 @@ __metadata: isomorphic-fetch: "npm:^3.0.0" lint-staged: "npm:^10.5.4" p-queue: "npm:^6.6.1" - solhint: "npm:^3.3.6" + prettier: "npm:^3.2.5" + prettier-plugin-solidity: "npm:^1.3.1" + solhint: "npm:^4.1.1" + solhint-graph-config: "workspace:^0.0.1" solidity-coverage: "npm:^0.7.16" ts-node: "npm:^10.9.1" typechain: "npm:^5.0.0" @@ -4704,6 +4707,33 @@ __metadata: languageName: node linkType: hard +"@pnpm/config.env-replace@npm:^1.1.0": + version: 1.1.0 + resolution: "@pnpm/config.env-replace@npm:1.1.0" + checksum: 4cfc4a5c49ab3d0c6a1f196cfd4146374768b0243d441c7de8fa7bd28eaab6290f514b98490472cc65dbd080d34369447b3e9302585e1d5c099befd7c8b5e55f + languageName: node + linkType: hard + +"@pnpm/network.ca-file@npm:^1.0.1": + version: 1.0.2 + resolution: "@pnpm/network.ca-file@npm:1.0.2" + dependencies: + graceful-fs: "npm:4.2.10" + checksum: 95f6e0e38d047aca3283550719155ce7304ac00d98911e4ab026daedaf640a63bd83e3d13e17c623fa41ac72f3801382ba21260bcce431c14fbbc06430ecb776 + languageName: node + linkType: hard + +"@pnpm/npm-conf@npm:^2.1.0": + version: 2.2.2 + resolution: "@pnpm/npm-conf@npm:2.2.2" + dependencies: + "@pnpm/config.env-replace": "npm:^1.1.0" + "@pnpm/network.ca-file": "npm:^1.0.1" + config-chain: "npm:^1.1.11" + checksum: 71393dcfce85603fddd8484b486767163000afab03918303253ae97992615b91d25942f83751366cb40ad2ee32b0ae0a033561de9d878199a024286ff98b0296 + languageName: node + linkType: hard + "@prettier/sync@npm:^0.3.0": version: 0.3.0 resolution: "@prettier/sync@npm:0.3.0" @@ -4917,6 +4947,13 @@ __metadata: languageName: node linkType: hard +"@sindresorhus/is@npm:^5.2.0": + version: 5.6.0 + resolution: "@sindresorhus/is@npm:5.6.0" + checksum: 66727344d0c92edde5760b5fd1f8092b717f2298a162a5f7f29e4953e001479927402d9d387e245fb9dc7d3b37c72e335e93ed5875edfc5203c53be8ecba1b52 + languageName: node + linkType: hard + "@smithy/types@npm:^2.9.1": version: 2.10.0 resolution: "@smithy/types@npm:2.10.0" @@ -5304,7 +5341,7 @@ __metadata: languageName: node linkType: hard -"@types/http-cache-semantics@npm:*": +"@types/http-cache-semantics@npm:*, @types/http-cache-semantics@npm:^4.0.2": version: 4.0.4 resolution: "@types/http-cache-semantics@npm:4.0.4" checksum: 51b72568b4b2863e0fe8d6ce8aad72a784b7510d72dc866215642da51d84945a9459fa89f49ec48f1e9a1752e6a78e85a4cda0ded06b1c73e727610c925f9ce6 @@ -8144,6 +8181,28 @@ __metadata: languageName: node linkType: hard +"cacheable-lookup@npm:^7.0.0": + version: 7.0.0 + resolution: "cacheable-lookup@npm:7.0.0" + checksum: 63a9c144c5b45cb5549251e3ea774c04d63063b29e469f7584171d059d3a88f650f47869a974e2d07de62116463d742c287a81a625e791539d987115cb081635 + languageName: node + linkType: hard + +"cacheable-request@npm:^10.2.8": + version: 10.2.14 + resolution: "cacheable-request@npm:10.2.14" + dependencies: + "@types/http-cache-semantics": "npm:^4.0.2" + get-stream: "npm:^6.0.1" + http-cache-semantics: "npm:^4.1.1" + keyv: "npm:^4.5.3" + mimic-response: "npm:^4.0.0" + normalize-url: "npm:^8.0.0" + responselike: "npm:^3.0.0" + checksum: 41b6658db369f20c03128227ecd219ca7ac52a9d24fc0f499cc9aa5d40c097b48b73553504cebd137024d957c0ddb5b67cf3ac1439b136667f3586257763f88d + languageName: node + linkType: hard + "cacheable-request@npm:^6.0.0": version: 6.1.0 resolution: "cacheable-request@npm:6.1.0" @@ -8956,6 +9015,16 @@ __metadata: languageName: node linkType: hard +"config-chain@npm:^1.1.11": + version: 1.1.13 + resolution: "config-chain@npm:1.1.13" + dependencies: + ini: "npm:^1.3.4" + proto-list: "npm:~1.2.1" + checksum: 39d1df18739d7088736cc75695e98d7087aea43646351b028dfabd5508d79cf6ef4c5bcd90471f52cd87ae470d1c5490c0a8c1a292fbe6ee9ff688061ea0963e + languageName: node + linkType: hard + "consola@npm:^2.15.0": version: 2.15.3 resolution: "consola@npm:2.15.3" @@ -9521,6 +9590,13 @@ __metadata: languageName: node linkType: hard +"deep-extend@npm:^0.6.0": + version: 0.6.0 + resolution: "deep-extend@npm:0.6.0" + checksum: 1c6b0abcdb901e13a44c7d699116d3d4279fdb261983122a3783e7273844d5f2537dc2e1c454a23fcf645917f93fbf8d07101c1d03c015a87faa662755212566 + languageName: node + linkType: hard + "deep-is@npm:^0.1.3, deep-is@npm:~0.1.3": version: 0.1.4 resolution: "deep-is@npm:0.1.4" @@ -11862,6 +11938,13 @@ __metadata: languageName: node linkType: hard +"form-data-encoder@npm:^2.1.2": + version: 2.1.4 + resolution: "form-data-encoder@npm:2.1.4" + checksum: 4c06ae2b79ad693a59938dc49ebd020ecb58e4584860a90a230f80a68b026483b022ba5e4143cff06ae5ac8fd446a0b500fabc87bbac3d1f62f2757f8dabcaf7 + languageName: node + linkType: hard + "form-data@npm:^2.2.0": version: 2.5.1 resolution: "form-data@npm:2.5.1" @@ -12534,6 +12617,32 @@ __metadata: languageName: node linkType: hard +"got@npm:^12.1.0": + version: 12.6.1 + resolution: "got@npm:12.6.1" + dependencies: + "@sindresorhus/is": "npm:^5.2.0" + "@szmarczak/http-timer": "npm:^5.0.1" + cacheable-lookup: "npm:^7.0.0" + cacheable-request: "npm:^10.2.8" + decompress-response: "npm:^6.0.0" + form-data-encoder: "npm:^2.1.2" + get-stream: "npm:^6.0.1" + http2-wrapper: "npm:^2.1.10" + lowercase-keys: "npm:^3.0.0" + p-cancelable: "npm:^3.0.0" + responselike: "npm:^3.0.0" + checksum: 2fe97fcbd7a9ffc7c2d0ecf59aca0a0562e73a7749cadada9770eeb18efbdca3086262625fb65590594edc220a1eca58fab0d26b0c93c2f9a008234da71ca66b + languageName: node + linkType: hard + +"graceful-fs@npm:4.2.10": + version: 4.2.10 + resolution: "graceful-fs@npm:4.2.10" + checksum: 4223a833e38e1d0d2aea630c2433cfb94ddc07dfc11d511dbd6be1d16688c5be848acc31f9a5d0d0ddbfb56d2ee5a6ae0278aceeb0ca6a13f27e06b9956fb952 + languageName: node + linkType: hard + "graceful-fs@npm:^4.1.11, graceful-fs@npm:^4.1.2, graceful-fs@npm:^4.1.5, graceful-fs@npm:^4.1.6, graceful-fs@npm:^4.1.9, graceful-fs@npm:^4.2.0, graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6": version: 4.2.11 resolution: "graceful-fs@npm:4.2.11" @@ -13475,7 +13584,7 @@ __metadata: languageName: node linkType: hard -"ini@npm:^1.3.4, ini@npm:^1.3.5": +"ini@npm:^1.3.4, ini@npm:^1.3.5, ini@npm:~1.3.0": version: 1.3.8 resolution: "ini@npm:1.3.8" checksum: ec93838d2328b619532e4f1ff05df7909760b6f66d9c9e2ded11e5c1897d6f2f9980c54dd638f88654b00919ce31e827040631eab0a3969e4d1abefa0719516a @@ -14912,6 +15021,15 @@ __metadata: languageName: node linkType: hard +"latest-version@npm:^7.0.0": + version: 7.0.0 + resolution: "latest-version@npm:7.0.0" + dependencies: + package-json: "npm:^8.1.0" + checksum: 68045f5e419e005c12e595ae19687dd88317dd0108b83a8773197876622c7e9d164fe43aacca4f434b2cba105c92848b89277f658eabc5d50e81fb743bbcddb1 + languageName: node + linkType: hard + "lcid@npm:^1.0.0": version: 1.0.0 resolution: "lcid@npm:1.0.0" @@ -15948,6 +16066,13 @@ __metadata: languageName: node linkType: hard +"mimic-response@npm:^4.0.0": + version: 4.0.0 + resolution: "mimic-response@npm:4.0.0" + checksum: 761d788d2668ae9292c489605ffd4fad220f442fbae6832adce5ebad086d691e906a6d5240c290293c7a11e99fbdbbef04abbbed498bf8699a4ee0f31315e3fb + languageName: node + linkType: hard + "min-document@npm:^2.19.0": version: 2.19.0 resolution: "min-document@npm:2.19.0" @@ -16777,6 +16902,13 @@ __metadata: languageName: node linkType: hard +"normalize-url@npm:^8.0.0": + version: 8.0.0 + resolution: "normalize-url@npm:8.0.0" + checksum: 09582d56acd562d89849d9239852c2aff225c72be726556d6883ff36de50006803d32a023c10e917bcc1c55f73f3bb16434f67992fe9b61906a3db882192753c + languageName: node + linkType: hard + "npm-run-path@npm:^4.0.0, npm-run-path@npm:^4.0.1": version: 4.0.1 resolution: "npm-run-path@npm:4.0.1" @@ -17256,6 +17388,18 @@ __metadata: languageName: node linkType: hard +"package-json@npm:^8.1.0": + version: 8.1.1 + resolution: "package-json@npm:8.1.1" + dependencies: + got: "npm:^12.1.0" + registry-auth-token: "npm:^5.0.1" + registry-url: "npm:^6.0.0" + semver: "npm:^7.3.7" + checksum: 83b057878bca229033aefad4ef51569b484e63a65831ddf164dc31f0486817e17ffcb58c819c7af3ef3396042297096b3ffc04e107fd66f8f48756f6d2071c8f + languageName: node + linkType: hard + "packet-reader@npm:1.0.0": version: 1.0.0 resolution: "packet-reader@npm:1.0.0" @@ -18068,6 +18212,13 @@ __metadata: languageName: node linkType: hard +"proto-list@npm:~1.2.1": + version: 1.2.4 + resolution: "proto-list@npm:1.2.4" + checksum: b9179f99394ec8a68b8afc817690185f3b03933f7b46ce2e22c1930dc84b60d09f5ad222beab4e59e58c6c039c7f7fcf620397235ef441a356f31f9744010e12 + languageName: node + linkType: hard + "protocol-buffers-schema@npm:^3.3.1": version: 3.6.0 resolution: "protocol-buffers-schema@npm:3.6.0" @@ -18411,6 +18562,20 @@ __metadata: languageName: node linkType: hard +"rc@npm:1.2.8": + version: 1.2.8 + resolution: "rc@npm:1.2.8" + dependencies: + deep-extend: "npm:^0.6.0" + ini: "npm:~1.3.0" + minimist: "npm:^1.2.0" + strip-json-comments: "npm:~2.0.1" + bin: + rc: ./cli.js + checksum: 24a07653150f0d9ac7168e52943cc3cb4b7a22c0e43c7dff3219977c2fdca5a2760a304a029c20811a0e79d351f57d46c9bde216193a0f73978496afc2b85b15 + languageName: node + linkType: hard + "react-native-fs@npm:2.20.0": version: 2.20.0 resolution: "react-native-fs@npm:2.20.0" @@ -18658,6 +18823,24 @@ __metadata: languageName: node linkType: hard +"registry-auth-token@npm:^5.0.1": + version: 5.0.2 + resolution: "registry-auth-token@npm:5.0.2" + dependencies: + "@pnpm/npm-conf": "npm:^2.1.0" + checksum: 20fc2225681cc54ae7304b31ebad5a708063b1949593f02dfe5fb402bc1fc28890cecec6497ea396ba86d6cca8a8480715926dfef8cf1f2f11e6f6cc0a1b4bde + languageName: node + linkType: hard + +"registry-url@npm:^6.0.0": + version: 6.0.1 + resolution: "registry-url@npm:6.0.1" + dependencies: + rc: "npm:1.2.8" + checksum: 66e2221c8113fc35ee9d23fe58cb516fc8d556a189fb8d6f1011a02efccc846c4c9b5075b4027b99a5d5c9ad1345ac37f297bea3c0ca30d607ec8084bf561b90 + languageName: node + linkType: hard + "regjsgen@npm:^0.2.0": version: 0.2.0 resolution: "regjsgen@npm:0.2.0" @@ -18925,6 +19108,15 @@ __metadata: languageName: node linkType: hard +"responselike@npm:^3.0.0": + version: 3.0.0 + resolution: "responselike@npm:3.0.0" + dependencies: + lowercase-keys: "npm:^3.0.0" + checksum: 8af27153f7e47aa2c07a5f2d538cb1e5872995f0e9ff77def858ecce5c3fe677d42b824a62cde502e56d275ab832b0a8bd350d5cd6b467ac0425214ac12ae658 + languageName: node + linkType: hard + "restore-cursor@npm:^3.1.0": version: 3.1.0 resolution: "restore-cursor@npm:3.1.0" @@ -19273,7 +19465,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:7.6.0, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4": +"semver@npm:7.6.0, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4": version: 7.6.0 resolution: "semver@npm:7.6.0" dependencies: @@ -19947,9 +20139,9 @@ __metadata: languageName: node linkType: hard -"solhint@npm:^3.3.6": - version: 3.6.2 - resolution: "solhint@npm:3.6.2" +"solhint@npm:^4.1.1": + version: 4.1.1 + resolution: "solhint@npm:4.1.1" dependencies: "@solidity-parser/parser": "npm:^0.16.0" ajv: "npm:^6.12.6" @@ -19962,6 +20154,7 @@ __metadata: glob: "npm:^8.0.3" ignore: "npm:^5.2.4" js-yaml: "npm:^4.1.0" + latest-version: "npm:^7.0.0" lodash: "npm:^4.17.21" pluralize: "npm:^8.0.0" prettier: "npm:^2.8.3" @@ -19974,7 +20167,7 @@ __metadata: optional: true bin: solhint: solhint.js - checksum: db250dc141e92ca33a9adee11b01232dfa3883f053d781f30cd471c22af6d551e8b9ff839b7f1abbe9c0618204b0891b63fa3814ae049d824f98a4c5bb32b42b + checksum: b4bdb21bdc13f7ba3436d571a30cae6cb8dfb58ab1387df8bef25eeca25c8fbb3f625c49a5dddea41f8361aaeb4d8e2e9f986f580663ddd4574fd3d5de5f66c9 languageName: node linkType: hard @@ -20533,6 +20726,13 @@ __metadata: languageName: node linkType: hard +"strip-json-comments@npm:~2.0.1": + version: 2.0.1 + resolution: "strip-json-comments@npm:2.0.1" + checksum: b509231cbdee45064ff4f9fd73609e2bcc4e84a4d508e9dd0f31f70356473fde18abfb5838c17d56fb236f5a06b102ef115438de0600b749e818a35fbbc48c43 + languageName: node + linkType: hard + "supports-color@npm:8.1.1": version: 8.1.1 resolution: "supports-color@npm:8.1.1"