{"id":29219886,"url":"https://github.com/protofire/loopringv3.6-subgraph","last_synced_at":"2025-10-06T20:33:28.913Z","repository":{"id":66220317,"uuid":"346699227","full_name":"protofire/loopringv3.6-subgraph","owner":"protofire","description":"Loopring Exchange V2 (Loopring 3.6) subgraph. Supports L2 Blocks and Transactions, as well as L2 accounts, balances and more.","archived":false,"fork":false,"pushed_at":"2021-05-17T14:38:02.000Z","size":193,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-08-17T04:33:42.222Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://thegraph.com/explorer/subgraph/protofire/loopring-exchange-v2","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/protofire.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-03-11T12:46:30.000Z","updated_at":"2021-09-14T06:44:53.000Z","dependencies_parsed_at":"2023-03-21T11:19:03.988Z","dependency_job_id":null,"html_url":"https://github.com/protofire/loopringv3.6-subgraph","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/protofire/loopringv3.6-subgraph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protofire%2Floopringv3.6-subgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protofire%2Floopringv3.6-subgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protofire%2Floopringv3.6-subgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protofire%2Floopringv3.6-subgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/protofire","download_url":"https://codeload.github.com/protofire/loopringv3.6-subgraph/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protofire%2Floopringv3.6-subgraph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278674017,"owners_count":26026242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-03T02:07:44.783Z","updated_at":"2025-10-06T20:33:28.900Z","avatar_url":"https://github.com/protofire.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Loopring Exchange V2 subgraph (Loopring 3.6)\n\nThis subgraph aims to allow anyone to query data for the Loopring Exchange v2, with support for L2 blocks, transactions, accounts, pools, tokens, pairs and aggregations of trade volumes by token and pair on a weekly and daily basis.\n\n### Main entities and schema\n\nThe schema file contains documentation of most of the fields for almost all of the available entities.\n\n#### Proxy\n\nThe `Proxy` entity contains data about the upgradable proxy, such as the current implementation (`Exchange` entity), all past implementations, as well as a count of all blocks processed across all implementations.\n\n#### Exchange\n\nThis entity represents implementations of the exchange. It's a simple entity with the address of said implementation as it's ID, a link to the proxy (to be able to derive the past implementations list on the `Proxy` entity), and a list of all tokens registered when that implementation was active.\n\n#### Token\n\nThe `Token` entity contains the classic metadata found on any ERC20 (name, symbol, decimals) as well as the address of said token contract, the total traded volume (denominated in it's own token value), and the daily and weekly entities created for said token. Its ID is equal to the internal ID within the Loopring exchange.\n\n#### Pair\n\nThe `Pair` entity represents a pair of two tokens. There is only a single `Pair` entity for a pair of two tokens, since it's ID is standardized in the following manner `\u003cLOWEST Token ID\u003e-\u003cHIGHEST Token ID\u003e`.\n\nThis entity contains trade volume data, latest price of each token in the pair (denominated on the other token), daily and weekly data aggregations, as well as a list of all the trades involving said pair.\n\n#### Account\n\nThe `Account` interface is implemented by the following entities: `User`, `Pool` and `ProtocolAccount`. Since users and pools are all identified by account IDs within the loopring data, they share some similarities, so we wanted to represent them in a similar way, but still keep them as unique entities.\n\nBoth `User` and `Pool` entities have a unique ID within loopring, which is used as the ID for the entities, and that ID is linked to the address, which the entity also tracks.\n\nThese entities also have a list of all the `AccountTokenBalance` entities that a `User` or `Pool` has, and they also keep track of the last transaction where the entity was updated and the transaction it was created at.\n\n`ProtocolAccount` is a special singleton entity that keeps track of all `AccountTokenBalance` entities that the protocol has, for when protocolFees start being collected.\n\n#### AccountTokenBalance\n\nThis entity reprensents the balance of a particular `Token`, that a particular `Account` has.\n\nAside from links to the relevant `Token` and `Account`, and a balance field, this entity also has a list of all the `Transaction` entities that modified it.\n\n#### Block\n\nThe `Block` entity represents a single L2 block on the Loopring exchange.\n\nIt contains L1 metadata for the block (gasPrice, timestamp, L1 block height when the block was included, etc), as well as L2 metadata, like blockType, blockSize, blockVersion, operator that handled the block, etc.\n\nIt also contains the raw data represented as a hex string, parsed block data, like the fee maker and taker bips, and a list of all the parsed transactions from said block of raw data.\n\n#### Transaction\n\nThe `Transaction` interface is implemented by entities that represent all the transaction types available in the Loopring exchange:\n* AccountUpdate\n* AmmUpdate\n* SignatureVerification\n* Deposit\n* Withdrawal\n* Transfer\n* SpotTrade\n\nThe interface only defines the commmon points, which is only a reference to the `Block` entity where the transaction was created, the raw L2 data expressed as a hex string, and also a list of all the `AccountTokenBalance` entities that the transaction modified (useful for the transactions lists on said entity).\n\nEach of the implementations contains type specific parsed data from the raw L2 data. For more information, you can check the schema file, which has all relevant fields documented.\n\n#### Daily and weekly aggregated data\n\nThere are specific entities that aggregate `Token` and `Pair` data on a daily and weekly basis.\n`PairDailyData` and `PairWeeklyData` aggregate data for the `Pair` entity such as trade volume and token price (high, low, open, close).\n`TokenDailyData` and `TokenWeeklyData` aggregate data for the `Token` entity, in particular the trade volume.\n\nAll daily/weekly aggregation entities have fields to reference the day/week start and end, as well as the day/week \"number\". This number is relative to the Loopring exchange v2 launch, since we needed to define a start point for all daily/weekly aggregation entities.\n\nIf there's not activity for a `Token` or `Pair` within a day/week, there won't be an entity available for that day, and all values can be safely assumed as 0. We don't include these \"null\" entities since if there's no activity, there's no event to hook to and create the entity for that day/week.\n\n## Example queries\n\nGet all token balances for an account with its account ID\n\n```graphql\n{\n  accountTokenBalances(where: {account: \"\u003cACCOUNT-ID\u003e\"}) {\n    id\n    token {\n      id\n    }\n    account {\n      id\n    }\n    balance\n  }\n}\n```\n\nGet all account token balances for a specific token\n\n```graphql\n{\n  accountTokenBalances(where: {token: \"\u003cTOKEN-ID\u003e\"}) {\n    id\n    token {\n      id\n    }\n    account {\n      id\n    }\n    balance\n  }\n}\n```\n\nGet all spot trades for a particular account ID (two lists since any account could be the accountA or accountB)\n\n```graphql\n{\n  tradesA: spotTrades(where: {accountA: \"\u003cACCOUNT-ID\u003e\"}) {\n    accountA {\n      id\n    }\n    accountB {\n      id\n    }\n    tokenA {\n      symbol\n      decimals\n    }\n    tokenB {\n      symbol\n      decimals\n    }\n    fillSA\n    fillSB\n    feeA\n    feeB\n    id\n    tokenAPrice\n    tokenBPrice\n  }\n  tradesB: spotTrades(where: {accountB: \"\u003cACCOUNT-ID\u003e\"}) {\n    accountA {\n      id\n    }\n    accountB {\n      id\n    }\n    tokenA {\n      symbol\n      decimals\n    }\n    tokenB {\n      symbol\n      decimals\n    }\n    fillSA\n    fillSB\n    feeA\n    feeB\n    id\n    tokenAPrice\n    tokenBPrice\n  }\n}\n```\n\nGet pair daily data for ETH-LRC pair (0-1) ordered by dayNumber (ascending)\n\n```graphql\n{\n  pairDailyDatas(where:{pair:\"0-1\"}, orderBy: dayNumber, orderDirection: asc) {\n    pair {\n      token0 {\n        id\n        symbol\n      }\n      token1 {\n        id\n        symbol\n      }\n    }\n    dayStart\n    dayEnd\n    dayNumber\n    token0PriceLow\n    token1PriceLow\n    token0PriceHigh\n    token1PriceHigh\n    token0PriceOpen\n    token1PriceOpen\n    token0PriceClose\n    token1PriceClose\n    tradedVolumeToken0\n    tradedVolumeToken1\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotofire%2Floopringv3.6-subgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprotofire%2Floopringv3.6-subgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotofire%2Floopringv3.6-subgraph/lists"}