{"id":29219776,"url":"https://github.com/protofire/subgraph-devkit","last_synced_at":"2026-02-27T17:11:12.215Z","repository":{"id":65327550,"uuid":"586919354","full_name":"protofire/subgraph-devkit","owner":"protofire","description":"Happiness kit for subgraph developers","archived":false,"fork":false,"pushed_at":"2024-06-28T15:14:45.000Z","size":219,"stargazers_count":6,"open_issues_count":5,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-15T05:42:18.458Z","etag":null,"topics":["subgraph","thegraph","thegraphprotocol","tooling","toolkit","typescript"],"latest_commit_sha":null,"homepage":"https://protofire.github.io/subgraph-devkit/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"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}},"created_at":"2023-01-09T14:41:19.000Z","updated_at":"2024-06-28T15:12:03.000Z","dependencies_parsed_at":"2024-06-28T15:25:36.803Z","dependency_job_id":"068777f2-257c-4a8d-b94f-f146ed1a1dd0","html_url":"https://github.com/protofire/subgraph-devkit","commit_stats":{"total_commits":23,"total_committers":2,"mean_commits":11.5,"dds":"0.17391304347826086","last_synced_commit":"0001bce7e5b4daac9f65daf7cb2704dbf3a2db38"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/protofire/subgraph-devkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protofire%2Fsubgraph-devkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protofire%2Fsubgraph-devkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protofire%2Fsubgraph-devkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protofire%2Fsubgraph-devkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/protofire","download_url":"https://codeload.github.com/protofire/subgraph-devkit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protofire%2Fsubgraph-devkit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263245316,"owners_count":23436515,"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","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":["subgraph","thegraph","thegraphprotocol","tooling","toolkit","typescript"],"created_at":"2025-07-03T02:07:29.244Z","updated_at":"2025-10-27T00:20:50.839Z","avatar_url":"https://github.com/protofire.png","language":"TypeScript","readme":"![ci](https://github.com/protofire/subgraph-devkit/actions/workflows/ci.yaml/badge.svg)\n\n# Subgraph Devkit\n\nHappiness kit for subgraph developers\n\n### Features:\n\n- [Oracles](#oracles)\n\n  - [x] Token Price Fetching\n\n- [Numbers](#numbers)\n\n  - [x] Factories\n  - [x] Conversion\n  - [x] Helpers\n\n- [Bytes](#bytes)\n\n  - [x] Conversion\n\n- [Testing](#testing)\n\n  - [x] Mocking\n  - [x] Assertions\n\n- [Constants](#constants)\n  - [x] Addresses\n  - [x] Units\n\n### Tech Stack:\n\n- AssemblyScript\n- Matchstick\n\n### Installation:\n\n```shell\nyarn add @protofire/subgraph-devkit\n```\n\n### Documentation\n\n#### Oracles\n\n```typescript\nimport { Address } from \"@graphprotocol/graph-ts\";\nimport { oracles } from \"@protofire/subgraph-devkit\";\n\nconst tokenAddress = Address.fromString(\n  \"0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984\"\n);\n\n// get token price in usd from ChainLink oracle\noracles.chainlink.fetchPriceUSD(tokenAddress);\n\n// get token price in usd from YearnLens oracle\noracles.yearnLens.fetchPriceUSD(tokenAddress);\n\n// get token price in usd from Uniswap oracle\noracles.uniswap.fetchPriceUSD(tokenAddress);\n```\n\n#### Numbers\n\n```typescript\nimport { BigDecimal, BigInt } from \"@graphprotocol/graph-ts\";\nimport { decimals, integers } from \"@protofire/subgraph-devkit\";\n\n// number 0 in BigDecimal\ndecimals.ZERO;\n\n// number 1 in BigDecimal\ndecimals.ONE;\n\n// number 0 in BigInt\nintegers.ZERO;\n\n// number 1 in BigInt\nintegers.ONE;\n\n// number 10 in BigInt\nintegers.TEN;\n\n// Get min/max value\nconst a = BigInt.fromI32(100);\nconst b = BigInt.fromI32(101);\n\nintegers.min(a, b); // =\u003e 100\nintegers.max(a, b); // =\u003e 101\n\n// Convert BigInt into Bytes\nconst n = BigInt.fromI32(100);\nintegers.toBytes(n);\n\n// Create BigDecimal from BigInt\nconst n = BigInt.fromI32(1000000);\ndecimals.fromBigInt(n, 6); // =\u003e 1\n\n// Create BigDecimal from Float\ndecimals.fromFloat(1000000.123);\n\n// Create BigDecimal from Integer\ndecimals.fromInt(9223372036854775807);\n\n// Convert BigDecimal to BigInt\nconst n = BigDecimal.fromString(\"1234.56\");\ndecimals.toBigInt(n); // =\u003e 123456\n\n// Get min/max value\nconst a = BigDecimal.fromString(\"100.525678\");\nconst b = BigDecimal.fromString(\"100.525679\");\n\ndecimals.min(a, b); // =\u003e 100.525678\ndecimals.max(a, b); // =\u003e 100.525679\n\n// MakerDAO\n\n// Create BigDecimal from RAD BigInt\nconst rad = BigInt.fromString(\n  \"12500000000000000000000000000000000000000000000\"\n);\ndecimals.fromRad(rad); // =\u003e 12.5;\n\n// Create BigDecimal from WAD BigInt\nconst wad = BigInt.fromString(\"12500000000000000000\");\ndecimals.fromWad(wad); // =\u003e 12.5\n\n// Create BigDecimal from RAY BigInt\nconst ray = BigInt.fromString(\"12500000000000000000000000000\");\ndecimals.fromRay(ray); // =\u003e 12.5\n\nconst value = BigDecimal.fromString(\"12.5\");\n\n// Convert BigDecimal into RAD BigInt\ndecimals.toRad(value); // =\u003e 12500000000000000000000000000000000000000000000\n\n// Convert BigDecimal into RAY BigInt\ndecimals.toRay(value); // =\u003e 12500000000000000000000000000\n\n// Convert BigDecimal into WAD BigInt\ndecimals.toWad(value); // =\u003e 12500000000000000000\n```\n\n#### Bytes\n\n```typescript\nimport { bytes } from \"@protofire/subgraph-devkit\";\n\n// Convert Bytes into Address\nconst stringAddress = \"0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984\";\nconst bytesAddress = Bytes.fromHexString(stringAddress);\nconst address = bytes.toAddress(bytesAddress);\n\n// Convert unsigned number in Bytes into BigInt\nconst bytesData = Bytes.fromHexString(\"0x28fc\");\nbytes.toUnsignedBigInt(bytesData); // =\u003e 10492\n\n// Convert signed number in Bytes into BigInt\nconst bytesData = Bytes.fromHexString(\"0xd704\");\nbytes.toSignedBigInt(bytesData); // =\u003e -10492\n```\n\n#### Testing\n\n```typescript\nimport { BigDecimal } from \"@graphprotocol/graph-ts\";\nimport { describe, test } from \"matchstick-as/assembly/index\";\nimport { tests } from \"@protofire/subgraph-devkit\";\n\ndescribe(\"decimalEquals\", () =\u003e {\n  test(\"decimal equals to decimal\", () =\u003e {\n    const a = BigDeciaml.fromString(\"100\");\n    const b = BigDeciaml.fromString(\"100\");\n\n    tests.asserts.decimalEquals(a, b);\n  });\n});\n```\n\n#### Constants\n\n```typescript\nimport { constants } from \"@protofire/subgraph-devkit\";\n\n// USDC contract address\nconstants.addresses.USDC;\n\n// WETH contract address\nconstants.addresses.WETH;\n\n// UNISWAP_V2_ROUTER_02 contract address\nconstants.addresses.UNISWAP_V2_ROUTER_02;\n\n// CHAINLINK_FEED_REGISTRY contract address\nconstants.addresses.CHAINLINK_FEED_REGISTRY;\n\n// YEARN_LENS_ORACLE contract address\nconstants.addresses.YEARN_LENS_ORACLE;\n\n// USDC unit (BigInt): 1000000\nconstants.units.USDC;\n\n// MakerDAO\n\n// WAD unit (BigInt): 1000000000000000000\nconstants.units.WAD;\n\n// RAY unit (BigInt): 1000000000000000000000000000\nconstants.units.RAY;\n\n// RAD unit (BigInt): 1000000000000000000000000000000000000000000000\nconstants.units.RAD;\n```\n\n### Contributing:\n\n- **Fork** the repo on GitHub\n- **Clone** the project to your own machine\n- **Commit** changes to your own branch\n- **Push** your work back up to your fork\n- Submit a **Pull request** so that we can review your changes\n\n### Running Tests\n\nIn order to be able to take advantage of matchstick testing library, we have added a dummy subgraph inside tests folder.\nTests will live inside that dummy subgraph and you can run them as follows:\n\n```shell\nyarn test\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotofire%2Fsubgraph-devkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprotofire%2Fsubgraph-devkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotofire%2Fsubgraph-devkit/lists"}