Merge pull request #99 from propeller-heads/lp/uniswap-v2-default-balances

feat(uniswap_v2): set default balances on pool creation
This commit is contained in:
Louise Poole
2024-10-28 13:42:05 +02:00
committed by GitHub
5 changed files with 21 additions and 11 deletions

2
substreams/Cargo.lock generated
View File

@@ -330,7 +330,7 @@ dependencies = [
[[package]]
name = "ethereum-uniswap-v2"
version = "0.3.0"
version = "0.3.1"
dependencies = [
"anyhow",
"ethabi 18.0.0",

View File

@@ -1,6 +1,6 @@
[package]
name = "ethereum-uniswap-v2"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
[lib]

View File

@@ -1,7 +1,7 @@
specVersion: v0.1.0
package:
name: "ethereum_pancakeswap"
version: v0.2.1
version: v0.3.1
protobuf:
files:
@@ -15,7 +15,7 @@ protobuf:
binaries:
default:
type: wasm/rust-v1
file: ../../target/wasm32-unknown-unknown/substreams/ethereum_uniswap_v2.wasm
file: ../target/wasm32-unknown-unknown/release/ethereum_uniswap_v2.wasm
modules:
- name: map_pools_created
@@ -31,7 +31,7 @@ modules:
kind: store
initialBlock: 15614590
updatePolicy: set_if_not_exists
valueType: proto:tycho.evm.v1.ProtocolComponent
valueType: proto:tycho.evm.uniswap.v2.Pool
inputs:
- map: map_pools_created

View File

@@ -1,7 +1,7 @@
specVersion: v0.1.0
package:
name: "ethereum_sushiswap_v2"
version: v0.2.1
version: v0.3.1
protobuf:
files:
@@ -15,7 +15,7 @@ protobuf:
binaries:
default:
type: wasm/rust-v1
file: ../../target/wasm32-unknown-unknown/substreams/ethereum_uniswap_v2.wasm
file: ../target/wasm32-unknown-unknown/release/ethereum_uniswap_v2.wasm
modules:
- name: map_pools_created

View File

@@ -4,7 +4,6 @@ use ethabi::ethereum_types::Address;
use serde::Deserialize;
use substreams::prelude::BigInt;
use substreams_ethereum::pb::eth::v2::{self as eth};
use substreams_helper::{event_handler::EventHandler, hex::Hexable};
use crate::abi::factory::events::PairCreated;
@@ -58,7 +57,7 @@ fn get_pools(block: &eth::Block, new_pools: &mut Vec<TransactionChanges>, params
}],
component_changes: vec![ProtocolComponent {
id: event.pair.to_hex(),
tokens: vec![event.token0, event.token1],
tokens: vec![event.token0.clone(), event.token1.clone()],
contracts: vec![],
static_att: vec![
// Trading Fee is hardcoded to 0.3%, saved as int in bps (basis points)
@@ -69,7 +68,7 @@ fn get_pools(block: &eth::Block, new_pools: &mut Vec<TransactionChanges>, params
},
Attribute {
name: "pool_address".to_string(),
value: event.pair,
value: event.pair.clone(),
change: ChangeType::Creation.into(),
},
],
@@ -82,7 +81,18 @@ fn get_pools(block: &eth::Block, new_pools: &mut Vec<TransactionChanges>, params
}),
tx: Some(tycho_tx),
}],
balance_changes: vec![],
balance_changes: vec![
BalanceChange {
token: event.token0,
balance: BigInt::from(0).to_signed_bytes_be(),
component_id: event.pair.to_hex().as_bytes().to_vec(),
},
BalanceChange {
token: event.token1,
balance: BigInt::from(0).to_signed_bytes_be(),
component_id: event.pair.to_hex().as_bytes().to_vec(),
},
],
})
};