Skip to content

Commit

Permalink
common: remove claimable allocations and disputeEpochs from allocatio…
Browse files Browse the repository at this point in the history
…n resolver
  • Loading branch information
tilacog committed Sep 18, 2023
1 parent 653a277 commit 9a59c34
Showing 1 changed file with 12 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -48,7 +48,6 @@ enum AllocationQuery {
all = 'all',
active = 'active',
closed = 'closed',
claimable = 'claimable',
allocation = 'allocation',
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand All @@ -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 []
}
Expand Down Expand Up @@ -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'
Expand All @@ -419,7 +378,6 @@ export default {

const variables = {
indexer: toAddress(address),
disputableEpoch: currentEpoch.epochNumber - disputeEpochs,
allocation,
status: filter.status,
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit 9a59c34

Please sign in to comment.