* Add Ekubo TWAMM support * Change order of words * Account TWAMM order balances * Fix tracking wrong component balance deltas Swapped and PositionUpdated are the only events affecting pool TVL * Fix fee addition Fees are a .64 instead of a .128 since v2 & the result is rounded * Consistent naming * cargo fmt * Add method for selecting store method from change type * Only store the affected sale rate delta on OrderUpdated events * Remove unnecessary parameterization * Index Ekubo MEV-resist pools * cargo clippy
28 lines
841 B
Rust
28 lines
841 B
Rust
use substreams::scalar::BigInt;
|
|
|
|
use crate::pool_key::{PoolConfig, PoolKey};
|
|
|
|
pub type OrderKey = (Vec<u8>, Vec<u8>, BigInt, BigInt, BigInt);
|
|
|
|
impl PoolKey {
|
|
pub fn from_order_key(key: &OrderKey, twamm_address: &Vec<u8>) -> Self {
|
|
let (token0, token1) = if key.1 > key.0 { (&key.0, &key.1) } else { (&key.1, &key.0) };
|
|
|
|
Self {
|
|
token0: <&[u8; 20]>::try_from(token0.as_slice())
|
|
.unwrap()
|
|
.into(),
|
|
token1: <&[u8; 20]>::try_from(token1.as_slice())
|
|
.unwrap()
|
|
.into(),
|
|
config: PoolConfig {
|
|
fee: key.2.to_u64(),
|
|
tick_spacing: 0,
|
|
extension: <&[u8; 20]>::try_from(twamm_address.as_slice())
|
|
.unwrap()
|
|
.into(),
|
|
},
|
|
}
|
|
}
|
|
}
|