Skip to content

Commit

Permalink
Merge pull request #8 from mootz12/main
Browse files Browse the repository at this point in the history
Update Internal Math to i256 and Add More Tests
  • Loading branch information
spiraldevp authored Apr 26, 2024
2 parents 796589c + fd3b5ee commit dac8a38
Show file tree
Hide file tree
Showing 34 changed files with 3,107 additions and 1,741 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ codegen-units = 1
lto = true

[workspace.dependencies.soroban-sdk]
version = "20.3.1"
version = "20.5.0"

[workspace.dependencies.soroban-token-sdk]
version = "20.3.1"
version = "20.5.0"
6 changes: 3 additions & 3 deletions contracts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[package]
name = "contracts"
description = "Comet Contracts"
version = "0.0.7"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
soroban-fixed-point-math = "1.0.0"
soroban-fixed-point-math = "1.1.0"
soroban-sdk = { workspace = true }
soroban-token-sdk = { workspace = true }

[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
sep-41-token = { version = "0.3.0", features = ["testutils"] }
sep-41-token = { version = "1.0.0", features = ["testutils"] }
31 changes: 17 additions & 14 deletions contracts/src/c_consts.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
//! Comet Pool Constants
use soroban_fixed_point_math::STROOP;

pub const BONE: i128 = STROOP as i128;
/// c_math 256 bit constants
/// kept as i128 to avoid requiring `env` to define constants
pub const BONE: i128 = 10i128.pow(18);
pub const MIN_CPOW_BASE: i128 = 1;
pub const MAX_CPOW_BASE: i128 = (2 * BONE) - 1;
pub const CPOW_PRECISION: i128 = 1_000000_i128;
pub const EXIT_FEE: i128 = 0;
pub const MAX_TOTAL_WEIGHT: i128 = BONE * 50;
pub const INIT_POOL_SUPPLY: i128 = BONE * 100;
pub const MIN_FEE: i128 = 10;
pub const MAX_FEE: i128 = 1_000000_i128;
pub const MAX_IN_RATIO: i128 = BONE / 2;
pub const MAX_OUT_RATIO: i128 = (BONE / 3) + 1;
pub const CPOW_PRECISION: i128 = 10i128.pow(8);

/// constants
pub const STROOP: i128 = 10i128.pow(7);
pub const STROOP_SCALAR: i128 = 10i128.pow(11);
pub const MAX_IN_RATIO: i128 = (STROOP / 3) + 1;
pub const MAX_OUT_RATIO: i128 = (STROOP / 3) + 1;
pub const INIT_POOL_SUPPLY: i128 = STROOP * 100;
pub const MIN_FEE: i128 = 10; // 0.0001%
pub const MAX_FEE: i128 = STROOP / 10; // 10%
pub const MIN_BOUND_TOKENS: u32 = 2;
pub const MAX_BOUND_TOKENS: u32 = 8;
pub const MIN_WEIGHT: i128 = BONE;
pub const MAX_WEIGHT: i128 = BONE * 50;
pub const MIN_BALANCE: i128 = (1_0000000 / 1_00000) as i128;
pub const MAX_TOTAL_WEIGHT: i128 = STROOP * 50;
pub const MIN_WEIGHT: i128 = STROOP / 10; // 10%
pub const MAX_WEIGHT: i128 = MIN_WEIGHT * 9; // 90%
pub const MIN_BALANCE: i128 = 100;
Loading

0 comments on commit dac8a38

Please sign in to comment.