feat: Update uniswap v3 package to use big endian encoding (#199)

* feat: update uniswap v3 package to big endian encoding

* chore: update use of format macro to make clippy happy
This commit is contained in:
Louise Poole
2025-05-05 15:54:11 +02:00
committed by GitHub
parent 01d97193b2
commit ee41e63775
6 changed files with 38 additions and 35 deletions

38
substreams/Cargo.lock generated
View File

@@ -420,6 +420,25 @@ dependencies = [
"tycho-substreams 0.2.0 (git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=b8aeaa3)",
]
[[package]]
name = "ethereum-uniswap-v3"
version = "0.3.0"
dependencies = [
"anyhow",
"ethabi 18.0.0",
"getrandom",
"hex",
"hex-literal 0.4.1",
"num-bigint",
"prost 0.11.9",
"substreams",
"substreams-entity-change",
"substreams-ethereum",
"substreams-helper 0.0.2 (git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=b8aeaa3)",
"tiny-keccak",
"tycho-substreams 0.2.0 (git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=b8aeaa3)",
]
[[package]]
name = "ethereum-uniswap-v3-logs-only"
version = "0.1.1"
@@ -1406,25 +1425,6 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "substreams-ethereum-uniswap-v3"
version = "0.2.1"
dependencies = [
"anyhow",
"ethabi 18.0.0",
"getrandom",
"hex",
"hex-literal 0.4.1",
"num-bigint",
"prost 0.11.9",
"substreams",
"substreams-entity-change",
"substreams-ethereum",
"substreams-helper 0.0.2 (git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=b8aeaa3)",
"tiny-keccak",
"tycho-substreams 0.2.0 (git+https://github.com/propeller-heads/tycho-protocol-sdk.git?rev=b8aeaa3)",
]
[[package]]
name = "substreams-helper"
version = "0.0.2"

View File

@@ -1,10 +1,10 @@
[package]
name = "substreams-ethereum-uniswap-v3"
version = "0.2.1"
name = "ethereum-uniswap-v3"
version = "0.3.0"
edition = "2021"
[lib]
name = "substreams_ethereum_uniswap_v3"
name = "ethereum_uniswap_v3"
crate-type = ["cdylib"]
[dependencies]

View File

@@ -1,7 +1,9 @@
specVersion: v0.1.0
package:
name: "substreams_arbitrum_uniswap_v3"
version: v0.2.1
name: "arbitrum_uniswap_v3"
version: v0.3.0
url: "https://github.com/propeller-heads/tycho-protocol-sdk/tree/main/substreams/ethereum-uniswap-v3"
protobuf:
files:
@@ -15,7 +17,7 @@ protobuf:
binaries:
default:
type: wasm/rust-v1
file: ../../target/wasm32-unknown-unknown/substreams/substreams_ethereum_uniswap_v3.wasm
file: ../target/wasm32-unknown-unknown/release/ethereum_uniswap_v3.wasm
modules:
- name: map_pools_created

View File

@@ -1,7 +1,8 @@
specVersion: v0.1.0
package:
name: "substreams_ethereum_uniswap_v3"
version: v0.2.1
name: "ethereum_uniswap_v3"
version: v0.3.0
url: "https://github.com/propeller-heads/tycho-protocol-sdk/tree/main/substreams/ethereum-uniswap-v3"
protobuf:
files:
@@ -15,7 +16,7 @@ protobuf:
binaries:
default:
type: wasm/rust-v1
file: ../../target/wasm32-unknown-unknown/substreams/substreams_ethereum_uniswap_v3.wasm
file: ../target/wasm32-unknown-unknown/release/ethereum_uniswap_v3.wasm
modules:
- name: map_pools_created

View File

@@ -40,17 +40,17 @@ fn get_new_pools(
attributes: vec![
Attribute {
name: "liquidity".to_string(),
value: BigInt::from(0).to_signed_bytes_le(),
value: BigInt::from(0).to_signed_bytes_be(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "tick".to_string(),
value: BigInt::from(0).to_signed_bytes_le(),
value: BigInt::from(0).to_signed_bytes_be(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "sqrt_price_x96".to_string(),
value: BigInt::from(0).to_signed_bytes_le(),
value: BigInt::from(0).to_signed_bytes_be(),
change: ChangeType::Creation.into(),
},
],
@@ -62,12 +62,12 @@ fn get_new_pools(
static_att: vec![
Attribute {
name: "fee".to_string(),
value: event.fee.to_signed_bytes_le(),
value: event.fee.to_signed_bytes_be(),
change: ChangeType::Creation.into(),
},
Attribute {
name: "tick_spacing".to_string(),
value: event.tick_spacing.to_signed_bytes_le(),
value: event.tick_spacing.to_signed_bytes_be(),
change: ChangeType::Creation.into(),
},
Attribute {

View File

@@ -77,7 +77,7 @@ impl<'a> UniswapPoolStorage<'a> {
};
attributes.push(Attribute {
name: storage_location.name.to_string(),
value: value.to_signed_bytes_le(),
value: value.to_signed_bytes_be(),
change: ChangeType::Update.into(),
});
}
@@ -108,7 +108,7 @@ impl<'a> UniswapPoolStorage<'a> {
// We need this to keep the references to the names alive until we call
// `get_changed_attributes()`
for tick_idx in ticks_idx.iter() {
tick_names.push(format!("ticks/{}/net-liquidity", tick_idx));
tick_names.push(format!("ticks/{tick_idx}/net-liquidity"));
}
// Then, iterate over ticks_idx and tick_names simultaneously