Skip to content

Commit

Permalink
Merge branch 'main' into 1060-withdraw2-task-not-being-executed-when-…
Browse files Browse the repository at this point in the history
…withdrawamount-is-0
  • Loading branch information
thedavidmeister authored Dec 29, 2024
2 parents e5b8233 + d566b4b commit e60119b
Show file tree
Hide file tree
Showing 109 changed files with 5,618 additions and 1,805 deletions.
339 changes: 172 additions & 167 deletions .gas-snapshot

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .github/workflows/manual-sol-artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
echo "verifier_url_secret_name=CI_DEPLOY_${network^^}_VERIFIER_URL" >> $GITHUB_ENV
echo "metaboard_address_secret_name=CI_DEPLOY_${network^^}_METABOARD_ADDRESS" >> $GITHUB_ENV
echo "route_processor_4_address_secret_name=CI_DEPLOY_${network^^}_ROUTE_PROCESSOR_4_ADDRESS" >> $GITHUB_ENV
echo "raindex_address_secret_name=CI_DEPLOY_${network^^}_RAINDEX_ADDRESS" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
Expand All @@ -71,4 +72,5 @@ jobs:
DEPLOY_VERIFIER: ${{ secrets[env.verifier_secret_name] || vars[env.verifier_secret_name] || '' }}
DEPLOY_VERIFIER_URL: ${{ secrets[env.verifier_url_secret_name] || vars[env.verifier_url_secret_name] || '' }}
DEPLOY_METABOARD_ADDRESS: ${{ secrets[env.metaboard_address_secret_name] || vars[env.metaboard_address_secret_name] || '' }}
DEPLOY_ROUTE_PROCESSOR_4_ADDRESS: ${{ secrets[env.route_processor_4_address_secret_name] || vars[env.route_processor_4_address_secret_name] || '' }}
DEPLOY_ROUTE_PROCESSOR_4_ADDRESS: ${{ secrets[env.route_processor_4_address_secret_name] || vars[env.route_processor_4_address_secret_name] || '' }}
DEPLOY_RAINDEX_ADDRESS: ${{ secrets[env.raindex_address_secret_name] || vars[env.raindex_address_secret_name] || '' }}
6 changes: 1 addition & 5 deletions .github/workflows/tauri-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,10 @@ jobs:

- run: nix develop .#tauri-shell -c ob-tauri-unit-test

- run: nix develop .#tauri-shell --command ob-tauri-before-build-ci
working-directory: ./tauri-app
env:
WALLETCONNECT_PROJECT_ID: ${{ secrets.WALLETCONNECT_PROJECT_ID }}

- run: nix develop .#tauri-shell --command ob-tauri-before-release
working-directory: ./tauri-app
env:
VITE_WALLETCONNECT_PROJECT_ID: ${{ secrets.WALLETCONNECT_PROJECT_ID }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_ORG: rainlang
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"svelte.enable-ts-plugin": true,

"rust-analyzer.linkedProjects": ["./Cargo.toml", "tauri-app/src-tauri/Cargo.toml"],

"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true,
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

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

15 changes: 12 additions & 3 deletions crates/common/src/add_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,10 @@ price: 2e18;
};
let network_arc = Arc::new(network);
let deployer = Deployer {
document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))),
key: "".to_string(),
network: network_arc.clone(),
address: Address::default(),
label: None,
};
let deployer_arc = Arc::new(deployer);
let scenario = Scenario {
Expand Down Expand Up @@ -483,6 +484,8 @@ price: 2e18;
let token3_arc = Arc::new(token3);
let known_vault_id = U256::from(1);
let order = Order {
document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))),
key: "".to_string(),
inputs: vec![
OrderIO {
token: token1_arc.clone(),
Expand Down Expand Up @@ -544,9 +547,10 @@ _ _: 0 0;
};
let network_arc = Arc::new(network);
let deployer = Deployer {
document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))),
key: "".to_string(),
network: network_arc.clone(),
address: *local_evm.deployer.address(),
label: None,
};
let deployer_arc = Arc::new(deployer);
let scenario = Scenario {
Expand Down Expand Up @@ -587,6 +591,8 @@ _ _: 0 0;
let token2_arc = Arc::new(token2);
let token3_arc = Arc::new(token3);
let order = Order {
document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))),
key: "".to_string(),
inputs: vec![
OrderIO {
token: token1_arc.clone(),
Expand Down Expand Up @@ -683,9 +689,10 @@ _ _: 0 0;
};
let network_arc = Arc::new(network);
let deployer = Deployer {
document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))),
key: "".to_string(),
network: network_arc.clone(),
address: Address::default(),
label: None,
};
let deployer_arc = Arc::new(deployer);
let scenario = Scenario {
Expand Down Expand Up @@ -727,6 +734,8 @@ _ _: 0 0;
let token3_arc = Arc::new(token3);
let known_vault_id = U256::from(1);
let order = Order {
document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))),
key: "".to_string(),
inputs: vec![
OrderIO {
token: token1_arc.clone(),
Expand Down
9 changes: 8 additions & 1 deletion crates/common/src/types/order_detail_extended.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use crate::meta::{TryDecodeRainlangSource, TryDecodeRainlangSourceError};
#[cfg(target_family = "wasm")]
use rain_orderbook_bindings::{impl_all_wasm_traits, wasm_traits::prelude::*};
use rain_orderbook_subgraph_client::types::common::Order;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;

#[typeshare]
#[derive(Serialize, Deserialize, Clone, Debug)]
#[cfg_attr(target_family = "wasm", derive(Tsify))]
#[serde(rename_all = "camelCase")]
#[typeshare]
pub struct OrderDetailExtended {
pub order: Order,
pub rainlang: Option<String>,
Expand All @@ -26,3 +30,6 @@ impl TryFrom<Order> for OrderDetailExtended {
})
}
}

#[cfg(target_family = "wasm")]
impl_all_wasm_traits!(OrderDetailExtended);
57 changes: 53 additions & 4 deletions crates/js_api/src/subgraph/order.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
use cynic::Id;
use rain_orderbook_bindings::wasm_traits::prelude::*;
use rain_orderbook_common::types::OrderDetailExtended;
use rain_orderbook_subgraph_client::{
types::common::OrdersListFilterArgs, MultiOrderbookSubgraphClient, MultiSubgraphArgs,
OrderbookSubgraphClient, OrderbookSubgraphClientError, PaginationArgs,
types::common::{Order, OrdersListFilterArgs},
MultiOrderbookSubgraphClient, MultiSubgraphArgs, OrderbookSubgraphClient,
OrderbookSubgraphClientError, PaginationArgs,
};
use reqwest::Url;

/// Internal function to fetch a single order
/// Returns the Order struct
async fn get_sg_order(url: &str, id: &str) -> Result<Order, OrderbookSubgraphClientError> {
let client = OrderbookSubgraphClient::new(Url::parse(url)?);
let order = client.order_detail(Id::new(id)).await?;
Ok(order)
}

/// Fetch all orders from multiple subgraphs
/// Returns a list of OrderWithSubgraphName structs
#[wasm_bindgen(js_name = "getOrders")]
Expand All @@ -23,11 +33,20 @@ pub async fn get_orders(
/// Returns the Order struct
#[wasm_bindgen(js_name = "getOrder")]
pub async fn get_order(url: &str, id: &str) -> Result<JsValue, OrderbookSubgraphClientError> {
let client = OrderbookSubgraphClient::new(Url::parse(url)?);
let order = client.order_detail(Id::new(id)).await?;
let order = get_sg_order(url, id).await?;
Ok(to_value(&order)?)
}

/// Extend an order to include Rainlang string
/// Returns an OrderDetailExtended struct
#[wasm_bindgen(js_name = "extendOrder")]
pub fn order_detail_extended(order: Order) -> Result<JsValue, OrderbookSubgraphClientError> {
let order_extended: OrderDetailExtended = order
.try_into()
.map_err(|_| OrderbookSubgraphClientError::OrderDetailExtendError)?;
Ok(to_value(&order_extended)?)
}

/// Fetch trades for a specific order
/// Returns a list of Trade structs
#[wasm_bindgen(js_name = "getOrderTradesList")]
Expand Down Expand Up @@ -83,3 +102,33 @@ pub async fn get_order_trades_count(
// Convert the count to a JavaScript-compatible value and return
Ok(to_value(&trades_count)?)
}

/// Fetch volume information for vaults associated with an order
#[wasm_bindgen(js_name = "getOrderVaultsVolume")]
pub async fn order_vaults_volume(
url: &str,
order_id: &str,
start_timestamp: Option<u64>,
end_timestamp: Option<u64>,
) -> Result<JsValue, OrderbookSubgraphClientError> {
let client = OrderbookSubgraphClient::new(Url::parse(url)?);
let volumes = client
.order_vaults_volume(Id::new(order_id), start_timestamp, end_timestamp)
.await?;
Ok(to_value(&volumes)?)
}

/// Measures an order's performance (including vaults apy and vol and total apy and vol)
#[wasm_bindgen(js_name = "getOrderPerformance")]
pub async fn order_performance(
url: &str,
order_id: &str,
start_timestamp: Option<u64>,
end_timestamp: Option<u64>,
) -> Result<JsValue, OrderbookSubgraphClientError> {
let client = OrderbookSubgraphClient::new(Url::parse(url)?);
let performance = client
.order_performance(Id::new(order_id), start_timestamp, end_timestamp)
.await?;
Ok(to_value(&performance)?)
}
18 changes: 14 additions & 4 deletions crates/settings/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use super::config_source::ConfigSourceError;
use crate::*;
use alloy::primitives::U256;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::Arc;
use std::{collections::HashMap, sync::RwLock};
use strict_yaml_rust::StrictYaml;
use subgraph::Subgraph;
use thiserror::Error;
use typeshare::typeshare;
use url::Url;
Expand Down Expand Up @@ -45,7 +47,6 @@ pub struct Config {
#[cfg(target_family = "wasm")]
impl_all_wasm_traits!(Config);

pub type Subgraph = Url;
pub type Metaboard = Url;
pub type Vault = U256;

Expand Down Expand Up @@ -95,7 +96,16 @@ impl TryFrom<ConfigSource> for Config {
let subgraphs = item
.subgraphs
.into_iter()
.map(|(name, subgraph)| Ok((name, Arc::new(subgraph))))
.map(|(name, subgraph)| {
Ok((
name.clone(),
Arc::new(Subgraph {
document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))),
key: name.clone(),
url: subgraph.clone(),
}),
))
})
.collect::<Result<HashMap<String, Arc<Subgraph>>, ParseConfigSourceError>>()?;

let metaboards = item
Expand Down Expand Up @@ -343,7 +353,7 @@ mod tests {
// Verify subgraphs
assert_eq!(config.subgraphs.len(), 1);
let mainnet_subgraph = config.subgraphs.get("mainnet").unwrap();
assert_eq!(mainnet_subgraph.as_str(), "https://mainnet.subgraph/");
assert_eq!(mainnet_subgraph.url.as_str(), "https://mainnet.subgraph/");

// Verify orderbooks
assert_eq!(config.orderbooks.len(), 1);
Expand Down
Loading

0 comments on commit e60119b

Please sign in to comment.