valdiate: 3pool and steth-eth
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,23 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "3pool",
|
"name": "3pool",
|
||||||
"address": "bEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7",
|
"address": "bebc44782c7db0a1a60cb6fe97d0b483032ff1c7",
|
||||||
"tx_hash": "20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6",
|
"tx_hash": "e90adc0e0a1ae9dde6c240b348adef761444e61f4194245a2096f7ca8310ac2f",
|
||||||
"tokens": [
|
"tokens": [
|
||||||
"6b175474e89094c44da98b954eedeac495271d0f",
|
"6b175474e89094c44da98b954eedeac495271d0f",
|
||||||
"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
"a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
||||||
"dac17f958d2ee523a2206206994597c13d831ec7"
|
"dac17f958d2ee523a2206206994597c13d831ec7"
|
||||||
],
|
],
|
||||||
"attributes": {}
|
"attributes": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "steth",
|
||||||
|
"address": "dc24316b9ae028f1497c275eb9192a3ea0f67022",
|
||||||
|
"tx_hash": "d844051b63ce310f0f354e29e8c7f550a02fcd3bc642592a2eae6a2804e17d9c",
|
||||||
|
"tokens": [
|
||||||
|
"EeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
||||||
|
"ae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
|
||||||
|
],
|
||||||
|
"attributes": {}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -4,6 +4,7 @@ use anyhow::Result;
|
|||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use substreams::{
|
use substreams::{
|
||||||
pb::substreams::StoreDeltas,
|
pb::substreams::StoreDeltas,
|
||||||
|
scalar::BigInt,
|
||||||
store::{
|
store::{
|
||||||
StoreAdd, StoreAddBigInt, StoreAddInt64, StoreGet, StoreGetInt64, StoreGetString, StoreNew,
|
StoreAdd, StoreAddBigInt, StoreAddInt64, StoreGet, StoreGetInt64, StoreGetString, StoreNew,
|
||||||
StoreSet, StoreSetString,
|
StoreSet, StoreSetString,
|
||||||
@@ -179,7 +180,7 @@ pub fn map_protocol_changes(
|
|||||||
.extend_from_slice(&tx_component.components);
|
.extend_from_slice(&tx_component.components);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Balance changes are gathered by the `StoreDelta` based on `PoolBalanceChanged` creating
|
// Balance changes are gathered by the `StoreDelta` based on `TokenExchange`, etc. creating
|
||||||
// `BalanceDeltas`. We essentially just process the changes that occured to the `store` this
|
// `BalanceDeltas`. We essentially just process the changes that occured to the `store` this
|
||||||
// block. Then, these balance changes are merged onto the existing map of tx contract changes,
|
// block. Then, these balance changes are merged onto the existing map of tx contract changes,
|
||||||
// inserting a new one if it doesn't exist.
|
// inserting a new one if it doesn't exist.
|
||||||
@@ -188,14 +189,16 @@ pub fn map_protocol_changes(
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.zip(deltas.balance_deltas)
|
.zip(deltas.balance_deltas)
|
||||||
.map(|(store_delta, balance_delta)| {
|
.map(|(store_delta, balance_delta)| {
|
||||||
let pool_id = key::segment_at(&store_delta.key, 1);
|
let new_value_string = String::from_utf8_lossy(&store_delta.new_value).to_string();
|
||||||
let token_id = key::segment_at(&store_delta.key, 3);
|
|
||||||
(
|
(
|
||||||
balance_delta.tx.unwrap(),
|
balance_delta.tx.unwrap(),
|
||||||
BalanceChange {
|
BalanceChange {
|
||||||
token: hex::decode(token_id).expect("Token ID not valid hex"),
|
token: balance_delta.token,
|
||||||
balance: store_delta.new_value,
|
balance: BigInt::try_from(new_value_string)
|
||||||
component_id: hex::decode(pool_id).expect("Token ID not valid hex"),
|
.unwrap()
|
||||||
|
.to_signed_bytes_be(),
|
||||||
|
component_id: hex::decode(balance_delta.component_id)
|
||||||
|
.expect("Pool ID not valid hex"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use substreams::{
|
use substreams::{
|
||||||
|
hex,
|
||||||
scalar::BigInt,
|
scalar::BigInt,
|
||||||
store::{StoreGet, StoreGetInt64, StoreGetString},
|
store::{StoreGet, StoreGetInt64, StoreGetString},
|
||||||
};
|
};
|
||||||
@@ -37,9 +38,10 @@ pub fn emit_deltas(
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
if let Some(event) = abi::pool::events::TokenExchange::match_and_decode(log) {
|
if let Some(event) = abi::pool::events::TokenExchange::match_and_decode(log) {
|
||||||
token_change_deltas(event, log)
|
token_change_deltas(tokens, event, log)
|
||||||
} else if let Some(event) = abi::pool_3pool::events::TokenExchange::match_and_decode(log) {
|
} else if let Some(event) = abi::pool_3pool::events::TokenExchange::match_and_decode(log) {
|
||||||
token_change_deltas(
|
token_change_deltas(
|
||||||
|
tokens,
|
||||||
abi::pool::events::TokenExchange {
|
abi::pool::events::TokenExchange {
|
||||||
sold_id: event.sold_id,
|
sold_id: event.sold_id,
|
||||||
bought_id: event.bought_id,
|
bought_id: event.bought_id,
|
||||||
@@ -51,6 +53,7 @@ pub fn emit_deltas(
|
|||||||
)
|
)
|
||||||
} else if let Some(event) = abi::pool_steth::events::TokenExchange::match_and_decode(log) {
|
} else if let Some(event) = abi::pool_steth::events::TokenExchange::match_and_decode(log) {
|
||||||
token_change_deltas(
|
token_change_deltas(
|
||||||
|
tokens,
|
||||||
abi::pool::events::TokenExchange {
|
abi::pool::events::TokenExchange {
|
||||||
sold_id: event.sold_id,
|
sold_id: event.sold_id,
|
||||||
bought_id: event.bought_id,
|
bought_id: event.bought_id,
|
||||||
@@ -62,6 +65,7 @@ pub fn emit_deltas(
|
|||||||
)
|
)
|
||||||
} else if let Some(event) = abi::pool_tricrypto::events::TokenExchange::match_and_decode(log) {
|
} else if let Some(event) = abi::pool_tricrypto::events::TokenExchange::match_and_decode(log) {
|
||||||
token_change_deltas(
|
token_change_deltas(
|
||||||
|
tokens,
|
||||||
abi::pool::events::TokenExchange {
|
abi::pool::events::TokenExchange {
|
||||||
sold_id: event.sold_id,
|
sold_id: event.sold_id,
|
||||||
bought_id: event.bought_id,
|
bought_id: event.bought_id,
|
||||||
@@ -94,24 +98,27 @@ pub fn emit_deltas(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn token_change_deltas(
|
fn token_change_deltas(
|
||||||
|
tokens: Vec<String>,
|
||||||
event: abi::pool::events::TokenExchange,
|
event: abi::pool::events::TokenExchange,
|
||||||
log: LogView<'_>,
|
log: LogView<'_>,
|
||||||
) -> Option<Vec<BalanceDelta>> {
|
) -> Option<Vec<BalanceDelta>> {
|
||||||
let tokens_bought_delta: BigInt = event.tokens_bought * -1;
|
let tokens_bought_delta: BigInt = event.tokens_bought * -1;
|
||||||
|
let sold_token_id = &tokens[event.sold_id.to_u64() as usize];
|
||||||
|
let bought_token_id = &tokens[event.bought_id.to_u64() as usize];
|
||||||
Some(vec![
|
Some(vec![
|
||||||
BalanceDelta {
|
BalanceDelta {
|
||||||
ord: log.log.ordinal,
|
ord: log.log.ordinal,
|
||||||
tx: Some(tx_from_log(&log)),
|
tx: Some(tx_from_log(&log)),
|
||||||
token: event.sold_id.to_signed_bytes_be(),
|
token: hex::decode(sold_token_id.clone()).unwrap(),
|
||||||
delta: event.tokens_sold.to_signed_bytes_be(),
|
delta: event.tokens_sold.to_signed_bytes_be(),
|
||||||
component_id: log.address().into(),
|
component_id: hex::encode(log.address()).into(),
|
||||||
},
|
},
|
||||||
BalanceDelta {
|
BalanceDelta {
|
||||||
ord: log.log.ordinal,
|
ord: log.log.ordinal,
|
||||||
tx: Some(tx_from_log(&log)),
|
tx: Some(tx_from_log(&log)),
|
||||||
token: event.bought_id.to_signed_bytes_be(),
|
token: hex::decode(bought_token_id.clone()).unwrap(),
|
||||||
delta: tokens_bought_delta.to_signed_bytes_be(),
|
delta: tokens_bought_delta.to_signed_bytes_be(),
|
||||||
component_id: log.address().into(),
|
component_id: hex::encode(log.address()).into(),
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
@@ -128,9 +135,9 @@ fn add_liquidity_deltas(
|
|||||||
.map(move |(token_amount, token_id)| BalanceDelta {
|
.map(move |(token_amount, token_id)| BalanceDelta {
|
||||||
ord: log.log.ordinal,
|
ord: log.log.ordinal,
|
||||||
tx: Some(tx_from_log(&log)),
|
tx: Some(tx_from_log(&log)),
|
||||||
token: token_id.as_str().into(),
|
token: hex::decode(token_id).unwrap(),
|
||||||
delta: token_amount.to_signed_bytes_be(),
|
delta: token_amount.to_signed_bytes_be(),
|
||||||
component_id: log.address().into(),
|
component_id: hex::encode(log.address()).into(),
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
)
|
)
|
||||||
@@ -148,9 +155,9 @@ fn remove_liquidity_deltas(
|
|||||||
.map(move |(token_amount, token_id)| BalanceDelta {
|
.map(move |(token_amount, token_id)| BalanceDelta {
|
||||||
ord: log.log.ordinal,
|
ord: log.log.ordinal,
|
||||||
tx: Some(tx_from_log(&log)),
|
tx: Some(tx_from_log(&log)),
|
||||||
token: token_id.as_str().into(),
|
token: hex::decode(token_id).unwrap(),
|
||||||
delta: token_amount.to_signed_bytes_be(),
|
delta: token_amount.to_signed_bytes_be(),
|
||||||
component_id: log.address().into(),
|
component_id: hex::encode(log.address()).into(),
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ struct PoolQueryParams {
|
|||||||
/// Static attributes are defined as a vector of tuples with the name and value of the attribute.
|
/// Static attributes are defined as a vector of tuples with the name and value of the attribute.
|
||||||
/// These contain things like the pool type, specific pool fees, etc. You can see
|
/// These contain things like the pool type, specific pool fees, etc. You can see
|
||||||
/// `pool_factories.rs` for an example of the modern curve pool attributes and also the ones chosen
|
/// `pool_factories.rs` for an example of the modern curve pool attributes and also the ones chosen
|
||||||
/// for 3pool, etc.
|
/// for 3pool, etc.
|
||||||
///
|
///
|
||||||
/// This function can error based on some basic parsing errors and deeper down hex decoding errors
|
/// This function can error based on some basic parsing errors and deeper down hex decoding errors
|
||||||
/// if various addresses are not formatted properly.
|
/// if various addresses are not formatted properly.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ binaries:
|
|||||||
modules:
|
modules:
|
||||||
- name: map_components
|
- name: map_components
|
||||||
kind: map
|
kind: map
|
||||||
initialBlock: 10809473
|
initialBlock: 19355224
|
||||||
inputs:
|
inputs:
|
||||||
- params: string
|
- params: string
|
||||||
- source: sf.ethereum.type.v2.Block
|
- source: sf.ethereum.type.v2.Block
|
||||||
@@ -28,7 +28,7 @@ modules:
|
|||||||
|
|
||||||
- name: store_components
|
- name: store_components
|
||||||
kind: store
|
kind: store
|
||||||
initialBlock: 10809473
|
initialBlock: 19355224
|
||||||
updatePolicy: add
|
updatePolicy: add
|
||||||
valueType: int64
|
valueType: int64
|
||||||
inputs:
|
inputs:
|
||||||
@@ -36,7 +36,7 @@ modules:
|
|||||||
|
|
||||||
- name: store_component_tokens
|
- name: store_component_tokens
|
||||||
kind: store
|
kind: store
|
||||||
initialBlock: 10809473
|
initialBlock: 19355224
|
||||||
updatePolicy: set
|
updatePolicy: set
|
||||||
valueType: string
|
valueType: string
|
||||||
inputs:
|
inputs:
|
||||||
@@ -44,7 +44,7 @@ modules:
|
|||||||
|
|
||||||
- name: map_relative_balances
|
- name: map_relative_balances
|
||||||
kind: map
|
kind: map
|
||||||
initialBlock: 10809473 # An arbitrary block that should change based on your requirements
|
initialBlock: 19355224 # An arbitrary block that should change based on your requirements
|
||||||
inputs:
|
inputs:
|
||||||
- source: sf.ethereum.type.v2.Block
|
- source: sf.ethereum.type.v2.Block
|
||||||
- store: store_components
|
- store: store_components
|
||||||
@@ -54,7 +54,7 @@ modules:
|
|||||||
|
|
||||||
- name: store_balances
|
- name: store_balances
|
||||||
kind: store
|
kind: store
|
||||||
initialBlock: 10809473
|
initialBlock: 19355224
|
||||||
updatePolicy: add
|
updatePolicy: add
|
||||||
valueType: bigint
|
valueType: bigint
|
||||||
inputs:
|
inputs:
|
||||||
@@ -62,7 +62,7 @@ modules:
|
|||||||
|
|
||||||
- name: map_protocol_changes
|
- name: map_protocol_changes
|
||||||
kind: map
|
kind: map
|
||||||
initialBlock: 10809473
|
initialBlock: 19355224
|
||||||
inputs:
|
inputs:
|
||||||
- source: sf.ethereum.type.v2.Block
|
- source: sf.ethereum.type.v2.Block
|
||||||
- map: map_components
|
- map: map_components
|
||||||
|
|||||||
Reference in New Issue
Block a user