Skip to content

Commit

Permalink
[ECO-2719] Bump the processor submodule and update the SDK types for …
Browse files Browse the repository at this point in the history
…the new schema (#530)
  • Loading branch information
xbtmatt authored and alnoki committed Feb 4, 2025
1 parent aa445e0 commit 3e348f2
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 79 deletions.
3 changes: 2 additions & 1 deletion src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/rust/broker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ axum-extra = {version = "0.9.3", features = ["query"]}
env_logger = "0.11.5"
futures-util = "0.3.30"
log = "0.4.22"
num-traits = "0.2.19"
processor = {path = "../processor/rust/processor"}
serde = {version = "1.0.204", features = ["derive"]}
serde_json = "1.0.122"
Expand Down
27 changes: 13 additions & 14 deletions src/rust/broker/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use log::error;
use num_traits::ToPrimitive;
use processor::emojicoin_dot_fun::{EmojicoinDbEvent, EmojicoinDbEventType};
use tokio::signal;

Expand All @@ -7,25 +8,23 @@ use crate::types::Subscription;
/// Get the market ID of a EmojicoinDbEvent of a given EventType
#[allow(dead_code)]
pub fn get_market_id(event: &EmojicoinDbEvent) -> Result<u64, String> {
let market_id: Result<u64, _> = match event {
EmojicoinDbEvent::Swap(s) => s.market_id,
EmojicoinDbEvent::Chat(c) => c.market_id,
EmojicoinDbEvent::MarketRegistration(mr) => mr.market_id,
EmojicoinDbEvent::PeriodicState(ps) => ps.market_id,
EmojicoinDbEvent::MarketLatestState(mls) => mls.market_id,
EmojicoinDbEvent::Liquidity(l) => l.market_id,
let market_id = match event {
EmojicoinDbEvent::Swap(s) => &s.market_id,
EmojicoinDbEvent::Chat(c) => &c.market_id,
EmojicoinDbEvent::MarketRegistration(mr) => &mr.market_id,
EmojicoinDbEvent::PeriodicState(ps) => &ps.market_id,
EmojicoinDbEvent::MarketLatestState(mls) => &mls.market_id,
EmojicoinDbEvent::Liquidity(l) => &l.market_id,
_ => {
return Err(
"Trying to get market ID from event which does not have a market ID".to_string(),
)
}
}
.try_into();
if let Ok(market_id) = market_id {
Ok(market_id)
} else {
Err("Got negative market ID".to_string())
}
};

market_id
.to_u64()
.ok_or("Failed to convert BigDecimal to u64".to_string())
}

/// Returns true if the given subscription should receive the given event.
Expand Down
2 changes: 1 addition & 1 deletion src/rust/processor
Submodule processor updated 35 files
+1 −1 rust/processor/src/db/common/models/emojicoin_models/constants.rs
+21 −15 rust/processor/src/db/common/models/emojicoin_models/event_utils.rs
+72 −89 rust/processor/src/db/common/models/emojicoin_models/json_types.rs
+16 −16 rust/processor/src/db/common/models/emojicoin_models/models/chat_event.rs
+4 −4 rust/processor/src/db/common/models/emojicoin_models/models/global_state_event.rs
+19 −19 rust/processor/src/db/common/models/emojicoin_models/models/liquidity_event.rs
+2 −2 rust/processor/src/db/common/models/emojicoin_models/models/market_1m_periods_in_last_day.rs
+3 −3 rust/processor/src/db/common/models/emojicoin_models/models/market_24h_rolling_volume.rs
+14 −14 rust/processor/src/db/common/models/emojicoin_models/models/market_latest_state_event.rs
+5 −4 rust/processor/src/db/common/models/emojicoin_models/models/market_registration_event.rs
+13 −13 rust/processor/src/db/common/models/emojicoin_models/models/periodic_state_event.rs
+16 −16 rust/processor/src/db/common/models/emojicoin_models/models/swap_event.rs
+16 −15 rust/processor/src/db/common/models/emojicoin_models/models/user_liquidity_pools.rs
+39 −35 rust/processor/src/db/common/models/emojicoin_models/tests.rs
+7 −2 rust/processor/src/db/common/models/emojicoin_models/utils.rs
+59 −59 rust/processor/src/db/postgres/migrations/2024-08-08-024053_emojicoin_events/up.sql
+20 −20 rust/processor/src/db/postgres/migrations/2024-08-13-014340_add_latest_market_state_event/up.sql
+2 −2 rust/processor/src/db/postgres/migrations/2024-08-14-015329_add_daily_volume_and_tvl_growth/up.sql
+13 −13 rust/processor/src/db/postgres/migrations/2024-09-12-121842_user_pools/up.sql
+1 −1 rust/processor/src/db/postgres/migrations/2024-09-30-141128_price_feed/up.sql
+13 −13 rust/processor/src/db/postgres/migrations/2024-10-02-142213_update_user_pools_with_daily_vol/down.sql
+13 −13 rust/processor/src/db/postgres/migrations/2024-10-02-142213_update_user_pools_with_daily_vol/up.sql
+13 −13 rust/processor/src/db/postgres/migrations/2024-10-04-105346_fix_tvl_column_name/down.sql
+13 −13 rust/processor/src/db/postgres/migrations/2024-10-04-105346_fix_tvl_column_name/up.sql
+1 −1 rust/processor/src/db/postgres/migrations/2024-10-07-131051_fix_price_feed/down.sql
+1 −1 rust/processor/src/db/postgres/migrations/2024-10-07-131051_fix_price_feed/up.sql
+1 −1 rust/processor/src/db/postgres/migrations/2024-10-20-152751_rework_price_feed/down.sql
+1 −1 rust/processor/src/db/postgres/migrations/2024-10-20-152751_rework_price_feed/up.sql
+1 −1 rust/processor/src/db/postgres/migrations/2024-11-26-050428_add_market_data_to_price_feed/down.sql
+2 −2 rust/processor/src/db/postgres/migrations/2025-01-08-171729_emojicoin_arena/up.sql
+13 −13 rust/processor/src/db/postgres/migrations/2025-01-21-033858_add_daily_base_volume_to_user_pools/down.sql
+13 −13 rust/processor/src/db/postgres/migrations/2025-01-21-033858_add_daily_base_volume_to_user_pools/up.sql
+45 −25 rust/processor/src/db/postgres/migrations/2025-01-25-223042_add_data_integrity_check_at_txn_version/up.sql
+81 −81 rust/processor/src/db/postgres/schema.rs
+14 −6 rust/processor/src/processors/emojicoin_dot_fun/processor.rs
125 changes: 62 additions & 63 deletions src/typescript/sdk/src/indexer-v2/types/postgres-numeric-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,74 @@ export const PostgresNumericTypes = {
* @see schema.test.ts
*/
export const floatColumns: Set<AnyColumnName> = new Set([
"cumulative_quote_volume",
"total_quote_locked",
"total_value_locked",
"market_cap",
"fully_diluted_value",
"cumulative_integrator_fees",
"last_swap_avg_execution_price_q64",
"open_price_q64",
"high_price_q64",
"low_price_q64",
"close_price_q64",
"volume_base",
"volume_quote",
"integrator_fees",
"pool_fees_base",
"pool_fees_quote",
"tvl_per_lp_coin_growth_q64",
"avg_execution_price_q64",
"lp_coin_supply",
"balance_as_fraction_of_circulating_supply_after_q64",
"balance_as_fraction_of_circulating_supply_before_q64",
"balance_as_fraction_of_circulating_supply_q64",
"base_amount",
"base_donation_claim_amount",
"base_volume",
"base_volume_in_1m_state_tracker",
"circulating_supply",
"clamm_virtual_reserves_base",
"clamm_virtual_reserves_quote",
"close_price_q64",
"cpamm_real_reserves_base",
"cpamm_real_reserves_quote",
"cumulative_chat_messages",
"cumulative_integrator_fees",
"cumulative_quote_volume",
"cumulative_stats_base_volume",
"cumulative_stats_quote_volume",
"cumulative_stats_integrator_fees",
"cumulative_stats_n_chat_messages",
"cumulative_stats_n_swaps",
"cumulative_stats_pool_fees_base",
"cumulative_stats_pool_fees_quote",
"instantaneous_stats_total_value_locked",
"instantaneous_stats_market_cap",
"instantaneous_stats_fully_diluted_value",
"balance_as_fraction_of_circulating_supply_before_q64",
"balance_as_fraction_of_circulating_supply_after_q64",
"balance_as_fraction_of_circulating_supply_q64",
"cumulative_stats_quote_volume",
"cumulative_swaps",
"daily_base_volume",
"daily_tvl_per_lp_coin_growth",
"volume_in_1m_state_tracker",
"daily_volume",
"fully_diluted_value",
"high_price_q64",
"input_amount",
"instantaneous_stats_fully_diluted_value",
"instantaneous_stats_market_cap",
"instantaneous_stats_total_quote_locked",
"instantaneous_stats_total_value_locked",
"integrator_fee",
"integrator_fees",
"last_swap_avg_execution_price_q64",
"last_swap_base_volume",
"last_swap_nonce",
"last_swap_quote_volume",
"low_price_q64",
"lp_coin_amount",
"lp_coin_balance",
"lp_coin_supply",
"market_cap",
"market_id",
"market_nonce",
"n_chat_messages",
"n_swaps",
"net_proceeds",
"nonce",
"open_price_q64",
"pool_fee",
"pool_fees_base",
"pool_fees_quote",
"quote_amount",
"quote_donation_claim_amount",
"quote_volume",
"registry_nonce",
"total_quote_locked",
"total_value_locked",
"tvl_per_lp_coin_growth_q64",
"user_emojicoin_balance",
"volume",
"base_volume",
"base_volume_in_1m_state_tracker",
"daily_base_volume",
"volume_base",
"volume_in_1m_state_tracker",
"volume_quote",
]);

/**
Expand All @@ -70,42 +101,10 @@ export const floatColumns: Set<AnyColumnName> = new Set([
* @see schema.test.ts
*/
export const bigintColumns: Set<AnyColumnName> = new Set([
"transaction_version",
"registry_nonce",
"cumulative_swaps",
"cumulative_chat_messages",
"market_id",
"market_nonce",
"last_swap_base_volume",
"last_swap_quote_volume",
"last_swap_nonce",
"n_swaps",
"n_chat_messages",
"integrator_fee",
"input_amount",
"net_proceeds",
"base_volume",
"quote_volume",
"pool_fee",
"clamm_virtual_reserves_base",
"clamm_virtual_reserves_quote",
"cpamm_real_reserves_base",
"cpamm_real_reserves_quote",
"cumulative_stats_n_swaps",
"cumulative_stats_n_chat_messages",
"instantaneous_stats_total_quote_locked",
"base_amount",
"quote_amount",
"lp_coin_amount",
"base_donation_claim_amount",
"quote_donation_claim_amount",
"user_emojicoin_balance",
"circulating_supply",
"lp_coin_balance",
"nonce",
"last_success_version",
"block_number",
"event_index",
"last_success_version",
"transaction_version",
]);

/**
Expand Down
7 changes: 7 additions & 0 deletions src/typescript/sdk/tests/e2e/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,11 @@ describe("verifies the schema is what's expected", () => {
expect(marketStateColumnNames.has("daily_tvl_per_lp_coin_growth")).toBe(true);
expect(marketStateColumnNames.has("daily_tvl_per_lp_coin_growth_q64")).toBe(false);
});

it("ensures that there are no duplicate column names with different types", () => {
const mergedSetSize = new Set([...floatColumns, ...bigintColumns, ...integerColumns]).size;
const sumOfIndividualSetSize =
new Set(floatColumns).size + new Set(bigintColumns).size + new Set(integerColumns).size;
expect(mergedSetSize).toEqual(sumOfIndividualSetSize);
});
});

0 comments on commit 3e348f2

Please sign in to comment.