From 9a59c347ec1f595affb8e564937b724b895a2a1c Mon Sep 17 00:00:00 2001 From: tilacog Date: Mon, 18 Sep 2023 19:26:27 -0300 Subject: [PATCH] common: remove claimable allocations and disputeEpochs from allocation resolver --- .../resolvers/allocations.ts | 66 ++++--------------- 1 file changed, 12 insertions(+), 54 deletions(-) diff --git a/packages/indexer-common/src/indexer-management/resolvers/allocations.ts b/packages/indexer-common/src/indexer-management/resolvers/allocations.ts index a8d5d4fc9..170aeacf7 100644 --- a/packages/indexer-common/src/indexer-management/resolvers/allocations.ts +++ b/packages/indexer-common/src/indexer-management/resolvers/allocations.ts @@ -38,7 +38,7 @@ import { import { extractNetwork } from './utils' interface AllocationFilter { - status: 'active' | 'closed' | 'claimable' + status: 'active' | 'closed' allocation: string | null subgraphDeployment: string | null protocolNetwork: string | null @@ -48,7 +48,6 @@ enum AllocationQuery { all = 'all', active = 'active', closed = 'closed', - claimable = 'claimable', allocation = 'allocation', } @@ -114,30 +113,6 @@ const ALLOCATION_QUERIES = { } } `, - [AllocationQuery.claimable]: gql` - query allocations($indexer: String!, $disputableEpoch: Int!) { - allocations( - where: { indexer: $indexer, closedAtEpoch_lte: $disputableEpoch, status: Closed } - first: 1000 - ) { - id - subgraphDeployment { - id - stakedTokens - signalledTokens - } - indexer { - id - } - allocatedTokens - createdAtEpoch - closedAtEpoch - indexingRewards - queryFeesCollected - status - } - } - `, [AllocationQuery.closed]: gql` query allocations($indexer: String!) { allocations(where: { indexer: $indexer, status: Closed }, first: 1000) { @@ -187,9 +162,8 @@ async function queryAllocations( networkSubgraph: NetworkSubgraph, variables: { indexer: Address - disputableEpoch: number allocation: Address | null - status: 'active' | 'closed' | 'claimable' | null + status: 'active' | 'closed' | null }, context: { currentEpoch: number @@ -218,12 +192,6 @@ async function queryAllocations( filterVars = { indexer: variables.indexer.toLowerCase(), } - } else if (variables.status == 'claimable') { - filterType = AllocationQuery.claimable - filterVars = { - indexer: variables.indexer.toLowerCase(), - disputableEpoch: variables.disputableEpoch, - } } else if (variables.status == 'active') { filterType = AllocationQuery.active filterVars = { @@ -244,6 +212,7 @@ async function queryAllocations( const result = await networkSubgraph.query(ALLOCATION_QUERIES[filterType], filterVars) if (result.data.allocations.length == 0) { + // TODO: Is 'Claimable' still the correct term here, after Exponential Rebates? logger.info(`No 'Claimable' allocations found`) return [] } @@ -395,21 +364,11 @@ export default { }, } = network - const [currentEpoch, disputeEpochs, maxAllocationEpochs, epochLength] = - await Promise.all([ - networkMonitor.networkCurrentEpoch(), - contracts.staking.channelDisputeEpochs().catch((error) => { - logger.warn( - 'Failed to fetch channel dispute epochs. Ignoring claimable allocations', - { error, protocolNetwork: network.specification.networkIdentifier }, - ) - // Remove this call to channelDisputeEpochs once Exponential Rebates are deployed to - // all networks. Using a default value of zero on failure for now. - return 0 - }), - contracts.staking.maxAllocationEpochs(), - contracts.epochManager.epochLength(), - ]) + const [currentEpoch, maxAllocationEpochs, epochLength] = await Promise.all([ + networkMonitor.networkCurrentEpoch(), + contracts.staking.maxAllocationEpochs(), + contracts.epochManager.epochLength(), + ]) const allocation = filter.allocation ? filter.allocation === 'all' @@ -419,7 +378,6 @@ export default { const variables = { indexer: toAddress(address), - disputableEpoch: currentEpoch.epochNumber - disputeEpochs, allocation, status: filter.status, } @@ -545,7 +503,7 @@ export default { // avoid unnecessary transactions. // Note: We're checking the allocation state here, which is defined as // - // enum AllocationState { Null, Active, Closed, Finalized, Claimed } + // enum AllocationState { Null, Active, Closed, Finalized } // // in the contracts. const state = await contracts.staking.getAllocationState(allocationId) @@ -728,7 +686,7 @@ export default { // avoid unnecessary transactions. // Note: We're checking the allocation state here, which is defined as // - // enum AllocationState { Null, Active, Closed, Finalized, Claimed } + // enum AllocationState { Null, Active, Closed, Finalized } // // in the contracts. const state = await contracts.staking.getAllocationState(allocationData.id) @@ -933,7 +891,7 @@ export default { // avoid unnecessary transactions. // Note: We're checking the allocation state here, which is defined as // - // enum AllocationState { Null, Active, Closed, Finalized, Claimed } + // enum AllocationState { Null, Active, Closed, Finalized } // // in the contracts. const state = await contracts.staking.getAllocationState(allocationData.id) @@ -996,7 +954,7 @@ export default { // avoid unnecessary transactions. // Note: We're checking the allocation state here, which is defined as // - // enum AllocationState { Null, Active, Closed, Finalized, Claimed } + // enum AllocationState { Null, Active, Closed, Finalized } // // in the contracts. const newAllocationState =