From cf69e4df3139a96bcdd736d3f1da52d76a1ba6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enol=20=C3=81lvarez?= Date: Tue, 19 Mar 2024 14:14:42 +0100 Subject: [PATCH] WIP --- docs/new/develop/init-project.md | 49 +++++++++++++++++++++++++++ docs/reference-and-specs/manifests.md | 33 ++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/docs/new/develop/init-project.md b/docs/new/develop/init-project.md index 2dcf5e90e..0797a1b7c 100644 --- a/docs/new/develop/init-project.md +++ b/docs/new/develop/init-project.md @@ -25,5 +25,54 @@ The `substreams init` command also offers you the possibility to easily track a Initialize a Substreams project {% endembed %} +The following is the `substreams init` execution to create a Substreams that tracks new pools created from the UniswapV3 factory contract. + +```bash +✔ Project name (lowercase, numbers, undescores): uniswapv3_factory +Protocol: Ethereum +Ethereum chain: Mainnet +Contract address to track (leave empty to use "Bored Ape Yacht Club"): 0x1f98431c8ad98523631ae4a59f267346ea31f984 +Would you like to track another contract? (Leave empty if not): +Tracking 1 contract(s), let's define a short name for each contract +Choose a short name for 1f98431c8ad98523631ae4a59f267346ea31f984 (lowercase and numbers only): factory +✔ Events only +Retrieving Ethereum Mainnet contract information (ABI & creation block) +Fetched contract ABI for 1f98431c8ad98523631ae4a59f267346ea31f984 +Fetched initial block 12369621 for 1f98431c8ad98523631ae4a59f267346ea31f984 (lowest 12369621) +Generating ABI Event models for factory + Generating ABI Events for FeeAmountEnabled (fee,tickSpacing) + Generating ABI Events for OwnerChanged (oldOwner,newOwner) + Generating ABI Events for PoolCreated (token0,token1,fee,tickSpacing,pool) +Track a dynamic datasource: y +Select the event on the factory that triggers the creation of a dynamic datasource: +Event: PoolCreated +Select the field on the factory event that provides the address of the dynamic datasource: +Field: pool +Choose a short name for the created datasource, (lowercase and numbers only): pool +✔ Events only +Enter a reference contract address to fetch the ABI: 0xc2e9f25be6257c210d7adf0d4cd6e3e881ba25f8 +adding dynamic datasource pool PoolCreated pool + Generating ABI Events for Burn (owner,tickLower,tickUpper,amount,amount0,amount1) + Generating ABI Events for Collect (owner,recipient,tickLower,tickUpper,amount0,amount1) + Generating ABI Events for CollectProtocol (sender,recipient,amount0,amount1) + Generating ABI Events for Flash (sender,recipient,amount0,amount1,paid0,paid1) + Generating ABI Events for IncreaseObservationCardinalityNext (observationCardinalityNextOld,observationCardinalityNextNew) + Generating ABI Events for Initialize (sqrtPriceX96,tick) + Generating ABI Events for Mint (sender,owner,tickLower,tickUpper,amount,amount0,amount1) + Generating ABI Events for SetFeeProtocol (feeProtocol0Old,feeProtocol1Old,feeProtocol0New,feeProtocol1New) + Generating ABI Events for Swap (sender,recipient,amount0,amount1,sqrtPriceX96,liquidity,tick) +Writing project files +Generating Protobuf Rust code +Project "uniswapv3_factory" initialized at "/Users/enolalvarezdeprado/Documents/projects/substreams/dsds/test" + +Run 'make build' to build the wasm code. + +The following substreams.yaml files have been created with different sink targets: + * substreams.yaml: no sink target + * substreams.sql.yaml: PostgreSQL sink + * substreams.clickhouse.yaml: Clickhouse sink + * substreams.subgraph.yaml: Sink into Substreams-based subgraph +``` + {% endtab %} {% endtabs %} \ No newline at end of file diff --git a/docs/reference-and-specs/manifests.md b/docs/reference-and-specs/manifests.md index ace3e6372..f02bd8590 100644 --- a/docs/reference-and-specs/manifests.md +++ b/docs/reference-and-specs/manifests.md @@ -257,6 +257,39 @@ There are two module types for `modules[].kind`: * `map` * `store` +#### Module `use` + +The `use` parameter allows you to define a new module by reusing the function of another module. For example, consider that you have a module called `db_out` that emits the `DatabaseChanges` Protobuf. You want to create another module that maps the `DatabaseChanges` to `EntityChanges`, but you don't want to code it yourself; instead you use a module that is already written. + +```yaml +specVersion: v0.1.0 +package: + name: byac + version: v0.1.0 + +imports: + converter: https://spkg.io/streamingfast/substreams-db-graph-converter-v0.1.0.spkg + +modules: +... + - name: db_out + kind: map + initialBlock: 12287507 + inputs: + - map: map_events + output: + type: proto:sf.substreams.sink.database.v1.DatabaseChanges + + - name: graph_out + use: converter:dbout_to_graphout + inputs: + - map: db_out +``` + +In the previous example, the `map_events` module emits `DatabaseChanges`. The `graph_out` module converts `DatabaseChanges` to `EntityChanges`, by defining using an already written module (`use: converter:dbout_to_graphout`). + +The converter module **must** accept the same input as the one defined in the `inputs` section (in the previous example, `DatabaseChanges`). + #### Module `updatePolicy` Specifies the merge strategy for two contiguous partial stores produced by parallelized operations.