Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EulerSwap - a la uni-v2 integration - aborted #1

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
init euler-swap substreams
  • Loading branch information
haythemsellami committed Feb 17, 2025
commit 3a881af1cbb0b578e5225f4083014d6d43c6a5b9
26 changes: 26 additions & 0 deletions substreams/ethereum-eulerswap/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "ethereum-template-factory"
version = "0.1.0"
edition = "2021"

[lib]
name = "ethereum_template_factory"
crate-type = ["cdylib"]

[dependencies]
substreams = "0.5.22"
substreams-ethereum = "0.9.9"
prost = "0.11"
tycho-substreams = { git = "https://github.com/propeller-heads/tycho-protocol-sdk.git", rev = "3c08359" }
anyhow = "1.0.95"
ethabi = "18.0.0"
num-bigint = "0.4.6"
hex = "0.4.3"
itertools = "0.10.5"
serde = "1.0.217"
serde-sibor = "0.1.0"


[build-dependencies]
anyhow = "1"
substreams-ethereum = "0.9.9"
1 change: 1 addition & 0 deletions substreams/ethereum-eulerswap/abi/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please put any abi JSONs into this folder the buildscript will compile these to rust code.
12 changes: 12 additions & 0 deletions substreams/ethereum-eulerswap/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

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
49 changes: 49 additions & 0 deletions substreams/ethereum-eulerswap/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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 abis = fs::read_dir(abi_folder)?;

let mut files = abis.collect::<Result<Vec<_>, _>>()?;

// Sort the files by their name
files.sort_by_key(|a| a.file_name());

let mut mod_rs_content = String::new();
mod_rs_content.push_str("#![allow(clippy::all)]\n");

for file in files {
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(())
}
57 changes: 57 additions & 0 deletions substreams/ethereum-eulerswap/integration_test.tycho.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Name of the substreams config file in your substreams module. Usually "./substreams.yaml"
substreams_yaml_path: ./substreams.yaml
# Name of the adapter contract, usually: ProtocolSwapAdapter"
adapter_contract: "SwapAdapter"
# Constructor signature of the Adapter contract"
adapter_build_signature: "constructor(address)"
# A comma separated list of args to be passed to the contructor of the Adapter contract"
adapter_build_args: "0x0000000000000000000000000000000000000000"
# Whether or not the testing script should skip checking balances of the protocol components.
# If set to `true` please always add a reason why it's skipped.
skip_balance_check: false
# A list of accounts that need to be indexed to run the tests properly.
# Usually used when there is a global component required by all pools and created before the tested range of blocks. For example a factory or a vault.
# Please note that this component needs to be indexed by your substreams module, this feature is only for testing purpose.
# Also please always add a reason why this account is needed for your tests.
# This will be applied to each test.
initialized_accounts:
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84" # Needed for ....
# A list of protocol types names created by your Substreams module.
protocol_type_names:
- "type_name_1"
- "type_name_2"
# A list of tests.
tests:
# Name of the test
- name: test_pool_creation
# Indexed block range
start_block: 123
stop_block: 456
# Same as global `initialized_accounts` but only scoped to this test.
initialized_accounts:
- "0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963" # Needed for ....
# A list of expected component indexed in the block range. Each component must match perfectly the `ProtocolComponent` indexed by your subtreams module.
expected_components:
- id: "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7"
tokens:
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
- "0x6b175474e89094c44da98b954eedeac495271d0f"
static_attributes:
attr_1: "value"
attr_2: "value"
creation_tx: "0x20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6"
# Whether or not the script should skip trying to simulate a swap on this component.
# If set to `true` please always add a reason why it's skipped.
skip_simulation: false
- name: test_something_else
start_block: 123
stop_block: 456
expected_components:
- id: "0xdc24316b9ae028f1497c275eb9192a3ea0f67022"
tokens:
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
static_attributes: null
creation_tx: "0xfac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa"
skip_simulation: true # If true, always add a reason
4 changes: 4 additions & 0 deletions substreams/ethereum-eulerswap/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "1.83.0"
components = [ "rustfmt" ]
targets = [ "wasm32-unknown-unknown" ]
1 change: 1 addition & 0 deletions substreams/ethereum-eulerswap/src/abi/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#![allow(clippy::all)]
3 changes: 3 additions & 0 deletions substreams/ethereum-eulerswap/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod abi;
mod modules;
mod pool_factories;
Loading