metrom_resolver_commons/
lib.rs

1use alloy::primitives::U256;
2use metrom_commons::types::{
3    address::Address, amm::Amm, amm_pool_liquidity_type::AmmPoolLiquidityType,
4};
5use serde::{Deserialize, Serialize};
6
7// reexport this stuff
8pub use metrom_chain_adapter_commons::Token;
9
10#[derive(Serialize, Deserialize, Debug, Clone)]
11#[serde(rename_all = "camelCase")]
12#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
13/// A token metadata with address representation
14pub struct TokenWithAddress {
15    /// The token address
16    pub address: Address,
17    #[cfg_attr(feature = "utoipa", schema(example = 18))]
18    /// Number of decimals the token uses
19    pub decimals: i32,
20    #[cfg_attr(feature = "utoipa", schema(example = "Foo"))]
21    /// The symbol of the token
22    pub symbol: String,
23    #[cfg_attr(feature = "utoipa", schema(example = "Foobar"))]
24    /// The name of the token
25    pub name: String,
26}
27
28#[derive(Serialize, Deserialize, Debug, Clone)]
29#[serde(rename_all = "camelCase")]
30#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
31pub struct AmmPool {
32    #[cfg_attr(feature = "utoipa", schema(example = "uniswap-v3"))]
33    /// The pool's dex
34    pub dex: String,
35    #[cfg_attr(feature = "utoipa", schema(example = "uniswap-v3"))]
36    /// The pool's AMM
37    pub amm: Amm,
38    #[cfg_attr(feature = "utoipa", schema(example = "concentrated"))]
39    /// The pool's liquidity type
40    pub liquidity_type: AmmPoolLiquidityType,
41    /// The pool's tokens
42    pub tokens: Vec<TokenWithAddress>,
43    #[serde(skip_serializing_if = "Option::is_none")]
44    /// The pool's fee
45    pub fee: Option<f64>,
46    #[serde(skip_serializing_if = "Option::is_none")]
47    /// The pool's USD TVL
48    pub usd_tvl: Option<f64>,
49    #[serde(skip_serializing_if = "Option::is_none")]
50    #[cfg_attr(feature = "utoipa", schema(value_type = String, example = "100288918"))]
51    /// The pool's liquidity
52    pub liquidity: Option<U256>,
53}
54
55#[derive(Serialize, Deserialize, Debug, Clone)]
56#[serde(rename_all = "camelCase")]
57pub struct LiquityV2Collateral {
58    pub decimals: i32,
59    pub symbol: String,
60    pub name: String,
61    pub tvl: U256,
62    pub usd_tvl: f64,
63    pub usd_price: f64,
64    pub minted_debt: f64,
65    pub stability_pool_debt: f64,
66}
67
68#[derive(Serialize, Deserialize, Debug, Clone)]
69#[serde(rename_all = "camelCase")]
70pub struct GmxV1Collateral {
71    pub decimals: i32,
72    pub symbol: String,
73    pub name: String,
74    pub tvl: U256,
75    pub usd_tvl: f64,
76    pub usd_price: f64,
77}
78
79#[derive(Serialize, Deserialize, Clone, Debug)]
80#[serde(rename_all = "camelCase")]
81pub struct ResolveTokensQuery {
82    pub with_usd_prices: Option<bool>,
83}
84
85#[derive(Serialize, Deserialize, Clone, Debug)]
86#[serde(rename_all = "camelCase")]
87pub struct ResolveAmmPoolsQuery {
88    pub with_usd_tvls: Option<bool>,
89    pub with_liquidity: Option<bool>,
90}