Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ moka = { version = "0.12", features = ["future"] }
toml = "0.8"
reqwest = { version = "0.13.2", features = ["json"] }
sha2 = "0.10"
rain_orderbook_js_api = { path = "lib/rain.orderbook/crates/js_api", default-features = false }
rain_orderbook_common = { path = "lib/rain.orderbook/crates/common", default-features = false }
rain_orderbook_app_settings = { path = "lib/rain.orderbook/crates/settings", default-features = false }
rain_orderbook_bindings = { path = "lib/rain.orderbook/crates/bindings", default-features = false }
rain_orderbook_js_api = { package = "raindex_js_api", path = "lib/rain.orderbook/crates/js_api", default-features = false }
rain_orderbook_common = { package = "raindex_common", path = "lib/rain.orderbook/crates/common", default-features = false }
rain_orderbook_app_settings = { package = "raindex_app_settings", path = "lib/rain.orderbook/crates/settings", default-features = false }
rain_orderbook_bindings = { package = "raindex_bindings", path = "lib/rain.orderbook/crates/bindings", default-features = false }
rain-math-float = { path = "lib/rain.orderbook/lib/rain.interpreter/lib/rain.interpreter.interface/lib/rain.math.float/crates/float" }
wasm-bindgen = "=0.2.100"

Expand Down
Binary file modified infra/terraform.tfstate.age
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/rain.orderbook
50 changes: 25 additions & 25 deletions src/routes/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::types::health::{
NetworkSyncInfo, OrderbookSyncInfo, RaindexSyncStatus, RaindexSyncStatusKind,
};
use rain_orderbook_common::raindex_client::local_db::{
LocalDbSyncSnapshot, NetworkSyncStatusSnapshot, OrderbookSyncStatusSnapshot,
LocalDbSyncSnapshot, NetworkSyncStatusSnapshot, RaindexSyncStatusSnapshot,
};
use rocket::serde::json::Json;
use rocket::{Route, State};
Expand Down Expand Up @@ -126,9 +126,9 @@ fn map_raindex_snapshot(snapshot: LocalDbSyncSnapshot) -> RaindexSyncStatus {
.map(map_network_snapshot)
.collect(),
orderbooks: snapshot
.orderbooks
.raindexes
.into_iter()
.map(map_orderbook_snapshot)
.map(map_raindex_status_snapshot)
.collect(),
}
}
Expand All @@ -138,17 +138,17 @@ fn map_network_snapshot(snapshot: NetworkSyncStatusSnapshot) -> NetworkSyncInfo
chain_id: snapshot.chain_id,
network_key: snapshot.network_key,
status: snapshot.status.into(),
orderbook_count: snapshot.orderbook_count,
orderbook_count: snapshot.raindex_count,
ready: snapshot.ready,
error: snapshot.error.map(|_| "network sync failed".to_string()),
}
}

fn map_orderbook_snapshot(snapshot: OrderbookSyncStatusSnapshot) -> OrderbookSyncInfo {
fn map_raindex_status_snapshot(snapshot: RaindexSyncStatusSnapshot) -> OrderbookSyncInfo {
OrderbookSyncInfo {
chain_id: snapshot.ob_id.chain_id,
orderbook_address: format!("{:#x}", snapshot.ob_id.orderbook_address),
orderbook_key: snapshot.orderbook_key,
chain_id: snapshot.raindex_id.chain_id,
orderbook_address: format!("{:#x}", snapshot.raindex_id.raindex_address),
orderbook_key: snapshot.raindex_key,
network_key: snapshot.network_key,
status: snapshot.status.into(),
ready: snapshot.ready,
Expand All @@ -171,13 +171,13 @@ fn log_raindex_snapshot_errors(snapshot: &LocalDbSyncSnapshot) {
}
}

for orderbook in &snapshot.orderbooks {
if let Some(error) = &orderbook.error {
for raindex in &snapshot.raindexes {
if let Some(error) = &raindex.error {
tracing::warn!(
chain_id = orderbook.ob_id.chain_id,
orderbook_address = %format!("{:#x}", orderbook.ob_id.orderbook_address),
orderbook_key = orderbook.orderbook_key.as_deref(),
network_key = orderbook.network_key.as_deref(),
chain_id = raindex.raindex_id.chain_id,
orderbook_address = %format!("{:#x}", raindex.raindex_id.raindex_address),
orderbook_key = raindex.raindex_key.as_deref(),
network_key = raindex.network_key.as_deref(),
error = %error,
"raindex orderbook sync failed"
);
Expand Down Expand Up @@ -215,7 +215,7 @@ pub fn routes() -> Vec<Route> {
mod tests {
use super::*;
use alloy::primitives::address;
use rain_orderbook_common::local_db::OrderbookIdentifier;
use rain_orderbook_common::local_db::RaindexIdentifier;
use rain_orderbook_common::raindex_client::local_db::{LocalDbStatus, SchedulerState};

#[test]
Expand Down Expand Up @@ -278,20 +278,20 @@ mod tests {
#[test]
fn map_raindex_snapshot_preserves_network_and_orderbook_status() {
let orderbook_id =
OrderbookIdentifier::new(8453, address!("d2938e7c9fe3597f78832ce780feb61945c377d7"));
RaindexIdentifier::new(8453, address!("d2938e7c9fe3597f78832ce780feb61945c377d7"));
let snapshot = LocalDbSyncSnapshot::from_parts(
vec![NetworkSyncStatusSnapshot {
chain_id: 8453,
network_key: Some("base".to_string()),
status: LocalDbStatus::Active,
scheduler_state: SchedulerState::Leader,
orderbook_count: 1,
raindex_count: 1,
ready: true,
error: None,
}],
vec![OrderbookSyncStatusSnapshot {
ob_id: orderbook_id,
orderbook_key: Some("base-orderbook".to_string()),
vec![RaindexSyncStatusSnapshot {
raindex_id: orderbook_id,
raindex_key: Some("base-orderbook".to_string()),
network_key: Some("base".to_string()),
status: LocalDbStatus::Active,
scheduler_state: SchedulerState::Leader,
Expand Down Expand Up @@ -325,20 +325,20 @@ mod tests {
#[test]
fn map_raindex_snapshot_sanitizes_sync_errors() {
let orderbook_id =
OrderbookIdentifier::new(8453, address!("d2938e7c9fe3597f78832ce780feb61945c377d7"));
RaindexIdentifier::new(8453, address!("d2938e7c9fe3597f78832ce780feb61945c377d7"));
let snapshot = LocalDbSyncSnapshot::from_parts(
vec![NetworkSyncStatusSnapshot {
chain_id: 8453,
network_key: Some("base".to_string()),
status: LocalDbStatus::Failure,
scheduler_state: SchedulerState::Leader,
orderbook_count: 1,
raindex_count: 1,
ready: false,
error: Some("sqlite: no such table sync_status".to_string()),
}],
vec![OrderbookSyncStatusSnapshot {
ob_id: orderbook_id,
orderbook_key: Some("base-orderbook".to_string()),
vec![RaindexSyncStatusSnapshot {
raindex_id: orderbook_id,
raindex_key: Some("base-orderbook".to_string()),
network_key: Some("base".to_string()),
status: LocalDbStatus::Failure,
scheduler_state: SchedulerState::Leader,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/order/cancel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async fn process_cancel_order(
let calldata = ds.get_remove_calldata(&order).await?;

let tx = CancelTransaction {
to: order.orderbook(),
to: order.raindex(),
data: calldata,
value: U256::ZERO,
};
Expand Down
2 changes: 1 addition & 1 deletion src/routes/order/get_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn build_order_detail(
output_vault_balance: output.formatted_balance(),
io_ratio: io_ratio.to_string(),
created_at,
orderbook_id: order.orderbook(),
orderbook_id: order.raindex(),
trades: trade_entries,
})
}
Expand Down
20 changes: 10 additions & 10 deletions src/routes/order/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ pub(crate) mod test_fixtures {

pub fn stub_raindex_client() -> serde_json::Value {
json!({
"orderbook_yaml": {
"documents": ["version: 5\nnetworks:\n base:\n rpcs:\n - https://mainnet.base.org\n chain-id: 8453\n currency: ETH\nsubgraphs:\n base: https://example.com/sg\norderbooks:\n base:\n address: 0xd2938e7c9fe3597f78832ce780feb61945c377d7\n network: base\n subgraph: base\n deployment-block: 0\ndeployers:\n base:\n address: 0xC1A14cE2fd58A3A2f99deCb8eDd866204eE07f8D\n network: base\n"],
"raindex_yaml": {
"documents": ["version: 6\nnetworks:\n base:\n rpcs:\n - https://mainnet.base.org\n chain-id: 8453\n currency: ETH\nsubgraphs:\n base: https://example.com/sg\nraindexes:\n base:\n address: 0xd2938e7c9fe3597f78832ce780feb61945c377d7\n network: base\n subgraph: base\n deployment-block: 0\ndeployers:\n base:\n address: 0xC1A14cE2fd58A3A2f99deCb8eDd866204eE07f8D\n network: base\n"],
"profile": "strict"
}
})
Expand All @@ -132,7 +132,7 @@ pub(crate) mod test_fixtures {
"orderBytes": "0x01",
"orderHash": "0x000000000000000000000000000000000000000000000000000000000000abcd",
"owner": "0x0000000000000000000000000000000000000001",
"orderbook": "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
"raindex": "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
"active": true,
"timestampAdded": "0x000000000000000000000000000000000000000000000000000000006553f100",
"meta": null,
Expand Down Expand Up @@ -162,7 +162,7 @@ pub(crate) mod test_fixtures {
"symbol": "USDC",
"decimals": 6
},
"orderbook": "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
"raindex": "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
"ordersAsInputs": [],
"ordersAsOutputs": []
}],
Expand All @@ -183,7 +183,7 @@ pub(crate) mod test_fixtures {
"symbol": "WETH",
"decimals": 18
},
"orderbook": "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
"raindex": "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
"ordersAsInputs": [],
"ordersAsOutputs": []
}]
Expand Down Expand Up @@ -228,7 +228,7 @@ pub(crate) mod test_fixtures {
"blockNumber": "0x0000000000000000000000000000000000000000000000000000000000000064",
"timestamp": "0x000000000000000000000000000000000000000000000000000000006553f4e8"
},
"orderbook": "0xd2938e7c9fe3597f78832ce780feb61945c377d7"
"raindex": "0xd2938e7c9fe3597f78832ce780feb61945c377d7"
},
"outputVaultBalanceChange": {
"type": "takeOrder",
Expand All @@ -254,10 +254,10 @@ pub(crate) mod test_fixtures {
"blockNumber": "0x0000000000000000000000000000000000000000000000000000000000000064",
"timestamp": "0x000000000000000000000000000000000000000000000000000000006553f4e8"
},
"orderbook": "0xd2938e7c9fe3597f78832ce780feb61945c377d7"
"raindex": "0xd2938e7c9fe3597f78832ce780feb61945c377d7"
},
"timestamp": "0x000000000000000000000000000000000000000000000000000000006553f4e8",
"orderbook": "0xd2938e7c9fe3597f78832ce780feb61945c377d7"
"raindex": "0xd2938e7c9fe3597f78832ce780feb61945c377d7"
})
}

Expand Down Expand Up @@ -310,7 +310,7 @@ pub(crate) mod test_fixtures {
"symbol": token_symbol,
"decimals": decimals
},
"orderbook": "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
"raindex": "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
"ordersAsInputs": [],
"ordersAsOutputs": []
})
Expand Down Expand Up @@ -340,7 +340,7 @@ pub(crate) mod test_fixtures {
"orderBytes": "0x01",
"orderHash": "0x000000000000000000000000000000000000000000000000000000000000beef",
"owner": "0x0000000000000000000000000000000000000001",
"orderbook": "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
"raindex": "0xd2938e7c9fe3597f78832ce780feb61945c377d7",
"active": true,
"timestampAdded": "0x000000000000000000000000000000000000000000000000000000006553f100",
"meta": null,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/orders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pub(crate) fn build_order_summary(
output_vault_balance: output.formatted_balance(),
io_ratio: io_ratio.to_string(),
created_at,
orderbook_id: order.orderbook(),
orderbook_id: order.raindex(),
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/routes/swap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<'a> SwapDataSource for RaindexSwapDataSource<'a> {
ApiError::Internal("failed to format expected sell".into())
})?;
Ok(SwapCalldataResponse {
to: take_orders_info.orderbook(),
to: take_orders_info.raindex(),
data: take_orders_info.calldata().clone(),
value: alloy::primitives::U256::ZERO,
estimated_input: expected_sell,
Expand Down
Loading
Loading