Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Update amm_manager.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
22388o authored Nov 2, 2023
1 parent a993e6e commit 5768f2c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/dex/functions/main/amm_manager.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
use std::u64
use std::u64;


use super::{AMMError, CostFunctionMarketMaker};

/// `b` value must have certain amount for sane numerical computing
pub const MINIMAL_LIQUIDITY_B: f64 = 0.0001;
pub const MINIMAL_LIQUIDITY_B: u64 = 0.0001;

/// Multi dimensional cost function
pub(crate) fn cost_function_md(total_security: &[f64], b: f64) -> f64 {
pub(crate) fn cost_function_md(total_security: &[u64], b: u64) -> u64 {
b * total_security
.into_iter()
.map(|q| E.powf(q / b))
.sum::<f64>()
.ln()
}

pub(crate) fn price_for_purchase(total_security: &[f64], purchase_vector: &[f64], b: f64) -> f64 {
pub(crate) fn price_for_purchase(total_security: &[f64], purchase_vector: &[u64], b: u64) -> u64 {
let mut total_security_after = Vec::with_capacity(total_security.len());
for (i, q) in total_security.iter().enumerate() {
total_security_after[i] = *q + purchase_vector[i];
Expand Down

0 comments on commit 5768f2c

Please sign in to comment.