fix: skip processing balances of bpt tokens (#220)
This commit is contained in:
2
substreams/Cargo.lock
generated
2
substreams/Cargo.lock
generated
@@ -240,7 +240,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ethereum-balancer-v2"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ethabi 18.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ethereum-balancer-v2"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
|
||||
@@ -76,65 +76,72 @@ pub fn map_relative_balances(
|
||||
abi::vault::events::PoolBalanceChanged::match_and_decode(vault_log.log)
|
||||
{
|
||||
let component_id = format!("0x{}", hex::encode(ev.pool_id));
|
||||
let bpt_token = hex::decode(&component_id[2..42]).unwrap();
|
||||
|
||||
if store
|
||||
.get_last(format!("pool:{}", &component_id[..42]))
|
||||
.is_some()
|
||||
{
|
||||
for (token, delta) in ev
|
||||
.tokens
|
||||
.iter()
|
||||
.zip(ev.deltas.iter())
|
||||
.filter(|(token, _)| **token != hex::decode(&component_id[2..42]).unwrap())
|
||||
{
|
||||
deltas.push(BalanceDelta {
|
||||
ord: vault_log.ordinal(),
|
||||
tx: Some(vault_log.receipt.transaction.into()),
|
||||
token: token.to_vec(),
|
||||
delta: delta.to_signed_bytes_be(),
|
||||
component_id: component_id.as_bytes().to_vec(),
|
||||
});
|
||||
for (token, delta) in ev.tokens.iter().zip(ev.deltas.iter()) {
|
||||
// BPT tokens not supported - their balance handling is currently bugged
|
||||
if *token != bpt_token {
|
||||
deltas.push(BalanceDelta {
|
||||
ord: vault_log.ordinal(),
|
||||
tx: Some(vault_log.receipt.transaction.into()),
|
||||
token: token.to_vec(),
|
||||
delta: delta.to_signed_bytes_be(),
|
||||
component_id: component_id.as_bytes().to_vec(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if let Some(ev) = abi::vault::events::Swap::match_and_decode(vault_log.log) {
|
||||
let component_id = format!("0x{}", hex::encode(ev.pool_id));
|
||||
let bpt_token = hex::decode(&component_id[2..42]).unwrap();
|
||||
|
||||
if store
|
||||
.get_last(format!("pool:{}", &component_id[..42]))
|
||||
.is_some()
|
||||
{
|
||||
deltas.extend_from_slice(&[
|
||||
BalanceDelta {
|
||||
// BPT tokens not supported - their balance handling is currently bugged
|
||||
if ev.token_in != bpt_token {
|
||||
deltas.push(BalanceDelta {
|
||||
ord: vault_log.ordinal(),
|
||||
tx: Some(vault_log.receipt.transaction.into()),
|
||||
token: ev.token_in.to_vec(),
|
||||
delta: ev.amount_in.to_signed_bytes_be(),
|
||||
component_id: component_id.as_bytes().to_vec(),
|
||||
},
|
||||
BalanceDelta {
|
||||
});
|
||||
}
|
||||
// BPT tokens not supported - their balance handling is currently bugged
|
||||
if ev.token_out != bpt_token {
|
||||
deltas.push(BalanceDelta {
|
||||
ord: vault_log.ordinal(),
|
||||
tx: Some(vault_log.receipt.transaction.into()),
|
||||
token: ev.token_out.to_vec(),
|
||||
delta: ev.amount_out.neg().to_signed_bytes_be(),
|
||||
component_id: component_id.as_bytes().to_vec(),
|
||||
},
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if let Some(ev) =
|
||||
abi::vault::events::PoolBalanceManaged::match_and_decode(vault_log.log)
|
||||
{
|
||||
let component_id = format!("0x{}", hex::encode(ev.pool_id));
|
||||
let bpt_token = hex::decode(&component_id[2..42]).unwrap();
|
||||
if store
|
||||
.get_last(format!("pool:{}", &component_id[..42]))
|
||||
.is_some()
|
||||
// BPT tokens not supported - their balance handling is currently bugged
|
||||
&& ev.token != bpt_token
|
||||
{
|
||||
deltas.extend_from_slice(&[BalanceDelta {
|
||||
deltas.push(BalanceDelta {
|
||||
ord: vault_log.ordinal(),
|
||||
tx: Some(vault_log.receipt.transaction.into()),
|
||||
token: ev.token.to_vec(),
|
||||
delta: ev.cash_delta.to_signed_bytes_be(),
|
||||
component_id: component_id.as_bytes().to_vec(),
|
||||
}]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -217,8 +217,8 @@ pub fn address_map(
|
||||
Some(
|
||||
ProtocolComponent::new(&format!("0x{}", hex::encode(pool_registered.pool_id)))
|
||||
.with_contracts(&[pool_created.pool.clone(), VAULT_ADDRESS.to_vec()])
|
||||
// .with_tokens(&tokens_registered.tokens) //TODO: does it make sense to include
|
||||
// BPT token here?
|
||||
// .with_tokens(&tokens_registered.tokens) // TODO: add this back if we need to
|
||||
// track BPT
|
||||
.with_tokens(&[
|
||||
create_call.main_token.clone(),
|
||||
create_call.wrapped_token.clone(),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
specVersion: v0.1.0
|
||||
package:
|
||||
name: "ethereum_balancer_v2"
|
||||
version: v0.3.0
|
||||
version: v0.3.1
|
||||
url: "https://github.com/propeller-heads/tycho-protocol-sdk/tree/main/substreams/ethereum-balancer-v2"
|
||||
|
||||
protobuf:
|
||||
|
||||
Reference in New Issue
Block a user