feat: Add Maverick V2 adapter and substreams (#167)

Co-authored-by: Thales <thales@datarevenue.com>
Co-authored-by: zizou <111426680+flopell@users.noreply.github.com>
This commit is contained in:
Zach
2025-05-23 23:07:15 +08:00
committed by GitHub
parent a7841af383
commit fb0a57bf07
32 changed files with 12082 additions and 0 deletions

42
substreams/Cargo.lock generated
View File

@@ -296,6 +296,25 @@ dependencies = [
"tycho-substreams 0.2.0 (git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=3c08359)",
]
[[package]]
name = "ethereum-maverick-v2"
version = "0.1.0"
dependencies = [
"anyhow",
"ethabi 18.0.0",
"hex",
"itertools 0.10.5",
"num-bigint",
"prost 0.11.9",
"serde",
"serde-sibor",
"serde_qs",
"substreams",
"substreams-ethereum",
"substreams-helper 0.0.2 (git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=52d5021)",
"tycho-substreams 0.2.1 (git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=52d5021)",
]
[[package]]
name = "ethereum-pancakeswap-v3"
version = "0.1.2"
@@ -1447,6 +1466,29 @@ dependencies = [
"tiny-keccak",
]
[[package]]
name = "substreams-helper"
version = "0.0.2"
source = "git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=52d5021#52d502198e9aa964814ef5f139df0886c3eb7bb0"
dependencies = [
"anyhow",
"base64",
"bigdecimal",
"downcast-rs",
"ethabi 18.0.0",
"hex",
"hex-literal 0.4.1",
"num-bigint",
"pad",
"prost 0.11.9",
"prost-types 0.12.6",
"substreams",
"substreams-entity-change",
"substreams-ethereum",
"thiserror 1.0.69",
"tiny-keccak",
]
[[package]]
name = "substreams-helper"
version = "0.0.2"

View File

@@ -15,6 +15,7 @@ members = [
"ethereum-template-singleton",
"ethereum-uniswap-v4",
"ethereum-ekubo-v2",
"ethereum-maverick-v2",
]
resolver = "2"

View File

@@ -0,0 +1,28 @@
[package]
name = "ethereum-maverick-v2"
version = "0.1.0"
edition = "2021"
[lib]
name = "ethereum_maverick_v2"
crate-type = ["cdylib"]
[dependencies]
substreams = "0.5.22"
substreams-ethereum = "0.9.9"
prost = "0.11"
substreams-helper = { git = "https://github.com/propeller-heads/tycho-protocol-sdk.git", rev = "52d5021" }
tycho-substreams = { git = "https://github.com/propeller-heads/tycho-protocol-sdk.git", rev = "52d5021" }
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_qs = "0.13.0"
serde-sibor = "0.1.0"
[build-dependencies]
anyhow = "1"
substreams-ethereum = "0.9.9"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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!("{output_folder}/{contract_name}.rs");
mod_rs_content.push_str(&format!("pub mod {contract_name};\n"));
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!("{output_folder}/mod.rs");
let mut mod_rs_file = fs::File::create(mod_rs_path)?;
mod_rs_file.write_all(mod_rs_content.as_bytes())?;
Ok(())
}

View File

@@ -0,0 +1,72 @@
specVersion: v0.1.0
package:
name: "ethereum_maverick_v2"
version: v0.1.0
protobuf:
files:
- tycho/evm/v1/vm.proto
- tycho/evm/v1/common.proto
- tycho/evm/v1/utils.proto
- maverick.proto
importPaths:
- ./proto/v1
- ../../proto
binaries:
default:
type: wasm/rust-v1
file: ../target/wasm32-unknown-unknown/release/ethereum_maverick_v2.wasm
modules:
- name: map_components
kind: map
initialBlock: 20027237 # factory creation block
inputs:
- params: string
- source: sf.ethereum.type.v2.Block
output:
type: proto:tycho.evm.v1.BlockTransactionProtocolComponents
- name: store_components
kind: store
initialBlock: 20027237
updatePolicy: set_if_not_exists
valueType: proto:maverick.v2.Pool
inputs:
- map: map_components
- name: map_relative_balances
kind: map
initialBlock: 20027237
inputs:
- source: sf.ethereum.type.v2.Block
- store: store_components
output:
type: proto:tycho.evm.v1.BlockBalanceDeltas
- name: store_balances
kind: store
initialBlock: 20027237
updatePolicy: add
valueType: bigint
inputs:
- map: map_relative_balances
- name: map_protocol_changes
kind: map
initialBlock: 20027237
inputs:
- params: string
- source: sf.ethereum.type.v2.Block
- map: map_components
- map: map_relative_balances
- store: store_components
- store: store_balances
mode: deltas
output:
type: proto:tycho.evm.v1.BlockChanges
params:
map_components: "factory=0A7e848Aca42d879EF06507Fca0E7b33A0a63c1e&quoter=b40AfdB85a07f37aE217E7D6462e609900dD8D7A"
map_protocol_changes: "factory=0A7e848Aca42d879EF06507Fca0E7b33A0a63c1e&quoter=b40AfdB85a07f37aE217E7D6462e609900dD8D7A"

View File

@@ -0,0 +1,40 @@
substreams_yaml_path: ./ethereum-maverick-v2.yaml
adapter_contract: "MaverickV2SwapAdapter"
adapter_build_signature: "constructor(address,address)"
adapter_build_args: "0x0A7e848Aca42d879EF06507Fca0E7b33A0a63c1e,0xb40AfdB85a07f37aE217E7D6462e609900dD8D7A"
skip_balance_check: false
initialized_accounts:
- "0x0A7e848Aca42d879EF06507Fca0E7b33A0a63c1e" # Factory
- "0xb40AfdB85a07f37aE217E7D6462e609900dD8D7A" # Quoter
protocol_type_names:
- "maverick_v2_pool"
tests:
- name: test_pool_creation
start_block: 20122172
stop_block: 20122272
expected_components:
- id: "0xEB1da432D5C1a9FDF52aA5D37698f34706F91397"
tokens:
- "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" # WETH
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" # USDC
static_attributes:
fee_a_in: "0x5af3107a4000"
fee_b_in: "0x5af3107a4000"
tick_spacing: "0x08b8"
kinds: "0x01"
creation_tx: "0xb181cf013f46b5bd13a0244733c463b120b3d7eef68c74c11e0f0e4b6a0027e4"
- name: test_gho_usdc_pool_creation
start_block: 20127132
stop_block: 20127232
expected_components:
- id: "0x14Cf6D2Fe3E1B326114b07d22A6F6bb59e346c67"
tokens:
- "0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f" # GHO
- "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" # USDC
static_attributes:
fee_a_in: "0x5af3107a4000"
fee_b_in: "0x5af3107a4000"
tick_spacing: "0x2"
kinds: "0xf"
creation_tx: "0xa1c5c6a7d5886caefa4ab660575f0d3a63297d4859644039fe656edcd031a9dc"

View File

@@ -0,0 +1,10 @@
syntax = "proto3";
package maverick.v2;
message Pool {
bytes address = 1;
bytes tokenA = 2;
bytes tokenB = 3;
bytes created_tx_hash = 4;
}

View File

@@ -0,0 +1,4 @@
[toolchain]
channel = "1.83.0"
components = [ "rustfmt" ]
targets = [ "wasm32-unknown-unknown" ]

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
#![allow(clippy::all)]
pub mod factory;
pub mod pool;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
use crate::{
abi::pool::events::PoolAddLiquidity, events::BalanceEventTrait, pb::maverick::v2::Pool,
};
use substreams_helper::hex::Hexable;
use tycho_substreams::prelude::*;
impl BalanceEventTrait for PoolAddLiquidity {
fn get_balance_delta(&self, tx: &Transaction, pool: &Pool, ordinal: u64) -> Vec<BalanceDelta> {
let changed_balance = vec![
BalanceDelta {
ord: ordinal,
tx: Some(tx.clone()),
token: pool.token_a.clone(),
delta: self
.token_a_amount
.clone()
.to_signed_bytes_be(),
component_id: pool
.address
.clone()
.to_hex()
.as_bytes()
.to_vec(),
},
BalanceDelta {
ord: ordinal,
tx: Some(tx.clone()),
token: pool.token_b.clone(),
delta: self
.token_b_amount
.clone()
.to_signed_bytes_be(),
component_id: pool
.address
.clone()
.to_hex()
.as_bytes()
.to_vec(),
},
];
changed_balance
}
}

View File

@@ -0,0 +1,82 @@
use crate::{
abi::pool::events::{PoolAddLiquidity, PoolRemoveLiquidity, PoolSwap},
pb::maverick::v2::Pool,
};
use substreams_ethereum::{pb::eth::v2::Log, Event};
use tycho_substreams::prelude::*;
pub mod add_liquidity;
pub mod remove_liquidity;
pub mod swap;
/// A trait for extracting changed balance from an event.
pub trait BalanceEventTrait {
/// Get all balance deltas from the event.
///
/// # Arguments
///
/// * `tx` - Reference to the `Transaction`.
/// * `pool` - Reference to the `Pool`.
/// * `ordinal` - The ordinal number of the event. This is used by the balance store to sort the
///
/// # Returns
///
/// A vector of `BalanceDelta` that represents the balance deltas.
fn get_balance_delta(&self, tx: &Transaction, pool: &Pool, ordinal: u64) -> Vec<BalanceDelta>;
}
/// Represent every events of a Maverick pool.
pub enum EventType {
PoolSwap(PoolSwap),
AddLiquidity(PoolAddLiquidity),
RemoveLiquidity(PoolRemoveLiquidity),
}
impl EventType {
fn as_event_trait(&self) -> &dyn BalanceEventTrait {
match self {
EventType::PoolSwap(event) => event,
EventType::AddLiquidity(event) => event,
EventType::RemoveLiquidity(event) => event,
}
}
}
/// Decodes the event from the log.
///
/// # Arguments
///
/// * `event` - A reference to the `Log`.
///
/// # Returns
///
/// An `Option` that contains the `EventType` if the event is recognized.
pub fn decode_event(event: &Log) -> Option<EventType> {
[
PoolSwap::match_and_decode(event).map(EventType::PoolSwap),
PoolAddLiquidity::match_and_decode(event).map(EventType::AddLiquidity),
PoolRemoveLiquidity::match_and_decode(event).map(EventType::RemoveLiquidity),
]
.into_iter()
.find_map(std::convert::identity)
}
/// Gets the changed balances from the log.
///
/// # Arguments
///
/// * `tx` - Reference to the `Transaction`.
/// * `event` - Reference to the `Log`.
/// * `pool` - Reference to the `Pool`.
///
/// # Returns
///
/// A vector of `BalanceDelta` that represents
pub fn get_log_changed_balances(tx: &Transaction, event: &Log, pool: &Pool) -> Vec<BalanceDelta> {
decode_event(event)
.map(|e| {
e.as_event_trait()
.get_balance_delta(tx, pool, event.ordinal)
})
.unwrap_or_default()
}

View File

@@ -0,0 +1,45 @@
use crate::{
abi::pool::events::PoolRemoveLiquidity, events::BalanceEventTrait, pb::maverick::v2::Pool,
};
use substreams_helper::hex::Hexable;
use tycho_substreams::prelude::*;
impl BalanceEventTrait for PoolRemoveLiquidity {
fn get_balance_delta(&self, tx: &Transaction, pool: &Pool, ordinal: u64) -> Vec<BalanceDelta> {
let changed_balance = vec![
BalanceDelta {
ord: ordinal,
tx: Some(tx.clone()),
token: pool.token_a.clone(),
delta: self
.token_a_out
.neg()
.clone()
.to_signed_bytes_be(),
component_id: pool
.address
.clone()
.to_hex()
.as_bytes()
.to_vec(),
},
BalanceDelta {
ord: ordinal,
tx: Some(tx.clone()),
token: pool.token_b.clone(),
delta: self
.token_b_out
.neg()
.clone()
.to_signed_bytes_be(),
component_id: pool
.address
.clone()
.to_hex()
.as_bytes()
.to_vec(),
},
];
changed_balance
}
}

View File

@@ -0,0 +1,43 @@
use crate::{abi::pool::events::PoolSwap, events::BalanceEventTrait, pb::maverick::v2::Pool};
use substreams_helper::hex::Hexable;
use tycho_substreams::prelude::*;
impl BalanceEventTrait for PoolSwap {
fn get_balance_delta(&self, tx: &Transaction, pool: &Pool, ordinal: u64) -> Vec<BalanceDelta> {
let (token_in, token_out, amount_in, amount_out) = if self.params.1 {
(&pool.token_a, &pool.token_b, &self.amount_in, &self.amount_out)
} else {
(&pool.token_b, &pool.token_a, &self.amount_in, &self.amount_out)
};
vec![
BalanceDelta {
ord: ordinal,
tx: Some(tx.clone()),
token: token_in.clone(),
delta: amount_in.clone().to_signed_bytes_be(),
component_id: pool
.address
.clone()
.to_hex()
.as_bytes()
.to_vec(),
},
BalanceDelta {
ord: ordinal,
tx: Some(tx.clone()),
token: token_out.clone(),
delta: amount_out
.neg()
.clone()
.to_signed_bytes_be(),
component_id: pool
.address
.clone()
.to_hex()
.as_bytes()
.to_vec(),
},
]
}
}

View File

@@ -0,0 +1,7 @@
#![allow(clippy::not_unsafe_ptr_arg_deref)]
mod abi;
mod events;
mod modules;
mod pb;
pub use modules::*;

View File

@@ -0,0 +1,55 @@
use anyhow::{Ok, Result};
use ethabi::ethereum_types::Address;
use substreams_ethereum::pb::eth::v2::{Block, Log, TransactionTrace};
use tycho_substreams::prelude::*;
use crate::{abi::factory::events::PoolCreated, modules::utils::Params};
use substreams_helper::{event_handler::EventHandler, hex::Hexable};
#[substreams::handlers::map]
pub fn map_components(params: String, block: Block) -> Result<BlockTransactionProtocolComponents> {
let mut new_pools: Vec<TransactionProtocolComponents> = vec![];
let params = Params::parse_from_query(&params)?;
get_new_pools(params, &block, &mut new_pools);
Ok(BlockTransactionProtocolComponents { tx_components: new_pools })
}
fn get_new_pools(
params: Params,
block: &Block,
new_pools: &mut Vec<TransactionProtocolComponents>,
) {
let (factory_address, quoter_address) = params.decode_addresses().unwrap();
let mut on_pool_created = |event: PoolCreated, _tx: &TransactionTrace, _log: &Log| {
let tycho_tx: Transaction = _tx.into();
let contracts = vec![
event.pool_address.as_slice(),
factory_address.as_slice(),
quoter_address.as_slice(),
];
let new_pool_component = ProtocolComponent::new(&event.pool_address.to_hex())
.with_tokens(&[event.token_a.as_slice(), event.token_b.as_slice()])
.with_contracts(&contracts)
.with_attributes(&[
("fee_a_in", &event.fee_a_in.to_signed_bytes_be()),
("fee_b_in", &event.fee_b_in.to_signed_bytes_be()),
("tick_spacing", &event.tick_spacing.to_signed_bytes_be()),
("kinds", &event.kinds.to_signed_bytes_be()),
])
.as_swap_type("maverick_v2_pool", ImplementationType::Vm);
new_pools.push(TransactionProtocolComponents {
tx: Some(tycho_tx.clone()),
components: vec![new_pool_component],
});
};
let mut eh = EventHandler::new(block);
eh.filter_by_address(vec![Address::from_slice(&factory_address)]);
eh.on::<PoolCreated, _>(&mut on_pool_created);
eh.handle_events();
}

View File

@@ -0,0 +1,25 @@
use crate::pb::maverick::v2::Pool;
use substreams::{
prelude::{StoreSetIfNotExists, StoreSetIfNotExistsProto},
store::StoreNew,
};
use tycho_substreams::prelude::*;
#[substreams::handlers::store]
pub fn store_components(
map: BlockTransactionProtocolComponents,
store: StoreSetIfNotExistsProto<Pool>,
) {
for tx_pc in map.tx_components {
for pc in tx_pc.components {
let pool_address = &pc.id;
let pool = Pool {
address: hex::decode(pool_address.trim_start_matches("0x")).unwrap(),
token_a: pc.tokens[0].clone(),
token_b: pc.tokens[1].clone(),
created_tx_hash: tx_pc.tx.as_ref().unwrap().hash.clone(),
};
store.set_if_not_exists(0, format!("Pool:{pool_address}"), &pool);
}
}
}

View File

@@ -0,0 +1,39 @@
use crate::{events::get_log_changed_balances, pb::maverick::v2::Pool};
use anyhow::{Ok, Result};
use substreams::{prelude::StoreGetProto, store::StoreGet};
use substreams_ethereum::pb::eth::v2::Block;
use substreams_helper::hex::Hexable;
use tycho_substreams::prelude::*;
#[substreams::handlers::map]
pub fn map_relative_balances(
block: Block,
pools_store: StoreGetProto<Pool>,
) -> Result<BlockBalanceDeltas, anyhow::Error> {
let mut balance_deltas = Vec::new();
for trx in block.transactions() {
let mut tx_deltas = Vec::new();
let tx = Transaction {
to: trx.to.clone(),
from: trx.from.clone(),
hash: trx.hash.clone(),
index: trx.index.into(),
};
for log in trx
.calls
.iter()
.filter(|call| !call.state_reverted)
.flat_map(|call| &call.logs)
{
if let Some(pool) = pools_store.get_last(format!("Pool:{}", &log.address.to_hex())) {
tx_deltas.extend(get_log_changed_balances(&tx, log, &pool));
} else {
continue;
}
}
if !tx_deltas.is_empty() {
balance_deltas.extend(tx_deltas);
}
}
Ok(BlockBalanceDeltas { balance_deltas })
}

View File

@@ -0,0 +1,7 @@
use substreams::store::{StoreAddBigInt, StoreNew};
use tycho_substreams::prelude::*;
#[substreams::handlers::store]
pub fn store_balances(balances_deltas: BlockBalanceDeltas, store: StoreAddBigInt) {
tycho_substreams::balances::store_balance_changes(balances_deltas, store);
}

View File

@@ -0,0 +1,118 @@
use crate::{modules::utils::Params, pb::maverick::v2::Pool};
use anyhow::Result;
use itertools::Itertools;
use std::collections::HashMap;
use substreams::{pb::substreams::StoreDeltas, prelude::StoreGetProto, store::StoreGet};
use substreams_ethereum::pb::eth::v2::Block;
use substreams_helper::hex::Hexable;
use tycho_substreams::{
balances::aggregate_balances_changes, contract::extract_contract_changes_builder, prelude::*,
};
#[substreams::handlers::map]
pub fn map_protocol_changes(
params: String,
block: Block,
protocol_components: BlockTransactionProtocolComponents,
balance_deltas: BlockBalanceDeltas,
pool_store: StoreGetProto<Pool>,
balance_store: StoreDeltas,
) -> Result<BlockChanges> {
let params = Params::parse_from_query(&params)?;
let (factory_address, quoter_address) = params.decode_addresses()?;
let mut transaction_changes: HashMap<_, TransactionChangesBuilder> = HashMap::new();
protocol_components
.tx_components
.iter()
.for_each(|tx_component| {
let tx = tx_component.tx.as_ref().unwrap();
let builder = transaction_changes
.entry(tx.index)
.or_insert_with(|| TransactionChangesBuilder::new(tx));
tx_component
.components
.iter()
.for_each(|c| {
builder.add_protocol_component(c);
});
});
aggregate_balances_changes(balance_store, balance_deltas)
.into_iter()
.for_each(|(_, (tx, balances))| {
let builder = transaction_changes
.entry(tx.index)
.or_insert_with(|| TransactionChangesBuilder::new(&tx));
balances
.values()
.for_each(|token_bc_map| {
token_bc_map
.values()
.for_each(|bc| builder.add_balance_change(bc))
});
});
extract_contract_changes_builder(
&block,
|addr| {
pool_store
.get_last(format!("Pool:0x{}", hex::encode(addr)))
.is_some() ||
addr.eq(factory_address.as_slice())
},
&mut transaction_changes,
);
block
.transactions()
.for_each(|block_tx| {
block_tx.calls.iter().for_each(|call| {
if call.address == quoter_address {
let mut contract_change =
InterimContractChange::new(call.address.as_slice(), true);
if let Some(code_change) = &call.code_changes.first() {
contract_change.set_code(&code_change.new_code);
}
let builder = transaction_changes
.entry(block_tx.index.into())
.or_insert_with(|| TransactionChangesBuilder::new(&(block_tx.into())));
builder.add_contract_changes(&contract_change);
}
});
});
transaction_changes
.iter_mut()
.for_each(|(_, change)| {
// this indirection is necessary due to borrowing rules.
let addresses = change
.changed_contracts()
.map(|e| e.to_vec())
.collect::<Vec<_>>();
addresses
.into_iter()
.for_each(|address| {
// check if the address is not a pool
if address != factory_address.as_slice() && address != quoter_address.as_slice()
{
let pool = pool_store
.get_last(format!("Pool:0x{}", hex::encode(address)))
.unwrap();
change.mark_component_as_updated(&pool.address.to_hex());
}
})
});
Ok(BlockChanges {
block: Some((&block).into()),
changes: transaction_changes
.drain()
.sorted_unstable_by_key(|(index, _)| *index)
.filter_map(|(_, builder)| builder.build())
.collect::<Vec<_>>(),
})
}

View File

@@ -0,0 +1,21 @@
pub use map_components::map_components;
pub use map_protocol_changes::map_protocol_changes;
pub use map_relative_balances::map_relative_balances;
pub use store_balances::store_balances;
pub use store_components::store_components;
#[path = "1_map_components.rs"]
mod map_components;
#[path = "2_store_components.rs"]
mod store_components;
#[path = "3_map_relative_balances.rs"]
mod map_relative_balances;
#[path = "4_store_balances.rs"]
mod store_balances;
#[path = "5_map_protocol_changes.rs"]
mod map_protocol_changes;
mod utils;

View File

@@ -0,0 +1,26 @@
use anyhow::{anyhow, Result};
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct Params {
pub factory: String,
pub quoter: String,
}
impl Params {
pub fn parse_from_query(input: &str) -> Result<Self> {
serde_qs::from_str(input).map_err(|e| anyhow!("Failed to parse query params: {}", e))
}
pub fn decode_addresses(&self) -> Result<([u8; 20], [u8; 20])> {
let factory =
hex::decode(&self.factory).map_err(|e| anyhow!("Invalid factory hex: {}", e))?;
let quoter = hex::decode(&self.quoter).map_err(|e| anyhow!("Invalid quoter hex: {}", e))?;
if factory.len() != 20 || quoter.len() != 20 {
return Err(anyhow!("Addresses must be 20 bytes"));
}
Ok((factory.try_into().unwrap(), quoter.try_into().unwrap()))
}
}

View File

@@ -0,0 +1,14 @@
// @generated
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Pool {
#[prost(bytes="vec", tag="1")]
pub address: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes="vec", tag="2")]
pub token_a: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes="vec", tag="3")]
pub token_b: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes="vec", tag="4")]
pub created_tx_hash: ::prost::alloc::vec::Vec<u8>,
}
// @@protoc_insertion_point(module)

View File

@@ -0,0 +1,8 @@
// @generated
pub mod maverick {
// @@protoc_insertion_point(attribute:maverick.v2)
pub mod v2 {
include!("maverick.v2.rs");
// @@protoc_insertion_point(maverick.v2)
}
}

View File

@@ -20,4 +20,5 @@ ignore = [
"ethereum-uniswap-v3-logs-only/src/abi",
"ethereum-pancakeswap-v3/src/abi",
"ethereum-uniswap-v4/src/abi",
"ethereum-maverick-v2/src/abi",
]