Ekubo TWAMM & MEV-resist integration (#192)
* 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
This commit is contained in:
@@ -2,7 +2,8 @@ syntax = "proto3";
|
||||
|
||||
package ekubo;
|
||||
|
||||
// Copy of tycho.evm.v1.Transaction to be able to implement conversions to/from TransactionTrace
|
||||
// Copy of tycho.evm.v1.Transaction to be able to implement conversions to/from
|
||||
// TransactionTrace
|
||||
message Transaction {
|
||||
bytes hash = 1;
|
||||
bytes from = 2;
|
||||
@@ -18,27 +19,45 @@ message TickDelta {
|
||||
Transaction transaction = 5;
|
||||
}
|
||||
|
||||
message TickDeltas {
|
||||
repeated TickDelta deltas = 1;
|
||||
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;
|
||||
}
|
||||
|
||||
enum LiquidityChangeType {
|
||||
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
|
||||
LiquidityChangeType change_type = 3;
|
||||
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 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
|
||||
@@ -47,6 +66,7 @@ message PoolDetails {
|
||||
|
||||
message BlockTransactionEvents {
|
||||
repeated TransactionEvents block_transaction_events = 1;
|
||||
uint64 timestamp = 2; // block timestamp
|
||||
|
||||
message TransactionEvents {
|
||||
Transaction transaction = 1;
|
||||
@@ -59,37 +79,32 @@ message BlockTransactionEvents {
|
||||
oneof event {
|
||||
Swapped swapped = 3;
|
||||
PositionUpdated position_updated = 4;
|
||||
PositionFeesCollected position_fees_collected = 5;
|
||||
PoolInitialized pool_initialized = 6;
|
||||
FeesAccumulated fees_accumulated = 7;
|
||||
PoolInitialized pool_initialized = 5;
|
||||
VirtualOrdersExecuted virtual_orders_executed = 6;
|
||||
OrderUpdated order_updated = 7;
|
||||
}
|
||||
|
||||
message Swapped {
|
||||
bytes delta0 = 1; // int128
|
||||
bytes delta1 = 2; // int128
|
||||
bytes delta0 = 1; // int128
|
||||
bytes delta1 = 2; // int128
|
||||
bytes sqrt_ratio_after = 3; // uint192
|
||||
bytes liquidity_after = 4; // uint128
|
||||
sint32 tick_after = 5; // int32
|
||||
bytes liquidity_after = 4; // uint128
|
||||
sint32 tick_after = 5; // int32
|
||||
}
|
||||
|
||||
message PositionUpdated {
|
||||
sint32 lower = 1; // int32
|
||||
sint32 upper = 2; // int32
|
||||
sint32 lower = 1; // int32
|
||||
sint32 upper = 2; // int32
|
||||
bytes liquidity_delta = 3; // int128
|
||||
bytes delta0 = 4; // int128
|
||||
bytes delta1 = 5; // int128
|
||||
}
|
||||
|
||||
message PositionFeesCollected {
|
||||
bytes amount0 = 1; // uint128
|
||||
bytes amount1 = 2; // uint128
|
||||
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 token0 = 1; // address
|
||||
bytes token1 = 2; // address
|
||||
bytes config = 3; // bytes32
|
||||
sint32 tick = 4; // int32
|
||||
bytes sqrt_ratio = 5; // uint192
|
||||
Extension extension = 6;
|
||||
|
||||
@@ -97,12 +112,27 @@ message BlockTransactionEvents {
|
||||
EXTENSION_UNKNOWN = 0;
|
||||
EXTENSION_BASE = 1;
|
||||
EXTENSION_ORACLE = 2;
|
||||
EXTENSION_TWAMM = 3;
|
||||
EXTENSION_MEV_RESIST = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message FeesAccumulated {
|
||||
bytes amount0 = 1; // uint128
|
||||
bytes amount1 = 2; // uint128
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user