Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
enoldev committed Mar 19, 2024
1 parent fe4908b commit cf69e4d
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
49 changes: 49 additions & 0 deletions docs/new/develop/init-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
33 changes: 33 additions & 0 deletions docs/reference-and-specs/manifests.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cf69e4d

Please sign in to comment.