Skip to content

Commit

Permalink
Merge pull request #299 from Phoenix-Protocol-Group/rename-and-publis…
Browse files Browse the repository at this point in the history
…h-decimal

Rename `decimal` package to `soroban-decimal`
  • Loading branch information
ueco-jb authored May 8, 2024
2 parents 36e2421 + da82ec1 commit 8386173
Show file tree
Hide file tree
Showing 22 changed files with 41 additions and 34 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to

## [Unreleased]

## Changed

- decimal: Rename to `soroban-decimal` and publish in crates.io ([#299])

[#299]: https://github.com/Phoenix-Protocol-Group/phoenix-contracts/pull/299

## [1.0.0] - 2024-05-08

## Changed
Expand Down
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository = "https://github.com/Phoenix-Protocol-Group/phoenix-contracts"

[workspace.dependencies]
curve = { path = "./packages/curve" }
decimal = { path = "./packages/decimal" }
soroban-decimal = { path = "./packages/decimal" }
phoenix = { path = "./packages/phoenix" }
num-integer = { version = "0.1.45", default-features = false, features = [
"i128",
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ crate-type = ["cdylib"]
testutils = ["soroban-sdk/testutils"]

[dependencies]
decimal = { workspace = true }
soroban-decimal = { workspace = true }
phoenix = { workspace = true }
num-integer = { workspace = true }
soroban-sdk = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
},
token_contract,
};
use decimal::Decimal;
use soroban_decimal::Decimal;
use phoenix::{
utils::{is_approx_ratio, LiquidityPoolInitInfo},
validate_bps, validate_int_parameters,
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use soroban_sdk::{
};

use crate::{error::ContractError, token_contract};
use decimal::Decimal;
use soroban_decimal::Decimal;

#[derive(Clone, Copy)]
#[repr(u32)]
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool/src/tests/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use test_case::test_case;

use super::setup::{deploy_liquidity_pool_contract, deploy_token_contract};
use crate::storage::{Asset, PoolResponse, SimulateReverseSwapResponse, SimulateSwapResponse};
use decimal::Decimal;
use soroban_decimal::Decimal;

#[test]
fn simple_swap() {
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool_stable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ crate-type = ["cdylib"]
testutils = ["soroban-sdk/testutils"]

[dependencies]
decimal = { workspace = true }
soroban-decimal = { workspace = true }
phoenix = { workspace = true }
num-integer = { workspace = true }
soroban-sdk = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool_stable/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
},
token_contract,
};
use decimal::Decimal;
use soroban_decimal::Decimal;
use phoenix::{validate_bps, validate_int_parameters};

// Minimum amount of initial LP shares to mint
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool_stable/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use soroban_sdk::{log, panic_with_error, Env};

use crate::{error::ContractError, storage::AmplifierParameters};

use decimal::Decimal;
use soroban_decimal::Decimal;

// TODO: Those parameters will be used for updating AMP function later
#[allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool_stable/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use soroban_sdk::{
};

use crate::{error::ContractError, token_contract};
use decimal::Decimal;
use soroban_decimal::Decimal;

#[derive(Clone, Copy)]
#[repr(u32)]
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool_stable/src/tests/liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
storage::{Asset, PoolResponse},
token_contract,
};
use decimal::Decimal;
use soroban_decimal::Decimal;

#[test]
fn provide_liqudity() {
Expand Down
2 changes: 1 addition & 1 deletion contracts/pool_stable/src/tests/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use soroban_sdk::{symbol_short, testutils::Address as _, Address, Env, IntoVal};

use super::setup::{deploy_stable_liquidity_pool_contract, deploy_token_contract};
use crate::storage::{Asset, PoolResponse, SimulateReverseSwapResponse, SimulateSwapResponse};
use decimal::Decimal;
use soroban_decimal::Decimal;

#[test]
fn simple_swap() {
Expand Down
4 changes: 2 additions & 2 deletions contracts/stake/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ crate-type = ["cdylib"]
testutils = ["soroban-sdk/testutils"]

[dependencies]
decimal = { workspace = true }
soroban-decimal = { workspace = true }
curve = { workspace = true }
phoenix = { workspace = true }
soroban-sdk = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
pretty_assertions = { workspace = true }
pretty_assertions = { workspace = true }
2 changes: 1 addition & 1 deletion contracts/stake/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use decimal::Decimal;
use soroban_decimal::Decimal;
use soroban_sdk::{
contract, contractimpl, contractmeta, log, panic_with_error, vec, Address, BytesN, Env, String,
Vec,
Expand Down
2 changes: 1 addition & 1 deletion contracts/stake/src/distribution.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use soroban_sdk::{contracttype, Address, Env};

use curve::Curve;
use decimal::Decimal;
use soroban_decimal::Decimal;

use crate::{
storage::{get_stakes, Config},
Expand Down
2 changes: 1 addition & 1 deletion contracts/vesting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = { workspace = true }
crate-type = ["cdylib"]

[dependencies]
decimal = { workspace = true }
soroban-decimal = { workspace = true }
curve = { workspace = true }
phoenix = { workspace = true }
soroban-sdk = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion packages/decimal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[package]
name = "decimal"
name = "soroban-decimal"
version = { workspace = true }
authors = ["Jakub <[email protected]>"]
repository = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
description = "A precise decimal arithmetic package for Soroban contracts"

[dependencies]
soroban-sdk = { workspace = true, features = ["alloc"]}
2 changes: 1 addition & 1 deletion packages/decimal/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Dex Decimal
# Soroban Decimal
This code is taken from the [cosmwasm-std crate](https://github.com/CosmWasm/cosmwasm.), which is licensed under the Apache License 2.0
The contract provides a `Decimal` struct for arithmetic operations, suitable for blockchain De-Fi operations, where precision is of highest importance. It ensures that calculations are accurate up to 18 decimal places.

Expand Down
4 changes: 2 additions & 2 deletions packages/decimal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl Decimal {
/// ## Examples
///
/// ```
/// use decimal::Decimal;
/// use soroban_decimal::Decimal;
/// // Value with whole and fractional part
/// let a = Decimal::percent(123);
/// assert_eq!(a.decimal_places(), 18);
Expand Down Expand Up @@ -129,7 +129,7 @@ impl Decimal {
/// ## Examples
///
/// ```
/// use decimal::Decimal;
/// use soroban_decimal::Decimal;
/// use soroban_sdk::{String, Env};
///
/// let e = Env::default();
Expand Down
2 changes: 1 addition & 1 deletion packages/phoenix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ testutils = ["soroban-sdk/testutils"]

[dependencies]
soroban-sdk = { workspace = true }
decimal = { workspace = true }
soroban-decimal = { workspace = true }

[dev_dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
Expand Down
2 changes: 1 addition & 1 deletion packages/phoenix/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use decimal::Decimal;
use soroban_decimal::Decimal;
use soroban_sdk::{contracttype, Address};

// Validate if int value is bigger then 0
Expand Down

0 comments on commit 8386173

Please sign in to comment.