Fix bugs in balance substreams
This commit is contained in:
@@ -75,13 +75,10 @@ pub fn map_relative_balances(
|
|||||||
if let Some(ev) =
|
if let Some(ev) =
|
||||||
abi::vault::events::PoolBalanceChanged::match_and_decode(vault_log.log)
|
abi::vault::events::PoolBalanceChanged::match_and_decode(vault_log.log)
|
||||||
{
|
{
|
||||||
let component_id =
|
let component_id = format!("0x{}", hex::encode(&ev.pool_id[..20]));
|
||||||
format!("0x{}", String::from_utf8(ev.pool_id[..20].to_vec()).unwrap())
|
|
||||||
.as_bytes()
|
|
||||||
.to_vec();
|
|
||||||
|
|
||||||
if store
|
if store
|
||||||
.get_last(format!("pool:{}", hex::encode(&component_id)))
|
.get_last(format!("pool:{}", component_id))
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
for (token, delta) in ev.tokens.iter().zip(ev.deltas.iter()) {
|
for (token, delta) in ev.tokens.iter().zip(ev.deltas.iter()) {
|
||||||
@@ -90,18 +87,15 @@ pub fn map_relative_balances(
|
|||||||
tx: Some(vault_log.receipt.transaction.into()),
|
tx: Some(vault_log.receipt.transaction.into()),
|
||||||
token: token.to_vec(),
|
token: token.to_vec(),
|
||||||
delta: delta.to_signed_bytes_be(),
|
delta: delta.to_signed_bytes_be(),
|
||||||
component_id: component_id.clone(),
|
component_id: component_id.as_bytes().to_vec(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let Some(ev) = abi::vault::events::Swap::match_and_decode(vault_log.log) {
|
} else if let Some(ev) = abi::vault::events::Swap::match_and_decode(vault_log.log) {
|
||||||
let component_id =
|
let component_id = format!("0x{}", hex::encode(&ev.pool_id[..20]));
|
||||||
format!("0x{}", String::from_utf8(ev.pool_id[..20].to_vec()).unwrap())
|
|
||||||
.as_bytes()
|
|
||||||
.to_vec();
|
|
||||||
|
|
||||||
if store
|
if store
|
||||||
.get_last(format!("pool:{}", hex::encode(&component_id)))
|
.get_last(format!("pool:{}", component_id))
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
deltas.extend_from_slice(&[
|
deltas.extend_from_slice(&[
|
||||||
@@ -110,14 +104,14 @@ pub fn map_relative_balances(
|
|||||||
tx: Some(vault_log.receipt.transaction.into()),
|
tx: Some(vault_log.receipt.transaction.into()),
|
||||||
token: ev.token_in.to_vec(),
|
token: ev.token_in.to_vec(),
|
||||||
delta: ev.amount_in.to_signed_bytes_be(),
|
delta: ev.amount_in.to_signed_bytes_be(),
|
||||||
component_id: component_id.clone(),
|
component_id: component_id.as_bytes().to_vec(),
|
||||||
},
|
},
|
||||||
BalanceDelta {
|
BalanceDelta {
|
||||||
ord: vault_log.ordinal(),
|
ord: vault_log.ordinal(),
|
||||||
tx: Some(vault_log.receipt.transaction.into()),
|
tx: Some(vault_log.receipt.transaction.into()),
|
||||||
token: ev.token_out.to_vec(),
|
token: ev.token_out.to_vec(),
|
||||||
delta: ev.amount_out.neg().to_signed_bytes_be(),
|
delta: ev.amount_out.neg().to_signed_bytes_be(),
|
||||||
component_id,
|
component_id: component_id.as_bytes().to_vec(),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -188,7 +182,7 @@ pub fn map_protocol_changes(
|
|||||||
&block,
|
&block,
|
||||||
|addr| {
|
|addr| {
|
||||||
components_store
|
components_store
|
||||||
.get_last(format!("pool:{0}", hex::encode(addr)))
|
.get_last(format!("pool:0x{0}", hex::encode(addr)))
|
||||||
.is_some()
|
.is_some()
|
||||||
},
|
},
|
||||||
&mut transaction_contract_changes,
|
&mut transaction_contract_changes,
|
||||||
|
|||||||
@@ -3,6 +3,14 @@ package:
|
|||||||
name: "ethereum_balancer"
|
name: "ethereum_balancer"
|
||||||
version: v0.1.0
|
version: v0.1.0
|
||||||
|
|
||||||
|
protobuf:
|
||||||
|
files:
|
||||||
|
- tycho/evm/v1/vm.proto
|
||||||
|
- tycho/evm/v1/common.proto
|
||||||
|
- tycho/evm/v1/utils.proto
|
||||||
|
importPaths:
|
||||||
|
- ../../proto
|
||||||
|
|
||||||
binaries:
|
binaries:
|
||||||
default:
|
default:
|
||||||
type: wasm/rust-v1
|
type: wasm/rust-v1
|
||||||
@@ -42,7 +50,7 @@ modules:
|
|||||||
inputs:
|
inputs:
|
||||||
- map: map_relative_balances
|
- map: map_relative_balances
|
||||||
|
|
||||||
- name: map_changes
|
- name: map_protocol_changes
|
||||||
kind: map
|
kind: map
|
||||||
initialBlock: 12369300
|
initialBlock: 12369300
|
||||||
inputs:
|
inputs:
|
||||||
|
|||||||
@@ -3,6 +3,14 @@ package:
|
|||||||
name: "ethereum_template"
|
name: "ethereum_template"
|
||||||
version: v0.1.0
|
version: v0.1.0
|
||||||
|
|
||||||
|
protobuf:
|
||||||
|
files:
|
||||||
|
- tycho/evm/v1/vm.proto
|
||||||
|
- tycho/evm/v1/common.proto
|
||||||
|
- tycho/evm/v1/utils.proto
|
||||||
|
importPaths:
|
||||||
|
- ../../proto
|
||||||
|
|
||||||
binaries:
|
binaries:
|
||||||
default:
|
default:
|
||||||
type: wasm/rust-v1
|
type: wasm/rust-v1
|
||||||
|
|||||||
Reference in New Issue
Block a user