Migrate the Algebra Farming subgraph to Squid SDK.
Important
This quest is sponsored by StellaSwap who generously offered to provide two extra rewards of $500 (in STELLA tokens) each. The rewards will be given to the authors of two submissions selected by StellaSwap from the pool of five Subsquid-selected winners. See Special considerations for extra info.
Subgraph source code is available at the AlgebraFarming
folder or this repo. The resulting squid should match the GraphQL API of the subgraph as close as possible, by migrating schema.graphql
(see Permissible deviations). The judges reserve the right to request improvements after the initial review of the submission. Reach out to the Discord Channel for any tech questions regarding this quest. You can use the template
squid as a starter.
Category | Skill Level | Time required (hours) | Max Participants | Reward | Status |
---|---|---|---|---|---|
Migration | ~10 | 10 |
|
open |
Two of the winning submissions will be selected by StellaSwap for extra rewards of $500 (in STELLA tokens) each.
This section describes the criteria put forth by Subsquid. See Special considerations for StellaSwap info.
Ultimately, the solutions are accepted at the discretion of judges following a manual review. This sections is a rough guide that is in no way binding on our side.
Some of the reasons why the solution will not be accepted include:
- The submission is an unmodified squid template. We will not reward these by chance. Give up.
- We receive two or more solutions with identical or almost identical code. If we detect that, either one or none of the affected submissions will be rewarded, depending on your luck.
- The squid does not start.
- The squid fails to sync fully due to internal errors.
- The squid fails to sync fully in a reasonable time due to severe performance issues. Follow the best practices guide to avoid these.
- The squid writes no data into its database.
- Data returned for any query is not consistent with subgraph data. You may find this tool useful for comparing squid and subgraph APIs.
It is desirable that your solution:
- includes a suite of test GraphQL queries that touches every schema entity and, if used, every custom resolver at least once, with corresponding subgraph queries (listing in README is enough)
- has high code quality (readability, simplicity, comments where necessary)
- avoids any "sleeping bugs": logic errors that accidentally happen to not break the data
- follows the standard squid startup procedure:
If it does not, describe your startup procedure in the README.
git clone <repo_url> cd <repo_url> npm ci sqd up sqd process & sqd serve
Please test your solutions before submitting. We do allow some corrections, but judges' time is not limitless.
Important
To ensure fair competition and timely delivery of squids to StellaSwap, we limit the time allotted for post-deadline corrections to two weeks. The limit will be enforced.
To submit, invite the following github accounts to your private repo : @dariaag, @belopash, @abernatskiy and @dzhelezov.
- You can use
String
in place ofBytes
in your submissions - The only way to handle many-to-many relations in squids is by adding explicit join tables. Addition of such tables is an expected change when schemas with such relations are migrated.
The subgraph took an extremely long time to sync on TheGraph. The StellaSwap team wants to improve upon that as much as possible. So, the advice is to pay extra attention to performance-related matters. Use batch processing and database indexes for best results.
tSQD rewards will be delivered via the quests page of Subsquid Cloud. Make sure you use the same GitHub handle to make a submission and when linking to that page.
STELLA rewards from StellaSwap will be sent to addresses individually agreed upon with each winner. We'll make a GitHub issue in each of the winning repos for the discussion.
Winners (both the five selected by Subsquid and the two selected by StellaSwap) will be listed at the quest repository README. If you do not wish to be listed please tell us that in an issue in your submission repo.
- Squid development master guide
- TheGraph migration guide
- Subsquid Cloud best practices guide (includes a lot of good non-Cloud related advice)
- compareGraphQL tool
-
Install Node v16.x or newer https://nodejs.org/en/download
-
Install Docker https://docs.docker.com/engine/install/
-
Install git https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
-
Install Squid CLI
npm i -g @subsquid/cli@latest
Full startup procedure for newly developed squids:
- Install dependecies:
npm ci
- Generate model
sqd codegen
- Generate types
sqd typegen
- Build the squid
sqd build
- Open docker and run:
sqd up
- Generate migrations:
sqd migration:generate
- Start processing:
sqd process
- Start a local GraphQL server in a separate terminal:
sqd serve
Types (./src/abi
), models (./src/model
) and migrations (./db
) are typically kept within squid repos after they become stable. Then the startup procedure simplifies to
npm ci
sqd up
sqd process &
sqd serve
- Docker not installed
X db Error ร query-gateway Error
Error response from daemon: Get "https://registry-1.docker.jo/v2/": uri ting to 127.0.0.1:8888: dial cp 127.0.0.1:8888: connectex: No connection
- Git not installed
Error: Error: spawn git ENOENT
at ChildProcess._handle.onexit (node: internal/child_process: 284:19)
at onErrorNT (node: internal/child_process:477:16)
at process.processTicksAndRejections (node: internal/process/task_queues:82:21)
- Dependencies not installed. Run
npm ci
sqd typegen
TYPEGEN
Error: spawn squid-evm-typegen ENOENT
Code: ENOENT
- Rate-limiting. Get a private RPC endpoint from any node provider, then change the
rpcUrl
inprocessor.ts
will pause new requests for 20000ms {"rpcUrl":"https://rpc.ankr.com/eth",
"reason" : "HttpError: got 429 from https://rpc.ankr.com/eth"}
If necessary, rate limit your RPC queries.
- Batch saving
let transfers: Transfers[] = [];
...
ctx.store.save(transfers);
- Using map instead of array to avoid duplicate values
let transfers: Map<string, Transfer> = new Map();
...
ctx.store.upsert([...transfers.values()]);
- Verify both log addresses and topics before processing events.
if (log.topics[0] === erc721.events.Transfer.topic && log.address === CONTRACT_ADDRESS) {
...
}