* 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
140 lines
3.5 KiB
Protocol Buffer
140 lines
3.5 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package ekubo;
|
|
|
|
// Copy of tycho.evm.v1.Transaction to be able to implement conversions to/from
|
|
// TransactionTrace
|
|
message Transaction {
|
|
bytes hash = 1;
|
|
bytes from = 2;
|
|
bytes to = 3;
|
|
uint64 index = 4;
|
|
}
|
|
|
|
message TickDelta {
|
|
bytes pool_id = 1; // bytes32
|
|
int32 tick_index = 2;
|
|
bytes liquidity_net_delta = 3; // int128
|
|
uint64 ordinal = 4;
|
|
Transaction transaction = 5;
|
|
}
|
|
|
|
message TickDeltas { repeated TickDelta deltas = 1; }
|
|
|
|
message OrderSaleRateDelta {
|
|
bytes pool_id = 1; // bytes32
|
|
uint64 time = 2;
|
|
bytes sale_rate_delta = 3; // int112
|
|
bool is_token1 = 4;
|
|
uint64 ordinal = 5;
|
|
Transaction transaction = 6;
|
|
}
|
|
|
|
message OrderSaleRateDeltas { repeated OrderSaleRateDelta deltas = 1; }
|
|
|
|
enum ChangeType {
|
|
DELTA = 0;
|
|
ABSOLUTE = 1;
|
|
}
|
|
|
|
message LiquidityChange {
|
|
bytes pool_id = 1; // bytes32
|
|
bytes value = 2; // uint128 or int128, depending on change_type
|
|
ChangeType change_type = 3;
|
|
uint64 ordinal = 4;
|
|
Transaction transaction = 5;
|
|
}
|
|
|
|
message LiquidityChanges { repeated LiquidityChange changes = 1; }
|
|
|
|
message SaleRateChange {
|
|
bytes pool_id = 1; // bytes32
|
|
bytes token0_value = 2; // uint112 or int112, depending on change_type
|
|
bytes token1_value = 3; // uint112 or int112, depending on change_type
|
|
ChangeType change_type = 4;
|
|
uint64 ordinal = 5;
|
|
Transaction transaction = 6;
|
|
}
|
|
|
|
message SaleRateChanges { repeated SaleRateChange changes = 1; }
|
|
|
|
message PoolDetails {
|
|
bytes token0 = 1; // address
|
|
bytes token1 = 2; // address
|
|
fixed64 fee = 3;
|
|
}
|
|
|
|
message BlockTransactionEvents {
|
|
repeated TransactionEvents block_transaction_events = 1;
|
|
uint64 timestamp = 2; // block timestamp
|
|
|
|
message TransactionEvents {
|
|
Transaction transaction = 1;
|
|
repeated PoolLog pool_logs = 2;
|
|
|
|
message PoolLog {
|
|
uint64 ordinal = 1;
|
|
bytes pool_id = 2; // bytes32
|
|
|
|
oneof event {
|
|
Swapped swapped = 3;
|
|
PositionUpdated position_updated = 4;
|
|
PoolInitialized pool_initialized = 5;
|
|
VirtualOrdersExecuted virtual_orders_executed = 6;
|
|
OrderUpdated order_updated = 7;
|
|
}
|
|
|
|
message Swapped {
|
|
bytes delta0 = 1; // int128
|
|
bytes delta1 = 2; // int128
|
|
bytes sqrt_ratio_after = 3; // uint192
|
|
bytes liquidity_after = 4; // uint128
|
|
sint32 tick_after = 5; // int32
|
|
}
|
|
|
|
message PositionUpdated {
|
|
sint32 lower = 1; // int32
|
|
sint32 upper = 2; // int32
|
|
bytes liquidity_delta = 3; // int128
|
|
bytes delta0 = 4; // int128
|
|
bytes delta1 = 5; // int128
|
|
}
|
|
|
|
message PoolInitialized {
|
|
bytes token0 = 1; // address
|
|
bytes token1 = 2; // address
|
|
bytes config = 3; // bytes32
|
|
sint32 tick = 4; // int32
|
|
bytes sqrt_ratio = 5; // uint192
|
|
Extension extension = 6;
|
|
|
|
enum Extension {
|
|
EXTENSION_UNKNOWN = 0;
|
|
EXTENSION_BASE = 1;
|
|
EXTENSION_ORACLE = 2;
|
|
EXTENSION_TWAMM = 3;
|
|
EXTENSION_MEV_RESIST = 4;
|
|
}
|
|
}
|
|
|
|
message VirtualOrdersExecuted {
|
|
bytes token0_sale_rate = 1; // int112
|
|
bytes token1_sale_rate = 2; // int112
|
|
}
|
|
|
|
message OrderUpdated {
|
|
OrderKey order_key = 1;
|
|
bytes sale_rate_delta = 2; // int112
|
|
|
|
message OrderKey {
|
|
bytes sell_token = 1; // address
|
|
bytes buy_token = 2; // address
|
|
fixed64 fee = 3;
|
|
uint64 start_time = 4; // block timestamp
|
|
uint64 end_time = 5; // block timestamp
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|