Skip to content

Commit

Permalink
feat: epoch entity feature parity (#57)
Browse files Browse the repository at this point in the history
* feat: epochManager added

* fix: abi fixed

* feat: epoch length updated events added

* feat: start and end block added

* feat: epoch signalledTokens added

* feat: epoch stake and queryFeeRebates added

* feat: epoch indexing rewards added

* feat: substreams graph updated

* fix: changed "end" keyword to "en" to allow graph rendering
  • Loading branch information
sahra-karakoc committed Aug 15, 2023
1 parent 8c3aacf commit 4fa37f2
Show file tree
Hide file tree
Showing 17 changed files with 2,847 additions and 24 deletions.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ graph LR;
map_events --> store_cumulative_curator_burned;
store_query_fee_rebates[store: store_query_fee_rebates];
map_events --> store_query_fee_rebates;
store_epoch_count --> store_query_fee_rebates;
store_query_fees_amount[store: store_query_fees_amount];
map_events --> store_query_fees_amount;
store_curator_fee_rewards[store: store_curator_fee_rewards];
Expand All @@ -71,9 +72,34 @@ graph LR;
map_events --> store_signal_amount;
store_subgraph_deployment_rewards[store: store_subgraph_deployment_rewards];
map_indexing_rewards --> store_subgraph_deployment_rewards;
store_epoch_length[store: store_epoch_length];
map_events --> store_epoch_length;
store_epoch_count[store: store_epoch_count];
store_epoch_length --> store_epoch_count;
sf.substreams.v1.Clock[source: sf.substreams.v1.Clock] --> store_epoch_count;
store_epoch_start[store: store_epoch_start];
store_epoch_count --> store_epoch_start;
sf.substreams.v1.Clock[source: sf.substreams.v1.Clock] --> store_epoch_start;
store_epoch_en[store: store_epoch_end];
store_epoch_count --> store_epoch_en;
sf.substreams.v1.Clock[source: sf.substreams.v1.Clock] --> store_epoch_en;
store_epoch_signal[store: store_epoch_signal];
map_storage_changes --> store_epoch_signal;
store_epoch_count --> store_epoch_signal;
store_epoch_stake[store: store_epoch_stake];
map_events --> store_epoch_stake;
store_epoch_count --> store_epoch_stake;
store_epoch_rewards[store: store_epoch_rewards];
map_indexing_rewards --> store_epoch_rewards;
store_epoch_count --> store_epoch_rewards;
graph_out[map: graph_out];
sf.substreams.v1.Clock[source: sf.substreams.v1.Clock] --> graph_out;
map_events --> graph_out;
store_epoch_start -- deltas --> graph_out;
store_epoch_en -- deltas --> graph_out;
store_epoch_signal -- deltas --> graph_out;
store_epoch_stake -- deltas --> graph_out;
store_epoch_rewards -- deltas --> graph_out;
store_grt_global -- deltas --> graph_out;
store_grt_balances -- deltas --> graph_out;
store_graph_account_indexer -- deltas --> graph_out;
Expand All @@ -94,8 +120,8 @@ graph LR;
store_signal_amount -- deltas --> graph_out;
store_subgraph_deployment_rewards -- deltas --> graph_out;
map_indexing_rewards --> graph_out;
```
```

## Quickstart
To build and run the substream,
Expand Down
232 changes: 232 additions & 0 deletions abis/epochManager.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "epochLength",
"type": "uint256"
}
],
"name": "EpochLengthUpdate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "epoch",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "caller",
"type": "address"
}
],
"name": "EpochRun",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "string",
"name": "param",
"type": "string"
}
],
"name": "ParameterUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "controller",
"type": "address"
}
],
"name": "SetController",
"type": "event"
},
{
"inputs": [
{
"internalType": "contract IGraphProxy",
"name": "_proxy",
"type": "address"
}
],
"name": "acceptProxy",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IGraphProxy",
"name": "_proxy",
"type": "address"
},
{ "internalType": "bytes", "name": "_data", "type": "bytes" }
],
"name": "acceptProxyAndCall",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"name": "addressCache",
"outputs": [{ "internalType": "address", "name": "", "type": "address" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "_block", "type": "uint256" }
],
"name": "blockHash",
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "blockNum",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "controller",
"outputs": [
{ "internalType": "contract IController", "name": "", "type": "address" }
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "currentEpoch",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "currentEpochBlock",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "currentEpochBlockSinceStart",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "epochLength",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "_epoch", "type": "uint256" }
],
"name": "epochsSince",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "epochsSinceUpdate",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "_controller", "type": "address" },
{ "internalType": "uint256", "name": "_epochLength", "type": "uint256" }
],
"name": "initialize",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "isCurrentEpochRun",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lastLengthUpdateBlock",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lastLengthUpdateEpoch",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lastRunEpoch",
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "runEpoch",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "_controller", "type": "address" }
],
"name": "setController",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "_epochLength", "type": "uint256" }
],
"name": "setEpochLength",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ fn main() -> Result<(), anyhow::Error> {
Abigen::new("controller", "./abis/controller.json")?
.generate()?
.write_to_file("src/abi/controller.rs")?;
Abigen::new("epochManager", "./abis/epochManager.json")?
.generate()?
.write_to_file("src/abi/epoch_manager.rs")?;
Ok(())
}
13 changes: 13 additions & 0 deletions proto/erc20.proto
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ message AllocationCollectedEvents {
message PauseChangedEvents {
repeated PauseChanged paused_changed_events = 1;
}

message PartialPauseChangedEvents {
repeated PartialPauseChanged partial_paused_changed_events = 1;
}

message EpochLengthUpdatedEvents {
repeated EpochLengthUpdated epoch_length_updated_events = 1;
}

message IndexerStakes {
repeated IndexerStake indexer_stakes = 1;
}
Expand Down Expand Up @@ -113,6 +118,7 @@ message Events {
AllocationCollectedEvents allocation_collected_events = 13;
PauseChangedEvents pause_changed_events = 14;
PartialPauseChangedEvents partial_pause_changed_events = 15;
EpochLengthUpdatedEvents epoch_length_updated_events = 16;
}

message Transfer {
Expand Down Expand Up @@ -263,6 +269,13 @@ message PartialPauseChanged {
uint64 ordinal = 3;
}

message EpochLengthUpdated {
string id = 1;
string last_length_update_block = 2;
string epoch_length = 3;
uint64 ordinal = 4;
}

message IndexerStake {
string id = 1;
bytes indexer = 2;
Expand Down
24 changes: 24 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,27 @@ enum AllocationStatus {
Finalized # == Closing && closedAtEpoch + channelDisputeEpochs > now(). Note, the subgraph has no way to return this value. it is implied
Claimed # == not Null && tokens == 0 - i.e. finalized, and all tokens withdrawn
}

"""
Epoch aggregate data for network statistics on signaling, rewards, and query fees
"""
type Epoch @entity {
"Epoch number"
id: ID!
"Start block of the epoch"
startBlock: Int!
"End block of the epoch"
endBlock: Int!
"Signaled tokens during this epoch"
signalledTokens: BigInt!
"Stake deposited during this epoch"
stakeDeposited: BigInt!
"Rebate amount claimed from the protocol through cobbs douglas during this epoch (Doesn't correlate to the queryFeesCollected for this epoch since there's a 7 day period before claiming)"
queryFeeRebates: BigInt!
"Total indexing rewards earned in this epoch. Includes both delegator and indexer rewards"
totalRewards: BigInt!
"Total indexing rewards earned in this epoch by indexers"
totalIndexerRewards: BigInt!
"Total indexing rewards earned in this epoch by delegators"
totalDelegatorRewards: BigInt!
}

0 comments on commit 4fa37f2

Please sign in to comment.