diff --git a/Cargo.toml b/Cargo.toml index 7ca96479..ede0571d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ resolver = "2" members = [ # Packages "packages/shade_protocol", - #"packages/shadeswap_shared", # "packages/secretcli", "packages/multi_test", "packages/multi_derive", diff --git a/packages/shade_protocol/Cargo.toml b/packages/shade_protocol/Cargo.toml index ad688724..e45a0f64 100644 --- a/packages/shade_protocol/Cargo.toml +++ b/packages/shade_protocol/Cargo.toml @@ -15,8 +15,9 @@ name = "schemas" path = "src/schemas.rs" # Must have all of the contract_interfaces required-features = [ - "admin", "airdrop", "bonds", "dao", "dex", "governance-impl", "mint", "oracles", - "peg_stability", "query_auth", "sky", "snip20", "staking", "mint_router", "snip20_migration", "liquidity_book" + "admin", "airdrop", "bonds", "dao", "dex", "governance-impl", "mint", "mint_router", + "oracles", "peg_stability", "query_auth", "sky", "snip20", "snip20_migration", + "staking", "swap", "liquidity_book", ] [lib] @@ -35,7 +36,7 @@ storage = ["dao-utils"] storage_plus = ["storage", "dep:secret-storage-plus", "chrono"] query_auth_lib = ["dep:query-authentication"] multi-test = ["dep:secret-multi-test", "dep:anyhow", "interface"] -lb-libraries = ["swap", "snip20", "interface"] +lb-libraries = ["swap", "snip20", "interface", "liquidity_book"] # Implementing new contracts: # Contracts packages are divided by two different features, the interface and the implementation @@ -87,8 +88,8 @@ dao = ["interface", "cosmwasm-std/staking"] admin = ["interface"] peg_stability = ["sky-utils", "adapter"] snip20_migration = [] -liquidity_book = ["interface"] -swap = ["snip20"] +liquidity_book = ["interface", "swap"] +swap = ["snip20"] chrono = ["dep:chrono"] @@ -105,7 +106,7 @@ snip20-impl = ["snip20", "query_auth_impl"] query_auth_impl = ["implementation", "query_auth", "dep:base64"] sky-utils = ["implementation", "sky"] admin_impl = ["implementation", "admin"] -liquidity_book_impl = ["liquidity_book", "implementation"] +# liquidity_book_impl = ["liquidity_book", "implementation", "swap"] # for quicker tests, cargo test --lib # for more explicit tests, cargo test --features=backtraces diff --git a/packages/shade_protocol/src/lib.rs b/packages/shade_protocol/src/lib.rs index 861a52ee..9b2494b2 100644 --- a/packages/shade_protocol/src/lib.rs +++ b/packages/shade_protocol/src/lib.rs @@ -1,4 +1,4 @@ -#![allow(clippy::clone_double_ref)] +#![allow(suspicious_double_ref_op)] // TODO: make private later pub mod contract_interfaces; @@ -41,7 +41,7 @@ pub use anyhow::Result as AnyResult; #[cfg(feature = "utils")] pub use utils::asset::Contract; -#[cfg(feature = "lb-libraries")] +#[cfg(all(feature = "lb-libraries", feature = "swap"))] pub use utils::liquidity_book as lb_libraries; #[cfg(feature = "chrono")] diff --git a/packages/shade_protocol/src/utils/liquidity_book/bin_helper.rs b/packages/shade_protocol/src/utils/liquidity_book/bin_helper.rs index 11f70c01..6a089762 100644 --- a/packages/shade_protocol/src/utils/liquidity_book/bin_helper.rs +++ b/packages/shade_protocol/src/utils/liquidity_book/bin_helper.rs @@ -3,12 +3,9 @@ //! //! This library contains functions to help interaction with bins. -use crate::{ - c_std::{Addr, BankMsg, Coin, CosmosMsg, Uint128}, - contract_interfaces::swap::core::TokenType, -}; +use crate::c_std::{Addr, BankMsg, Coin, CosmosMsg, Uint128}; use ethnum::U256; - +use crate::swap::core::TokenType; use super::{ constants::{SCALE, SCALE_OFFSET}, fee_helper::{FeeError, FeeHelper}, diff --git a/packages/shade_protocol/src/utils/liquidity_book/types.rs b/packages/shade_protocol/src/utils/liquidity_book/types.rs index e43f96fc..38f5a68f 100644 --- a/packages/shade_protocol/src/utils/liquidity_book/types.rs +++ b/packages/shade_protocol/src/utils/liquidity_book/types.rs @@ -1,35 +1,31 @@ //! ### Liquidity Book Type Library -//! Author: Kent +//! Author: Kent and Haseeb //! //! This library contains common types used throughout the project. -use cosmwasm_schema::cw_serde; -use cosmwasm_std::ContractInfo; use ethnum::U256; - -use crate::swap::core::TokenType; +use crate::{ + c_std::ContractInfo, + cosmwasm_schema::cw_serde, +}; pub use crate::utils::liquidity_book::math::{ liquidity_configurations::LiquidityConfigurations, tree_math::TreeUint24, }; +// TODO - Try to not use this type in the liquidity_book module, because it's gated by the "swap" +// feature. +use crate::contract_interfaces::swap::core::TokenType; pub type Bytes32 = [u8; 32]; -/// Info needed to instantiate a contract. +// TODO - This type belongs somewhere else. It's not specific to liquidity_book. #[cw_serde] #[derive(Default)] pub struct ContractInstantiationInfo { pub id: u64, pub code_hash: String, } -/// Pair parameters that don't change. -/// * `base_factor` -/// * `filter_period` -/// * `decay_period` -/// * `reduction_factor` -/// * `variable_fee_control` -/// * `protocol_share` -/// * `max_volatility_accumulator` + #[cw_serde] pub struct StaticFeeParameters { pub base_factor: u16, diff --git a/packages/shade_protocol/src/utils/mod.rs b/packages/shade_protocol/src/utils/mod.rs index a26501ca..d19b426e 100644 --- a/packages/shade_protocol/src/utils/mod.rs +++ b/packages/shade_protocol/src/utils/mod.rs @@ -23,6 +23,7 @@ pub mod generic_response; pub mod storage; +#[cfg(all(feature = "lb-libraries", feature = "swap"))] pub mod liquidity_book; #[cfg(feature = "dao-utils")]