Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move amm math into its own crate #5418

Merged
merged 3 commits into from
Nov 18, 2024
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
15 changes: 15 additions & 0 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ pallet-cf-vaults = { path = "state-chain/pallets/cf-vaults", default-features =
pallet-cf-witnesser = { path = "state-chain/pallets/cf-witnesser", default-features = false }

cf-amm = { path = "state-chain/amm", default-features = false }
cf-amm-math = { path = "state-chain/amm-math", default-features = false }
cf-chains = { path = "state-chain/chains", default-features = false }
cf-primitives = { path = "state-chain/primitives", default-features = false }
cf-session-benchmarking = { path = "state-chain/cf-session-benchmarking", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion api/lib/src/lp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use super::SimpleSubmissionApi;
use anyhow::{bail, Result};
use async_trait::async_trait;
pub use cf_amm::{
common::{Amount, PoolPairsMap, Side, Tick},
common::{PoolPairsMap, Side},
math::{Amount, Tick},
range_orders::Liquidity,
};
use cf_chains::{
Expand Down
2 changes: 1 addition & 1 deletion engine/src/witness/btc/vault_swaps.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bitcoin::{hashes::Hash as btcHash, opcodes::all::OP_RETURN, ScriptBuf};
use cf_amm::common::{bounded_sqrt_price, sqrt_price_to_price};
use cf_amm::math::{bounded_sqrt_price, sqrt_price_to_price};
use cf_chains::{
assets::btc::Asset as BtcAsset,
btc::{
Expand Down
31 changes: 31 additions & 0 deletions state-chain/amm-math/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "cf-amm-math"
version = "0.1.0"
authors = ["Chainflip <https://chainflip.io>"]
edition = "2021"
description = "Chainflip AMM Math Primitives"

[dependencies]
cf-primitives = { workspace = true }
serde = { workspace = true, features = ["derive", "alloc"] }

# Parity deps
codec = { workspace = true, features = ["derive"] }
scale-info = { workspace = true, features = ["derive"] }

sp-core = { workspace = true }
sp-std = { workspace = true }

rand = { workspace = true, features = ["std"], optional = true }

[features]
default = ["std"]
slow-tests = ["dep:rand"]
std = [
"cf-primitives/std",
"codec/std",
"scale-info/std",
"sp-core/std",
"sp-std/std",
"serde/std",
]
Loading
Loading