Skip to content

Commit

Permalink
*: Use signalledTokens instead of signalAmount for minSignal threshold
Browse files Browse the repository at this point in the history
The `signalledTokens` field describes the amount of GRT signalled on a
subgraph or subgraph deployment. `signalAmount` describes the amount of
signal shares on a subgraph, which is based on the bonding curve and
hence don't correspond 1:1 to the amount of GRT signalled.

It is therefore much more intuitive to use `signalledTokens` for the
`minSignal` threshold in indexing rules.
  • Loading branch information
Jannis committed Feb 23, 2022
1 parent c753d3d commit d579e1b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
24 changes: 13 additions & 11 deletions packages/indexer-agent/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ export class Network {
ipfsHash
deniedAt
stakedTokens
signalAmount
signalledTokens
queryFeesAmount
indexerAllocations {
indexer {
Expand Down Expand Up @@ -684,7 +684,9 @@ export class Network {

if (deploymentRule) {
const stakedTokens = BigNumber.from(deployment.stakedTokens)
const signalAmount = BigNumber.from(deployment.signalAmount)
const signalledTokens = BigNumber.from(
deployment.signalledTokens,
)
const avgQueryFees = BigNumber.from(
deployment.queryFeesAmount,
).div(
Expand All @@ -698,7 +700,7 @@ export class Network {
id: deployment.id.display,
deniedAt: deployment.deniedAt,
stakedTokens: stakedTokens.toString(),
signalAmount: signalAmount.toString(),
signalledTokens: signalledTokens.toString(),
avgQueryFees: avgQueryFees.toString(),
},
indexingRule: {
Expand Down Expand Up @@ -750,9 +752,9 @@ export class Network {
stakedTokens.gte(deploymentRule.minStake)) ||
// signal >= minSignal && signal <= maxSignal?
(deploymentRule.minSignal &&
signalAmount.gte(deploymentRule.minSignal)) ||
signalledTokens.gte(deploymentRule.minSignal)) ||
(deploymentRule.maxSignal &&
signalAmount.lte(deploymentRule.maxSignal)) ||
signalledTokens.lte(deploymentRule.maxSignal)) ||
// avgQueryFees >= minAvgQueryFees?
(deploymentRule.minAverageQueryFees &&
avgQueryFees.gte(deploymentRule.minAverageQueryFees))
Expand Down Expand Up @@ -818,7 +820,7 @@ export class Network {
subgraphDeployment {
id
stakedTokens
signalAmount
signalledTokens
}
}
}
Expand Down Expand Up @@ -875,7 +877,7 @@ export class Network {
subgraphDeployment {
id
stakedTokens
signalAmount
signalledTokens
}
}
}
Expand Down Expand Up @@ -932,7 +934,7 @@ export class Network {
subgraphDeployment {
id
stakedTokens
signalAmount
signalledTokens
}
}
}
Expand Down Expand Up @@ -1055,7 +1057,7 @@ export class Network {
subgraphDeployment {
id
stakedTokens
signalAmount
signalledTokens
}
}
}
Expand Down Expand Up @@ -1404,7 +1406,7 @@ export class Network {
subgraphDeployment: {
id: deployment,
stakedTokens: BigNumber.from(0),
signalAmount: BigNumber.from(0),
signalledTokens: BigNumber.from(0),
},
allocatedTokens: BigNumber.from(eventInputs.tokens),
createdAtBlockHash: '0x0',
Expand Down Expand Up @@ -1770,7 +1772,7 @@ export class Network {
subgraphDeployment: {
id: deployment,
stakedTokens: BigNumber.from(0),
signalAmount: BigNumber.from(0),
signalledTokens: BigNumber.from(0),
},
allocatedTokens: BigNumber.from(eventInputs.tokens),
createdAtBlockHash: receipt.blockHash,
Expand Down
6 changes: 3 additions & 3 deletions packages/indexer-cli/src/allocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface IndexerAllocation {
createdAtEpoch: number
closedAtEpoch: number | null
subgraphDeployment: string
signalAmount: BigNumber
signalledTokens: BigNumber
stakedTokens: BigNumber
}

Expand All @@ -26,7 +26,7 @@ const ALLOCATION_CONVERTERS_FROM_GRAPHQL: Record<
allocatedTokens: nullPassThrough((x: string) => BigNumber.from(x)),
createdAtEpoch: nullPassThrough((x: string) => parseInt(x)),
closedAtEpoch: nullPassThrough((x: string) => parseInt(x)),
signalAmount: nullPassThrough((x: string) => BigNumber.from(x)),
signalledTokens: nullPassThrough((x: string) => BigNumber.from(x)),
stakedTokens: nullPassThrough((x: string) => BigNumber.from(x)),
}

Expand All @@ -40,7 +40,7 @@ const ALLOCATION_FORMATTERS: Record<
allocatedTokens: x => utils.commify(formatGRT(x)),
createdAtEpoch: x => x,
closedAtEpoch: x => x,
signalAmount: x => utils.commify(formatGRT(x)),
signalledTokens: x => utils.commify(formatGRT(x)),
stakedTokens: x => utils.commify(formatGRT(x)),
}

Expand Down
4 changes: 2 additions & 2 deletions packages/indexer-cli/src/commands/indexer/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module.exports = {
createdAtEpoch
closedAtEpoch
subgraphDeployment
signalAmount
signalledTokens
stakedTokens
}
Expand Down Expand Up @@ -285,7 +285,7 @@ module.exports = {
'subgraphDeployment',
'allocatedTokens',
'createdAtEpoch',
'signalAmount',
'signalledTokens',
'stakedTokens',
])
}
Expand Down
4 changes: 2 additions & 2 deletions packages/indexer-common/src/allocations/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface SubgraphDeployment {
id: SubgraphDeploymentID
deniedAt: number
stakedTokens: BigNumber
signalAmount: BigNumber
signalledTokens: BigNumber
}

export interface Allocation {
Expand Down Expand Up @@ -42,7 +42,7 @@ export const parseGraphQLAllocation = (allocation: any): Allocation => ({
id: new SubgraphDeploymentID(allocation.subgraphDeployment.id),
deniedAt: allocation.subgraphDeployment.deniedAt,
stakedTokens: BigNumber.from(allocation.subgraphDeployment.stakedTokens),
signalAmount: BigNumber.from(allocation.subgraphDeployment.signalAmount),
signalledTokens: BigNumber.from(allocation.subgraphDeployment.signalledTokens),
},
indexer: toAddress(allocation.indexer.id),
allocatedTokens: BigNumber.from(allocation.allocatedTokens),
Expand Down
2 changes: 1 addition & 1 deletion packages/indexer-common/src/indexer-management/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const SCHEMA_SDL = gql`
createdAtEpoch: Int!
closedAtEpoch: Int
subgraphDeployment: String!
signalAmount: BigInt!
signalledTokens: BigInt!
stakedTokens: BigInt!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default {
subgraphDeployment {
id
stakedTokens
signalAmount
signalledTokens
}
}
}
Expand All @@ -128,7 +128,7 @@ export default {
...allocation,
subgraphDeployment: new SubgraphDeploymentID(allocation.subgraphDeployment.id)
.ipfsHash,
signalAmount: allocation.subgraphDeployment.signalAmount,
signalledTokens: allocation.subgraphDeployment.signalledTokens,
stakedTokens: allocation.subgraphDeployment.stakedTokens,
}))
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions packages/indexer-service/src/allocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const monitorEligibleAllocations = ({
subgraphDeployment {
id
stakedTokens
signalAmount
signalledTokens
}
}
recentlyClosedAllocations: totalAllocations(
Expand All @@ -98,7 +98,7 @@ export const monitorEligibleAllocations = ({
subgraphDeployment {
id
stakedTokens
signalAmount
signalledTokens
}
}
}
Expand Down

0 comments on commit d579e1b

Please sign in to comment.