Skip to content

Commit b492251

Browse files
fix: [TRST-R-6] Configurable indexing fees cut
1 parent 5f732ac commit b492251

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

packages/subgraph-service/contracts/SubgraphService.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,13 @@ contract SubgraphService is
398398
emit CurationCutSet(curationCut);
399399
}
400400

401+
/// @inheritdoc ISubgraphService
402+
function setIndexingFeesCut(uint256 indexingFeesCut_) external override onlyOwner {
403+
require(PPMMath.isValidPPM(indexingFeesCut_), SubgraphServiceInvalidIndexingFeesCut(indexingFeesCut_));
404+
indexingFeesCut = indexingFeesCut_;
405+
emit IndexingFeesCutSet(indexingFeesCut_);
406+
}
407+
401408
/**
402409
* @inheritdoc ISubgraphService
403410
* @notice Accept an indexing agreement.
@@ -793,7 +800,8 @@ contract SubgraphService is
793800
agreementId: _agreementId,
794801
currentEpoch: _graphEpochManager().currentEpoch(),
795802
receiverDestination: _paymentsDestination,
796-
data: _data
803+
data: _data,
804+
indexingFeesCut: indexingFeesCut
797805
})
798806
);
799807

packages/subgraph-service/contracts/SubgraphServiceStorage.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ abstract contract SubgraphServiceV1Storage {
2121

2222
/// @notice Destination of indexer payments
2323
mapping(address indexer => address destination) public paymentsDestination;
24+
25+
/// @notice The cut data service takes from indexing fee payments. In PPM.
26+
uint256 public indexingFeesCut;
2427
}

packages/subgraph-service/contracts/interfaces/ISubgraphService.sol

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,24 @@ interface ISubgraphService is IDataServiceFees {
6969
*/
7070
event CurationCutSet(uint256 curationCut);
7171

72+
/**
73+
* @notice Emitted when indexing fees cut is set
74+
* @param indexingFeesCut The indexing fees cut
75+
*/
76+
event IndexingFeesCutSet(uint256 indexingFeesCut);
77+
7278
/**
7379
* @notice Thrown when trying to set a curation cut that is not a valid PPM value
7480
* @param curationCut The curation cut value
7581
*/
7682
error SubgraphServiceInvalidCurationCut(uint256 curationCut);
7783

84+
/**
85+
* @notice Thrown when trying to set an indexing fees cut that is not a valid PPM value
86+
* @param indexingFeesCut The indexing fees cut value
87+
*/
88+
error SubgraphServiceInvalidIndexingFeesCut(uint256 indexingFeesCut);
89+
7890
/**
7991
* @notice Thrown when an indexer tries to register with an empty URL
8092
*/
@@ -252,6 +264,13 @@ interface ISubgraphService is IDataServiceFees {
252264
*/
253265
function setCurationCut(uint256 curationCut) external;
254266

267+
/**
268+
* @notice Sets the data service payment cut for indexing fees
269+
* @dev Emits a {IndexingFeesCutSet} event
270+
* @param indexingFeesCut The indexing fees cut for the payment type
271+
*/
272+
function setIndexingFeesCut(uint256 indexingFeesCut) external;
273+
255274
/**
256275
* @notice Sets the payments destination for an indexer to receive payments
257276
* @dev Emits a {PaymentsDestinationSet} event

packages/subgraph-service/contracts/libraries/IndexingAgreement.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,15 @@ library IndexingAgreement {
8080
* @param currentEpoch The current epoch
8181
* @param receiverDestination The address where the collected fees should be sent
8282
* @param data The encoded data containing the number of entities indexed, proof of indexing, and epoch
83+
* @param indexingFeesCut The indexing fees cut in PPM
8384
*/
8485
struct CollectParams {
8586
address indexer;
8687
bytes16 agreementId;
8788
uint256 currentEpoch;
8889
address receiverDestination;
8990
bytes data;
91+
uint256 indexingFeesCut;
9092
}
9193

9294
/**
@@ -577,7 +579,7 @@ library IndexingAgreement {
577579
agreementId: params.agreementId,
578580
collectionId: bytes32(uint256(uint160(wrapper.agreement.allocationId))),
579581
tokens: expectedTokens,
580-
dataServiceCut: 0,
582+
dataServiceCut: params.indexingFeesCut,
581583
receiverDestination: params.receiverDestination,
582584
maxSlippage: data.maxSlippage
583585
})

0 commit comments

Comments
 (0)