Skip to content

Commit

Permalink
[subgraph] upcoming feature set for the subgraph (#1889)
Browse files Browse the repository at this point in the history
* [SUBGRAPH] [BUG] PoolMember not getting updated when the member units change (#1877)

* add a test starter

* add the test

* fixes

* improve test

* update dev container for matchstick compatibility

* implement the fix

* clean-up

* add elaborate test for pool  total amount received

* fix test issue

* add even more comments

* fix test name

* ignore test

---------

Co-authored-by: 0xdavinchee <[email protected]>

* [SUBGRAPH] approval mapping (#1878)

* approval mapping

* missing addresses

* missing addresses cont.

* no-op, trigger build

* fix tests

---------

Co-authored-by: Kaspar Kallas <[email protected]>

* [subgraph] Fix Correctness of GDA Entities (#1890)



---------

Co-authored-by: 0xdavinchee <[email protected]>

* add createdAtTimestamp/BlockNumber for ATS entity (#1909)

* [SUBGRAPH] fix governance config always null (#1908)

* fix governance config always null

* fix broken tests

* [SUBGRAPH] fix resolver entry (#1843)

* fix resolver entry

* do resolver rpc call on token initialization and remove handleTokenRPCCalls in subsequent token calls

* fix broken tests

* TODO comment can be removed

* remove mistakenly added files

---------

Co-authored-by: 0xdavinchee <[email protected]>
  • Loading branch information
kasparkallas and 0xdavinchee authored Mar 26, 2024
1 parent e56f02a commit 24a549c
Show file tree
Hide file tree
Showing 22 changed files with 1,022 additions and 195 deletions.
7 changes: 5 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bookworm",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-22.04",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
// If having issues with Nix then consult:
Expand All @@ -19,7 +19,9 @@
"ghcr.io/lukewiwa/features/shellcheck:0": {},
"ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers-contrib/features/act:1": {}
"ghcr.io/devcontainers-contrib/features/act:1": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/eitsupi/devcontainer-features/jq-likes:2": {}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
Expand All @@ -32,6 +34,7 @@
"source /home/node/.bashrc && foundryup",
"yarn global add npm-run-all",
"yarn install && yarn build",
"sudo apt-get install libpq5", // for subgraph's matchstick
"./tasks/fix-devcontainer.sh && nix develop . -c bash <(echo \"yarn install && yarn build\")"
]
// Configure tool-specific properties.
Expand Down
109 changes: 89 additions & 20 deletions packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,8 @@ type AgreementClassRegisteredEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `code`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -849,7 +850,8 @@ type AgreementClassUpdatedEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `code`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -868,7 +870,8 @@ type AppRegisteredEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `app`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -889,7 +892,9 @@ type GovernanceReplacedEvent implements Event @entity(immutable: true) {
order: BigInt!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `oldGovernance`
addresses[1] = `newGovernance`
"""
addresses: [Bytes!]!
oldGovernance: Bytes!
Expand All @@ -905,7 +910,8 @@ type JailEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `app`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -924,7 +930,8 @@ type SuperTokenFactoryUpdatedEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `newFactory`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -942,7 +949,9 @@ type SuperTokenLogicUpdatedEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `token`
addresses[1] = `code`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -963,7 +972,9 @@ type RoleAdminChangedEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `previousAdminRole`
addresses[1] = `newAdminRole`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -983,7 +994,9 @@ type RoleGrantedEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `account`
addresses[1] = `sender`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -1003,7 +1016,9 @@ type RoleRevokedEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `account`
addresses[1] = `sender`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand Down Expand Up @@ -1057,7 +1072,10 @@ type CFAv1LiquidationPeriodChangedEvent implements Event
governanceAddress: Bytes!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `governanceAddress`
addresses[1] = `host`
addresses[2] = `superToken`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -1083,7 +1101,10 @@ type ConfigChangedEvent implements Event @entity(immutable: true) {
governanceAddress: Bytes!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `governanceAddress`
addresses[1] = `host`
addresses[2] = `superToken`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -1110,7 +1131,11 @@ type RewardAddressChangedEvent implements Event @entity(immutable: true) {
governanceAddress: Bytes!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `governanceAddress`
addresses[1] = `host`
addresses[2] = `superToken`
addresses[3] = `rewardAddress`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -1136,7 +1161,10 @@ type PPPConfigurationChangedEvent implements Event @entity(immutable: true) {
governanceAddress: Bytes!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `governanceAddress`
addresses[1] = `host`
addresses[2] = `superToken`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand Down Expand Up @@ -1164,7 +1192,10 @@ type SuperTokenMinimumDepositChangedEvent implements Event
governanceAddress: Bytes!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `governanceAddress`
addresses[1] = `host`
addresses[2] = `superToken`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand All @@ -1190,7 +1221,11 @@ type TrustedForwarderChangedEvent implements Event @entity(immutable: true) {
governanceAddress: Bytes!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `governanceAddress`
addresses[1] = `host`
addresses[2] = `superToken`
addresses[3] = `forwarder`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand Down Expand Up @@ -1468,20 +1503,39 @@ type ApprovalEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `isNFTApproval` ? `nft address` : `token` (superToken)
addresses[1] = `owner`
addresses[2] = `to`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
logIndex: BigInt!
order: BigInt!

"""
The address that will be granting allowance to transfer ERC20/NFT.
"""
owner: Account!

"""
The address that will be granted allowance to transfer the NFT.
The address that will be granted allowance to transfer ERC20/NFT.
"""
to: Account!

"""
Indicates whether the event was emitted for the approval of an NFT.
"""
isNFTApproval: Boolean!

"""
If `amount` is non-zero, this event was emitted for the approval of an ERC20.
Tne amount of ERC20 tokens that will be granted allowance to transfer.
"""
amount: BigInt!

"""
If `tokenId` is non-zero, this event was emitted for the approval of an NFT.
The id of the NFT that will be granted allowance to transfer.
The id is: uint256(keccak256(abi.encode(block.chainid, superToken, sender, receiver)))
"""
Expand All @@ -1497,7 +1551,10 @@ type ApprovalForAllEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = NFT address
addresses[1] = `owner`
addresses[2] = `operator`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand Down Expand Up @@ -1590,7 +1647,8 @@ type SuperTokenLogicCreatedEvent implements Event @entity(immutable: true) {
name: String!

"""
Empty addresses array.
Contains the addresses that were impacted by this event:
addresses[0] = `tokenLogic`
"""
addresses: [Bytes!]!
blockNumber: BigInt!
Expand Down Expand Up @@ -1757,6 +1815,11 @@ type Pool @entity {
totalAmountInstantlyDistributedUntilUpdatedAt: BigInt!
totalAmountFlowedDistributedUntilUpdatedAt: BigInt!
totalAmountDistributedUntilUpdatedAt: BigInt!
totalFlowAdjustmentAmountDistributedUntilUpdatedAt: BigInt!

perUnitSettledValue: BigInt!
perUnitFlowRate: BigInt!

"""
A member is any account which has more than 0 units in the pool.
"""
Expand Down Expand Up @@ -1812,6 +1875,9 @@ type PoolMember @entity {
poolTotalAmountDistributedUntilUpdatedAt: BigInt!
totalAmountReceivedUntilUpdatedAt: BigInt!

syncedPerUnitSettledValue: BigInt!
syncedPerUnitFlowRate: BigInt!

account: Account!
pool: Pool!

Expand Down Expand Up @@ -2206,6 +2272,7 @@ type Token @entity {
underlyingToken: Token

"""
If `governanceConfig.id` is the zero address, the token uses the default governance config.
"""
governanceConfig: TokenGovernanceConfig
}
Expand Down Expand Up @@ -2237,6 +2304,8 @@ type AccountTokenSnapshot @entity {
ID composed of: accountID-tokenID
"""
id: ID!
createdAtTimestamp: BigInt!
createdAtBlockNumber: BigInt!
updatedAtTimestamp: BigInt!
updatedAtBlockNumber: BigInt!
# ---------------------------------- state ----------------------------------
Expand Down
4 changes: 4 additions & 0 deletions packages/subgraph/src/addresses.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ export function getResolverAddress(): Address {
export function getNativeAssetSuperTokenAddress(): Address {
return Address.fromString("{{nativeAssetSuperTokenAddress}}");
}

export function getIsLocalIntegrationTesting(): boolean {
return "{{testNetwork}}".length > 0;
}
Loading

0 comments on commit 24a549c

Please sign in to comment.