remove: maverick (moved)

This commit is contained in:
0xMochan
2024-05-09 11:27:40 -05:00
parent 16b9bac3ce
commit df3508f05d
21 changed files with 0 additions and 9289 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +0,0 @@
[package]
name = "substreams-maverick"
version = "0.1.0"
edition = "2021"
[lib]
name = "substreams_maverick"
crate-type = ["cdylib"]
[dependencies]
substreams.workspace = true
substreams-ethereum.workspace = true
prost.workspace = true
prost-types.workspace = true
hex-literal.workspace = true
ethabi.workspace = true
hex.workspace = true
bytes = "1.5.0"
anyhow = "1.0.75"
num-bigint = "0.4.4"
itertools = "0.12.0"
tycho-substreams.workspace = true
[build-dependencies]
anyhow = "1"
substreams-ethereum = "0.9"
# Required so that ethabi > ethereum-types build correctly under wasm32-unknown-unknown
[target.wasm32-unknown-unknown.dependencies]
getrandom = { version = "0.2", features = ["custom"] }

View File

@@ -1,22 +0,0 @@
# ABIs
`get_abis.py` is a simple python script using the etherscan API (free plan) to gather ABIs for all of the contracts we are tracking!
We then can define all of the abis via `substreams_ethereum::Abigen::new` in our `build.rs`.
## Recommendation
It would be apt to convert (maybe through copilot) the python code into the `build.rs` file and then automate the `Abigen` functionality.
## Usage
Requires `python 3.8+`,
```bash
cd abi
python get_abis.py
```
This will populate the files in the `abi` folder.
When the `build.rs` file runs (when `rust-analyzer` activates or `cargo build` is manually ran), Abigen will generate new rust src files from the abis in the `src/abi` folder.

View File

@@ -1,224 +0,0 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "poolAddress",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "fee",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "tickSpacing",
"type": "uint256"
},
{
"indexed": false,
"internalType": "int32",
"name": "activeTick",
"type": "int32"
},
{
"indexed": false,
"internalType": "int256",
"name": "lookback",
"type": "int256"
},
{
"indexed": false,
"internalType": "uint64",
"name": "protocolFeeRatio",
"type": "uint64"
},
{
"indexed": false,
"internalType": "contract IERC20",
"name": "tokenA",
"type": "address"
},
{
"indexed": false,
"internalType": "contract IERC20",
"name": "tokenB",
"type": "address"
}
],
"name": "PoolCreated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "SetFactoryOwner",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint64",
"name": "protocolFeeRatio",
"type": "uint64"
}
],
"name": "SetFactoryProtocolFeeRatio",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_fee",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_tickSpacing",
"type": "uint256"
},
{
"internalType": "int256",
"name": "_lookback",
"type": "int256"
},
{
"internalType": "int32",
"name": "_activeTick",
"type": "int32"
},
{
"internalType": "contract IERC20",
"name": "_tokenA",
"type": "address"
},
{
"internalType": "contract IERC20",
"name": "_tokenB",
"type": "address"
}
],
"name": "create",
"outputs": [
{
"internalType": "contract IPool",
"name": "",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract IPool",
"name": "pool",
"type": "address"
}
],
"name": "isFactoryPool",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "fee",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "tickSpacing",
"type": "uint256"
},
{
"internalType": "int256",
"name": "lookback",
"type": "int256"
},
{
"internalType": "contract IERC20",
"name": "tokenA",
"type": "address"
},
{
"internalType": "contract IERC20",
"name": "tokenB",
"type": "address"
}
],
"name": "lookup",
"outputs": [
{
"internalType": "contract IPool",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "position",
"outputs": [
{
"internalType": "contract IPosition",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "protocolFeeRatio",
"outputs": [
{
"internalType": "uint64",
"name": "",
"type": "uint64"
}
],
"stateMutability": "view",
"type": "function"
}
]

View File

@@ -1,48 +0,0 @@
#!/usr/bin/python
import json
import os
import re
import time
import urllib.request
# Exports contract ABI in JSON
abis = {
# Factories
"CryptoSwapRegistry": "0x9a32aF1A11D9c937aEa61A3790C2983257eA8Bc0",
"MainRegistry": "0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5",
"MetaPoolFactory": "0xB9fC157394Af804a3578134A6585C0dc9cc990d4",
"CryptoPoolFactory": "0xF18056Bbd320E96A48e3Fbf8bC061322531aac99",
# pool
"Pool": "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7",
}
ABI_ENDPOINT = (
"https://api.etherscan.io/api?module=contract&action=getabi&address={address}"
)
if etherscan_key := os.environ.get("ETHERSCAN_API_TOKEN"):
print("API KEY Loaded!")
ABI_ENDPOINT += f"&apikey={etherscan_key}"
def __main__():
for name, addr in abis.items():
normalized_name = "_".join(re.findall(r"[A-Z]+[a-z]*", name)).lower()
print(f"Getting ABI for {name} at {addr} ({normalized_name})")
try:
with urllib.request.urlopen(ABI_ENDPOINT.format(address=addr)) as response:
response_json = json.loads(response.read().decode())
abi_json = json.loads(response_json["result"])
result = json.dumps(abi_json, indent=4, sort_keys=True)
with open(f"{normalized_name}.json", "w") as f:
f.write(result)
except Exception as err:
print(response.content)
raise err
time.sleep(0.25)
if __name__ == "__main__":
__main__()

View File

@@ -1,955 +0,0 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "deltaA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "deltaB",
"type": "uint128"
},
{
"internalType": "uint256",
"name": "deltaLpBalance",
"type": "uint256"
},
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "lowerTick",
"type": "int32"
},
{
"internalType": "bool",
"name": "isActive",
"type": "bool"
}
],
"indexed": false,
"internalType": "struct IPool.BinDelta[]",
"name": "binDeltas",
"type": "tuple[]"
}
],
"name": "AddLiquidity",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"indexed": false,
"internalType": "uint128",
"name": "reserveA",
"type": "uint128"
},
{
"indexed": false,
"internalType": "uint128",
"name": "reserveB",
"type": "uint128"
},
{
"indexed": false,
"internalType": "uint128",
"name": "mergeId",
"type": "uint128"
}
],
"name": "BinMerged",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"indexed": false,
"internalType": "int128",
"name": "previousTick",
"type": "int128"
},
{
"indexed": false,
"internalType": "int128",
"name": "newTick",
"type": "int128"
}
],
"name": "BinMoved",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"indexed": false,
"internalType": "uint32",
"name": "maxRecursion",
"type": "uint32"
}
],
"name": "MigrateBinsUpStack",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "protocolFee",
"type": "uint256"
},
{
"indexed": false,
"internalType": "bool",
"name": "isTokenA",
"type": "bool"
}
],
"name": "ProtocolFeeCollected",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "deltaA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "deltaB",
"type": "uint128"
},
{
"internalType": "uint256",
"name": "deltaLpBalance",
"type": "uint256"
},
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "lowerTick",
"type": "int32"
},
{
"internalType": "bool",
"name": "isActive",
"type": "bool"
}
],
"indexed": false,
"internalType": "struct IPool.BinDelta[]",
"name": "binDeltas",
"type": "tuple[]"
}
],
"name": "RemoveLiquidity",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "protocolFee",
"type": "uint256"
}
],
"name": "SetProtocolFeeRatio",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "tokenAIn",
"type": "bool"
},
{
"indexed": false,
"internalType": "bool",
"name": "exactOutput",
"type": "bool"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
},
{
"indexed": false,
"internalType": "int32",
"name": "activeTick",
"type": "int32"
}
],
"name": "Swap",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "fromTokenId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "toTokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "amount",
"type": "uint128"
}
],
"indexed": false,
"internalType": "struct IPool.RemoveLiquidityParams[]",
"name": "params",
"type": "tuple[]"
}
],
"name": "TransferLiquidity",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "pos",
"type": "int32"
},
{
"internalType": "bool",
"name": "isDelta",
"type": "bool"
},
{
"internalType": "uint128",
"name": "deltaA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "deltaB",
"type": "uint128"
}
],
"internalType": "struct IPool.AddLiquidityParams[]",
"name": "params",
"type": "tuple[]"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "addLiquidity",
"outputs": [
{
"internalType": "uint256",
"name": "tokenAAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "tokenBAmount",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "deltaA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "deltaB",
"type": "uint128"
},
{
"internalType": "uint256",
"name": "deltaLpBalance",
"type": "uint256"
},
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "lowerTick",
"type": "int32"
},
{
"internalType": "bool",
"name": "isActive",
"type": "bool"
}
],
"internalType": "struct IPool.BinDelta[]",
"name": "binDeltas",
"type": "tuple[]"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "lpToken",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "binBalanceA",
"outputs": [
{
"internalType": "uint128",
"name": "",
"type": "uint128"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "binBalanceB",
"outputs": [
{
"internalType": "uint128",
"name": "",
"type": "uint128"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "int32",
"name": "tick",
"type": "int32"
}
],
"name": "binMap",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "int32",
"name": "tick",
"type": "int32"
},
{
"internalType": "uint256",
"name": "kind",
"type": "uint256"
}
],
"name": "binPositions",
"outputs": [
{
"internalType": "uint128",
"name": "",
"type": "uint128"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "factory",
"outputs": [
{
"internalType": "contract IFactory",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "fee",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "lookback",
"outputs": [
{
"internalType": "int256",
"name": "",
"type": "int256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
}
],
"name": "getBin",
"outputs": [
{
"components": [
{
"internalType": "uint128",
"name": "reserveA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "reserveB",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "mergeBinBalance",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "mergeId",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "totalSupply",
"type": "uint128"
},
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "lowerTick",
"type": "int32"
}
],
"internalType": "struct IPool.BinState",
"name": "bin",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentTwa",
"outputs": [
{
"internalType": "int256",
"name": "",
"type": "int256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getState",
"outputs": [
{
"components": [
{
"internalType": "int32",
"name": "activeTick",
"type": "int32"
},
{
"internalType": "uint8",
"name": "status",
"type": "uint8"
},
{
"internalType": "uint128",
"name": "binCounter",
"type": "uint128"
},
{
"internalType": "uint64",
"name": "protocolFeeRatio",
"type": "uint64"
}
],
"internalType": "struct IPool.State",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getTwa",
"outputs": [
{
"components": [
{
"internalType": "int96",
"name": "twa",
"type": "int96"
},
{
"internalType": "int96",
"name": "value",
"type": "int96"
},
{
"internalType": "uint64",
"name": "lastTimestamp",
"type": "uint64"
}
],
"internalType": "struct IPool.TwaState",
"name": "",
"type": "tuple"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint32",
"name": "maxRecursion",
"type": "uint32"
}
],
"name": "migrateBinUpStack",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "amount",
"type": "uint128"
}
],
"internalType": "struct IPool.RemoveLiquidityParams[]",
"name": "params",
"type": "tuple[]"
}
],
"name": "removeLiquidity",
"outputs": [
{
"internalType": "uint256",
"name": "tokenAOut",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "tokenBOut",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "deltaA",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "deltaB",
"type": "uint128"
},
{
"internalType": "uint256",
"name": "deltaLpBalance",
"type": "uint256"
},
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint8",
"name": "kind",
"type": "uint8"
},
{
"internalType": "int32",
"name": "lowerTick",
"type": "int32"
},
{
"internalType": "bool",
"name": "isActive",
"type": "bool"
}
],
"internalType": "struct IPool.BinDelta[]",
"name": "binDeltas",
"type": "tuple[]"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "recipient",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
},
{
"internalType": "bool",
"name": "tokenAIn",
"type": "bool"
},
{
"internalType": "bool",
"name": "exactOutput",
"type": "bool"
},
{
"internalType": "uint256",
"name": "sqrtPriceLimit",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "swap",
"outputs": [
{
"internalType": "uint256",
"name": "amountIn",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "amountOut",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "tickSpacing",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tokenA",
"outputs": [
{
"internalType": "contract IERC20",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tokenAScale",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tokenB",
"outputs": [
{
"internalType": "contract IERC20",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "tokenBScale",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "fromTokenId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "toTokenId",
"type": "uint256"
},
{
"components": [
{
"internalType": "uint128",
"name": "binId",
"type": "uint128"
},
{
"internalType": "uint128",
"name": "amount",
"type": "uint128"
}
],
"internalType": "struct IPool.RemoveLiquidityParams[]",
"name": "params",
"type": "tuple[]"
}
],
"name": "transferLiquidity",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]

View File

@@ -1,12 +0,0 @@
version: v1
plugins:
- plugin: buf.build/community/neoeinstein-prost:v0.2.2
out: src/pb
opt:
- file_descriptor_set=false
- plugin: buf.build/community/neoeinstein-prost-crate:v0.3.1
out: src/pb
opt:
- no_features

View File

@@ -1,43 +0,0 @@
use anyhow::Result;
use std::{fs, io::Write};
use substreams_ethereum::Abigen;
fn main() -> Result<()> {
let abi_folder = "abi";
let output_folder = "src/abi";
let files = fs::read_dir(abi_folder)?;
let mut mod_rs_content = String::new();
for file in files {
let file = file?;
let file_name = file.file_name();
let file_name = file_name.to_string_lossy();
if !file_name.ends_with(".json") {
continue;
}
let contract_name = file_name.split('.').next().unwrap();
let input_path = format!("{}/{}", abi_folder, file_name);
let output_path = format!("{}/{}.rs", output_folder, contract_name);
mod_rs_content.push_str(&format!("pub mod {};\n", contract_name));
if std::path::Path::new(&output_path).exists() {
continue;
}
Abigen::new(contract_name, &input_path)?
.generate()?
.write_to_file(&output_path)?;
}
let mod_rs_path = format!("{}/mod.rs", output_folder);
let mut mod_rs_file = fs::File::create(mod_rs_path)?;
mod_rs_file.write_all(mod_rs_content.as_bytes())?;
Ok(())
}

View File

@@ -1,19 +0,0 @@
syntax = "proto3";
package eth.factory.v1;
message Pools {
repeated Pool pools = 1;
}
message Pool {
bytes pool_id = 1;
fixed64 log_ordinal = 2;
}
message Transfer {
bytes from = 1;
bytes to = 2;
string token = 3;
string amount = 4;
}

View File

@@ -1,15 +0,0 @@
syntax = "proto3";
package eth.pool.v1;
message Transfers {
repeated Transfer transfers = 1;
}
message Transfer {
string from = 1;
string to = 2;
uint64 token_id = 3;
string trx_hash = 4;
uint64 ordinal = 5;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +0,0 @@
pub mod factory;
pub mod pool;

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +0,0 @@
mod abi;
mod modules;
mod pb;

View File

@@ -1,456 +0,0 @@
use std::collections::HashMap;
use anyhow::Result;
use substreams::{
pb::substreams::StoreDeltas,
store::{
StoreAdd, StoreAddBigInt, StoreAddInt64, StoreGet, StoreGetInt64, StoreGetString, StoreNew,
StoreSet, StoreSetString,
},
};
use substreams::{hex, key, scalar::BigInt};
use substreams_ethereum::{block_view::LogView, pb::eth};
use itertools::Itertools;
use substreams_ethereum::Event;
use crate::abi;
use tycho_substreams::{
balances::store_balance_changes, contract::extract_contract_changes, prelude::*,
};
const FACTORY: [u8; 20] = hex!("Eb6625D65a0553c9dBc64449e56abFe519bd9c9B");
// struct BinDelta {
// delta_a: BigInt,
// delta_b: BigInt,
// delta_lp_balance: BigInt,
// bin_id: BigInt,
// kind: BigInt,
// lower_tick: BigInt,
// is_active: bool,
// }
/// This struct purely exists to spoof the `PartialEq` trait for `Transaction` so we can use it in
/// a later groupby operation.
#[derive(Debug)]
struct TransactionWrapper(Transaction);
impl PartialEq for TransactionWrapper {
fn eq(&self, other: &Self) -> bool {
self.0.hash == other.0.hash
}
}
fn tx_from_log(log: &LogView) -> Transaction {
Transaction {
hash: log.receipt.transaction.hash.clone(),
from: log.receipt.transaction.from.clone(),
to: log.receipt.transaction.to.clone(),
index: Into::<u64>::into(log.receipt.transaction.index),
}
}
#[substreams::handlers::map]
pub fn map_components(block: eth::v2::Block) -> Result<BlockTransactionProtocolComponents> {
// Gather contract changes by indexing `PoolCreated` events and analysing the `Create` call
// We store these as a hashmap by tx hash since we need to agg by tx hash later
Ok(BlockTransactionProtocolComponents {
tx_components: block
.transactions()
.filter_map(|tx| {
let components: Vec<ProtocolComponent> = tx
.logs_with_calls()
.filter(|(_, call)| !call.call.state_reverted)
.filter(|(log, _)| log.address == FACTORY)
.filter_map(|(log, _)| {
let pool_added = abi::factory::events::PoolCreated::match_and_decode(log)?;
Some(ProtocolComponent {
id: hex::encode(&pool_added.pool_address),
tx: Some(Transaction {
hash: tx.hash.clone(),
from: tx.from.clone(),
to: tx.to.clone(),
index: Into::<u64>::into(tx.index),
}),
tokens: vec![pool_added.token_a, pool_added.token_b],
contracts: vec![FACTORY.into(), pool_added.pool_address],
static_att: vec![
Attribute {
name: "activeTick".into(),
value: pool_added
.active_tick
.to_signed_bytes_be(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "lookback".into(),
value: pool_added.lookback.to_signed_bytes_be(),
change: ChangeType::Creation.into(),
},
],
change: ChangeType::Creation.into(),
protocol_type: Some(ProtocolType {
name: "maverick_pool".into(),
financial_type: FinancialType::Swap.into(),
attribute_schema: Vec::new(),
implementation_type: ImplementationType::Vm.into(),
}),
})
})
.collect::<Vec<_>>();
if !components.is_empty() {
Some(TransactionProtocolComponents {
tx: Some(Transaction {
hash: tx.hash.clone(),
from: tx.from.clone(),
to: tx.to.clone(),
index: Into::<u64>::into(tx.index),
}),
components,
})
} else {
None
}
})
.collect::<Vec<_>>(),
})
}
/// Simply stores the `ProtocolComponent`s with the pool id as the key
#[substreams::handlers::store]
pub fn store_components(map: BlockTransactionProtocolComponents, store: StoreAddInt64) {
store.add_many(
0,
&map.tx_components
.iter()
.flat_map(|tx_components| &tx_components.components)
.map(|component| format!("pool:{0}", component.id))
.collect::<Vec<_>>(),
1,
);
}
/// Simply stores the `ProtocolComponent`s with the pool id as the key
#[substreams::handlers::store]
pub fn store_component_tokens(map: BlockTransactionProtocolComponents, store: StoreSetString) {
map.tx_components
.iter()
.flat_map(|tx_components| &tx_components.components)
.for_each(|component| {
store.set(
0,
format!("pool:{0}", component.id),
&component
.tokens
.iter()
.map(|token| hex::encode(token))
.join(":".into()),
);
});
}
/// Since the `Swap`, `AddLiquidity`, `RemoveLiuidity` events administer only deltas, we need to
/// leverage a map and a store to be able to tally up final balances for tokens in a pool.
#[substreams::handlers::map]
pub fn map_relative_balances(
block: eth::v2::Block,
pools_store: StoreGetInt64,
tokens_store: StoreGetString,
) -> Result<BlockBalanceDeltas, anyhow::Error> {
let deltas = block
.logs()
.filter(|log| {
pools_store
.get_last(format!("pool:{0}", hex::encode(&log.address())))
.is_some()
})
.flat_map(|log| {
if let Some(event) = abi::pool::events::Swap::match_and_decode(log) {
let tokens = tokens_store
.get_last(format!("pool:{}", hex::encode(log.address())))
.unwrap()
.split(":")
.map(|token| token.to_owned()) // Clone the tokens
.collect::<Vec<_>>();
let (token_a, token_b) = if event.token_a_in {
(
hex::decode(tokens[0].clone()).unwrap(),
hex::decode(tokens[1].clone()).unwrap(),
)
} else {
(
hex::decode(tokens[1].clone()).unwrap(),
hex::decode(tokens[0].clone()).unwrap(),
)
};
vec![
BalanceDelta {
ord: log.log.ordinal,
tx: Some(tx_from_log(&log)),
token: token_a,
delta: event.amount_in.to_signed_bytes_be(),
component_id: log.address().into(),
},
BalanceDelta {
ord: log.log.ordinal,
tx: Some(tx_from_log(&log)),
token: token_b,
delta: event.amount_out.to_signed_bytes_be(),
component_id: log.address().into(),
},
]
} else if let Some(event) = abi::pool::events::AddLiquidity::match_and_decode(log) {
event
.bin_deltas
.into_iter()
.flat_map(
|(
delta_a,
delta_b,
delta_lp_balance,
bin_id,
kind,
lower_tick,
is_active,
)| {
let tokens = tokens_store
.get_last(format!("pool:{}", hex::encode(log.address())))
.unwrap()
.split(":")
.map(|token| token.to_owned()) // Clone the tokens
.collect::<Vec<_>>();
vec![
BalanceDelta {
ord: log.log.ordinal,
tx: Some(tx_from_log(&log)),
token: hex::decode(tokens[0].clone()).unwrap(),
delta: delta_a.to_signed_bytes_be(),
component_id: log.address().into(),
},
BalanceDelta {
ord: log.log.ordinal,
tx: Some(tx_from_log(&log)),
token: hex::decode(tokens[1].clone()).unwrap(),
delta: delta_b.to_signed_bytes_be(),
component_id: log.address().into(),
},
]
},
)
.collect::<Vec<_>>()
} else if let Some(event) = abi::pool::events::RemoveLiquidity::match_and_decode(log) {
event
.bin_deltas
.into_iter()
.flat_map(
|(
delta_a,
delta_b,
delta_lp_balance,
bin_id,
kind,
lower_tick,
is_active,
)| {
let tokens = tokens_store
.get_last(format!("pool:{}", hex::encode(log.address())))
.unwrap()
.split(":")
.map(|token| token.to_owned()) // Clone the tokens
.collect::<Vec<_>>();
let neg_delta_a: BigInt = delta_a * -1;
let neg_delta_b: BigInt = delta_b * -1;
vec![
BalanceDelta {
ord: log.log.ordinal,
tx: Some(tx_from_log(&log)),
token: hex::decode(tokens[0].clone()).unwrap(),
delta: neg_delta_a.to_signed_bytes_be(),
component_id: log.address().into(),
},
BalanceDelta {
ord: log.log.ordinal,
tx: Some(tx_from_log(&log)),
token: hex::decode(tokens[1].clone()).unwrap(),
delta: neg_delta_b.to_signed_bytes_be(),
component_id: log.address().into(),
},
]
},
)
.collect::<Vec<_>>()
} else {
vec![]
}
})
.collect::<Vec<_>>();
Ok(BlockBalanceDeltas { balance_deltas: deltas })
}
/// It's significant to include both the `pool_id` and the `token_id` for each balance delta as the
/// store key to ensure that there's a unique balance being tallied for each.
#[substreams::handlers::store]
pub fn store_balances(deltas: BlockBalanceDeltas, store: StoreAddBigInt) {
store_balance_changes(deltas, store)
}
/// This is the main map that handles most of the indexing of this substream.
/// Every contract change is grouped by transaction index via the `transaction_contract_changes`
/// map. Each block of code will extend the `TransactionContractChanges` struct with the
/// cooresponding changes (balance, component, contract), inserting a new one if it doesn't exist.
/// At the very end, the map can easily be sorted by index to ensure the final
/// `BlockContractChanges` is ordered by transactions properly.
#[substreams::handlers::map]
pub fn map_protocol_changes(
block: eth::v2::Block,
grouped_components: BlockTransactionProtocolComponents,
deltas: BlockBalanceDeltas,
components_store: StoreGetInt64,
balance_store: StoreDeltas, // Note, this map module is using the `deltas` mode for the store.
) -> Result<BlockContractChanges> {
// We merge contract changes by transaction (identified by transaction index) making it easy to
// sort them at the very end.
let mut transaction_contract_changes: HashMap<_, TransactionContractChanges> = HashMap::new();
// `ProtocolComponents` are gathered from `map_pools_created` which just need a bit of work to
// convert into `TransactionContractChanges`
grouped_components
.tx_components
.iter()
.for_each(|tx_component| {
let tx = tx_component.tx.as_ref().unwrap();
transaction_contract_changes
.entry(tx.index)
.or_insert_with(|| TransactionContractChanges {
tx: Some(tx.clone()),
contract_changes: vec![],
component_changes: vec![],
balance_changes: vec![],
})
.component_changes
.extend_from_slice(&tx_component.components);
});
// Balance changes are gathered by the `StoreDelta` based on transfer and liquidity events
// creating `BalanceDeltas`. We essentially just process the changes that occured to the
// `store` this block. Then, these balance changes are merged onto the existing map of
// tx contract changes, inserting a new one if it doesn't exist.
balance_store
.deltas
.into_iter()
.zip(deltas.balance_deltas)
.map(|(store_delta, balance_delta)| {
let pool_id = key::segment_at(&store_delta.key, 1);
let token_id = key::segment_at(&store_delta.key, 3);
(
balance_delta.tx.unwrap(),
BalanceChange {
token: hex::decode(token_id).expect("Token ID not valid hex"),
balance: store_delta.new_value,
component_id: hex::decode(pool_id).expect("Token ID not valid hex"),
},
)
})
// We need to group the balance changes by tx hash for the `TransactionContractChanges` agg
.group_by(|(tx, _)| TransactionWrapper(tx.clone()))
.into_iter()
.for_each(|(tx_wrapped, group)| {
let tx = tx_wrapped.0;
transaction_contract_changes
.entry(tx.index)
.or_insert_with(|| TransactionContractChanges {
tx: Some(tx.clone()),
contract_changes: vec![],
component_changes: vec![],
balance_changes: vec![],
})
.balance_changes
.extend(group.map(|(_, change)| change));
});
// General helper for extracting contract changes. Uses block, our component store which holds
// all of our tracked deployed pool addresses, and the map of tx contract changes which we
// output into for final processing later.
extract_contract_changes(
&block,
|addr| {
components_store
.get_last(format!("pool:0x{0}", hex::encode(addr)))
.is_some()
},
&mut transaction_contract_changes,
);
// Process all `transaction_contract_changes` for final output in the `BlockContractChanges`,
// sorted by transaction index (the key).
Ok(BlockContractChanges {
block: Some(Block {
number: block.number,
hash: block.hash.clone(),
parent_hash: block
.header
.as_ref()
.expect("Block header not present")
.parent_hash
.clone(),
ts: block.timestamp_seconds(),
}),
changes: transaction_contract_changes
.drain()
.sorted_unstable_by_key(|(index, _)| index.clone())
.filter_map(|(_, change)| {
if change.contract_changes.is_empty() &&
change.component_changes.is_empty() &&
change.balance_changes.is_empty()
{
None
} else {
Some(change)
}
})
.collect::<Vec<_>>(),
})
}
// #[substreams::handlers::map]
// pub fn debug_block_events(block: eth::v2::Block) -> Result<BlockContractChanges> {
// log::info!("Block: {:?}", block);
// Ok(BlockContractChanges {
// block: Some(Block {
// number: block.number,
// hash: block.hash.clone(),
// parent_hash: block
// .header
// .as_ref()
// .expect("Block header not present")
// .parent_hash
// .clone(),
// ts: block.timestamp_seconds(),
// }),
// changes: transaction_contract_changes
// .drain()
// .sorted_unstable_by_key(|(index, _)| index.clone())
// .filter_map(|(_, change)| {
// if change.contract_changes.is_empty()
// && change.component_changes.is_empty()
// && change.balance_changes.is_empty()
// {
// None
// } else {
// Some(change)
// }
// })
// .collect::<Vec<_>>(),
// })
// }

View File

@@ -1,28 +0,0 @@
// @generated
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Pools {
#[prost(message, repeated, tag="1")]
pub pools: ::prost::alloc::vec::Vec<Pool>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Pool {
#[prost(bytes="vec", tag="1")]
pub pool_id: ::prost::alloc::vec::Vec<u8>,
#[prost(fixed64, tag="2")]
pub log_ordinal: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Transfer {
#[prost(bytes="vec", tag="1")]
pub from: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes="vec", tag="2")]
pub to: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag="3")]
pub token: ::prost::alloc::string::String,
#[prost(string, tag="4")]
pub amount: ::prost::alloc::string::String,
}
// @@protoc_insertion_point(module)

View File

@@ -1,28 +0,0 @@
// @generated
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Pools {
#[prost(message, repeated, tag="1")]
pub pools: ::prost::alloc::vec::Vec<Pool>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Pool {
#[prost(bytes="vec", tag="1")]
pub pool_id: ::prost::alloc::vec::Vec<u8>,
#[prost(fixed64, tag="2")]
pub log_ordinal: u64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Transfer {
#[prost(bytes="vec", tag="1")]
pub from: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes="vec", tag="2")]
pub to: ::prost::alloc::vec::Vec<u8>,
#[prost(string, tag="3")]
pub token: ::prost::alloc::string::String,
#[prost(string, tag="4")]
pub amount: ::prost::alloc::string::String,
}
// @@protoc_insertion_point(module)

View File

@@ -1,22 +0,0 @@
// @generated
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Transfers {
#[prost(message, repeated, tag="1")]
pub transfers: ::prost::alloc::vec::Vec<Transfer>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Transfer {
#[prost(string, tag="1")]
pub from: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub to: ::prost::alloc::string::String,
#[prost(uint64, tag="3")]
pub token_id: u64,
#[prost(string, tag="4")]
pub trx_hash: ::prost::alloc::string::String,
#[prost(uint64, tag="5")]
pub ordinal: u64,
}
// @@protoc_insertion_point(module)

View File

@@ -1,10 +0,0 @@
// @generated
pub mod tycho {
pub mod evm {
// @@protoc_insertion_point(attribute:tycho.evm.v1)
pub mod v1 {
include!("tycho.evm.v1.rs");
// @@protoc_insertion_point(tycho.evm.v1)
}
}
}

View File

@@ -1,236 +0,0 @@
// @generated
// This file contains the proto definitions for Substreams common to all integrations.
/// A struct describing a block.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Block {
/// The blocks hash.
#[prost(bytes="vec", tag="1")]
pub hash: ::prost::alloc::vec::Vec<u8>,
/// The parent blocks hash.
#[prost(bytes="vec", tag="2")]
pub parent_hash: ::prost::alloc::vec::Vec<u8>,
/// The block number.
#[prost(uint64, tag="3")]
pub number: u64,
/// The block timestamp.
#[prost(uint64, tag="4")]
pub ts: u64,
}
/// A struct describing a transaction.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Transaction {
/// The transaction hash.
#[prost(bytes="vec", tag="1")]
pub hash: ::prost::alloc::vec::Vec<u8>,
/// The sender of the transaction.
#[prost(bytes="vec", tag="2")]
pub from: ::prost::alloc::vec::Vec<u8>,
/// The receiver of the transaction.
#[prost(bytes="vec", tag="3")]
pub to: ::prost::alloc::vec::Vec<u8>,
/// The transactions index within the block.
/// TODO: should this be uint32? to match the type from the native substream type?
#[prost(uint64, tag="4")]
pub index: u64,
}
/// A custom struct representing an arbitrary attribute of a protocol component.
/// This is mainly used by the native integration to track the necessary information about the protocol.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Attribute {
/// The name of the attribute.
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
/// The value of the attribute.
#[prost(bytes="vec", tag="2")]
pub value: ::prost::alloc::vec::Vec<u8>,
/// The type of change the attribute underwent.
#[prost(enumeration="ChangeType", tag="3")]
pub change: i32,
}
/// A struct describing a part of the protocol.
/// Note: For example this can be a UniswapV2 pair, that tracks the two ERC20 tokens used by the pair,
/// the component would represent a single contract. In case of VM integration, such component would
/// not need any attributes, because all the relevant info would be tracked via storage slots and balance changes.
/// It can also be a wrapping contract, like WETH, that has a constant price, but it allows swapping tokens.
/// This is why the name ProtocolComponent is used instead of "Pool" or "Pair".
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProtocolComponent {
/// A unique identifier for the component within the protocol.
/// Can be e.g. a stringified address or a string describing the trading pair.
#[prost(string, tag="1")]
pub id: ::prost::alloc::string::String,
/// Addresses of the ERC20 tokens used by the component.
#[prost(bytes="vec", repeated, tag="2")]
pub tokens: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
/// Addresses of the contracts used by the component.
/// Usually it is a single contract, but some protocols use multiple contracts.
#[prost(bytes="vec", repeated, tag="3")]
pub contracts: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
/// Attributes of the component. Used mainly be the native integration.
/// The inner ChangeType of the attribute has to match the ChangeType of the ProtocolComponent.
#[prost(message, repeated, tag="4")]
pub static_att: ::prost::alloc::vec::Vec<Attribute>,
/// Type of change the component underwent.
#[prost(enumeration="ChangeType", tag="5")]
pub change: i32,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransactionProtocolComponents {
#[prost(message, optional, tag="1")]
pub tx: ::core::option::Option<Transaction>,
#[prost(message, repeated, tag="2")]
pub components: ::prost::alloc::vec::Vec<ProtocolComponent>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GroupedTransactionProtocolComponents {
#[prost(message, repeated, tag="1")]
pub tx_components: ::prost::alloc::vec::Vec<TransactionProtocolComponents>,
}
/// A struct for following the changes of Total Value Locked (TVL) of a protocol component.
/// Note that if a ProtocolComponent contains multiple contracts, the TVL is tracked for the component as a whole.
/// E.g. for UniswapV2 pair WETH/USDC, this tracks the USDC and WETH balance of the pair contract.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BalanceChange {
/// The address of the ERC20 token whose balance changed.
#[prost(bytes="vec", tag="1")]
pub token: ::prost::alloc::vec::Vec<u8>,
/// The new balance of the token.
#[prost(bytes="vec", tag="2")]
pub balance: ::prost::alloc::vec::Vec<u8>,
/// The id of the component whose TVL is tracked.
/// If the protocol component includes multiple contracts, the balance change must be aggregated to reflect how much tokens can be traded.
#[prost(bytes="vec", tag="3")]
pub component_id: ::prost::alloc::vec::Vec<u8>,
}
/// A struct for following the changes of Total Value Locked (TVL) of a protocol component.
/// Note that if a ProtocolComponent contains multiple contracts, the TVL is tracked for the component as a whole.
/// E.g. for UniswapV2 pair WETH/USDC, this tracks the USDC and WETH balance of the pair contract.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BalanceDelta {
#[prost(uint64, tag="1")]
pub ord: u64,
/// The tx hash of the transaction that caused the balance change.
#[prost(message, optional, tag="2")]
pub tx: ::core::option::Option<Transaction>,
/// The address of the ERC20 token whose balance changed.
#[prost(bytes="vec", tag="3")]
pub token: ::prost::alloc::vec::Vec<u8>,
/// The delta balance of the token.
#[prost(bytes="vec", tag="4")]
pub delta: ::prost::alloc::vec::Vec<u8>,
/// The id of the component whose TVL is tracked.
/// If the protocol component includes multiple contracts, the balance change must be aggregated to reflect how much tokens can be traded.
#[prost(bytes="vec", tag="5")]
pub component_id: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BalanceDeltas {
#[prost(message, repeated, tag="1")]
pub balance_deltas: ::prost::alloc::vec::Vec<BalanceDelta>,
}
/// Enum to specify the type of a change.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum ChangeType {
Unspecified = 0,
Update = 1,
Creation = 2,
Deletion = 3,
}
impl ChangeType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
ChangeType::Unspecified => "CHANGE_TYPE_UNSPECIFIED",
ChangeType::Update => "CHANGE_TYPE_UPDATE",
ChangeType::Creation => "CHANGE_TYPE_CREATION",
ChangeType::Deletion => "CHANGE_TYPE_DELETION",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"CHANGE_TYPE_UNSPECIFIED" => Some(Self::Unspecified),
"CHANGE_TYPE_UPDATE" => Some(Self::Update),
"CHANGE_TYPE_CREATION" => Some(Self::Creation),
"CHANGE_TYPE_DELETION" => Some(Self::Deletion),
_ => None,
}
}
}
// This file contains proto definitions specific to the VM integration.
/// A key value entry into contract storage.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ContractSlot {
/// A contract's storage slot.
#[prost(bytes="vec", tag="2")]
pub slot: ::prost::alloc::vec::Vec<u8>,
/// The new value for this storage slot.
#[prost(bytes="vec", tag="3")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
/// Changes made to a single contract's state.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ContractChange {
/// The contract's address
#[prost(bytes="vec", tag="1")]
pub address: ::prost::alloc::vec::Vec<u8>,
/// The new native balance of the contract, empty bytes indicates no change.
#[prost(bytes="vec", tag="2")]
pub balance: ::prost::alloc::vec::Vec<u8>,
/// The new code of the contract, empty bytes indicates no change.
#[prost(bytes="vec", tag="3")]
pub code: ::prost::alloc::vec::Vec<u8>,
/// The changes to this contract's slots, empty sequence indicates no change.
#[prost(message, repeated, tag="4")]
pub slots: ::prost::alloc::vec::Vec<ContractSlot>,
/// Whether this is an update, a creation or a deletion.
#[prost(enumeration="ChangeType", tag="5")]
pub change: i32,
}
/// A set of changes aggregated by transaction.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransactionContractChanges {
/// The transaction instance that results in the changes.
#[prost(message, optional, tag="1")]
pub tx: ::core::option::Option<Transaction>,
/// Contains the changes induced by the above transaction, aggregated on a per-contract basis.
/// Must include changes to every contract that is tracked by all ProtocolComponents.
#[prost(message, repeated, tag="2")]
pub contract_changes: ::prost::alloc::vec::Vec<ContractChange>,
/// An array of any component changes.
#[prost(message, repeated, tag="3")]
pub component_changes: ::prost::alloc::vec::Vec<ProtocolComponent>,
/// An array of balance changes to components.
#[prost(message, repeated, tag="4")]
pub balance_changes: ::prost::alloc::vec::Vec<BalanceChange>,
}
/// A set of transaction changes within a single block.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BlockContractChanges {
/// The block for which these changes are collectively computed.
#[prost(message, optional, tag="1")]
pub block: ::core::option::Option<Block>,
/// The set of transaction changes observed in the specified block.
#[prost(message, repeated, tag="2")]
pub changes: ::prost::alloc::vec::Vec<TransactionContractChanges>,
}
// @@protoc_insertion_point(module)

View File

@@ -1,73 +0,0 @@
specVersion: v0.1.0
package:
name: "substreams_maverick"
version: v0.1.0
protobuf:
files:
- tycho/evm/v1/vm.proto
- tycho/evm/v1/common.proto
importPaths:
- ../../proto
- ./proto
binaries:
default:
type: wasm/rust-v1
file: target/wasm32-unknown-unknown/release/substreams_maverick.wasm
modules:
- name: map_pools_created
kind: map
initialBlock: 17216720
inputs:
- source: sf.ethereum.type.v2.Block
output:
type: proto:tycho.evm.v1.GroupedTransactionProtocolComponents
- name: store_pools_created
kind: store
initialBlock: 17216720
updatePolicy: add
valueType: int64
inputs:
- map: map_pools_created
- name: store_pools_tokens
kind: store
initialBlock: 17216720
updatePolicy: set
valueType: string
inputs:
- map: map_pools_created
- name: map_balance_deltas
kind: map
initialBlock: 17216720 # An arbitrary block that should change based on your requirements
inputs:
- source: sf.ethereum.type.v2.Block
- store: store_pools_created
- store: store_pools_tokens
output:
type: proto:tycho.evm.v1.BalanceDeltas
- name: store_balance_changes
kind: store
initialBlock: 17216720
updatePolicy: add
valueType: bigint
inputs:
- map: map_balance_deltas
- name: map_changes
kind: map
initialBlock: 17216720
inputs:
- source: sf.ethereum.type.v2.Block
- map: map_pools_created
- map: map_balance_deltas
- store: store_pools_created
- store: store_balance_changes
mode: deltas # This is the key property that simplifies `BalanceChange` handling
output:
type: proto:tycho.evm.v1.BlockContractChanges