Skip to content

Commit

Permalink
chore: prepare the restd package for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x committed Sep 2, 2024
1 parent d1dd1b5 commit 90fc80e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion 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 @@ -44,7 +44,7 @@ serde = { version = "1.0.145", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.43" }
osmosis-std-derive = { version = "0.15.3" }
prost-types = { version = "0.11.9", default-features = false }
white-whale-std = { version = "1.1.3", path = "packages/white-whale-std" }
white-whale-std = { path = "packages/white-whale-std" }
white-whale-testing = { path = "./packages/white-whale-testing" }
cw-multi-test = { version = "0.20.0", features = ["cosmwasm_1_2"] }
uint = { version = "0.9.5" }
Expand Down
2 changes: 1 addition & 1 deletion packages/white-whale-std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "white-whale-std"
version = "1.1.6"
version = "2.0.0-alpha.1"
edition.workspace = true
authors = [
"Kerber0x <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion packages/white-whale-std/src/coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn get_ethereum_bridged_asset_label(denom: &str) -> StdResult<String> {
}

/// Verifies if the given denom is an ibc token or not
fn is_ibc_token(denom: &str) -> bool {
pub fn is_ibc_token(denom: &str) -> bool {
let split: Vec<&str> = denom.splitn(2, '/').collect();

if split[0] == IBC_PREFIX && split.len() == 2 {
Expand Down
19 changes: 5 additions & 14 deletions packages/white-whale-std/src/pool_network/swap.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use cosmwasm_std::{Decimal, Decimal256, Fraction, StdError, StdResult, Uint128};
use std::str::FromStr;

use cosmwasm_std::{Decimal, Decimal256, Fraction, StdError, StdResult, Uint128};

/// Default swap slippage in case max_spread is not specified
pub const DEFAULT_SLIPPAGE: &str = "0.01";
/// Cap on the maximum swap slippage that is allowed. If max_spread goes over this limit, it will
Expand All @@ -15,21 +16,13 @@ pub fn assert_max_spread(
max_spread: Option<Decimal>,
offer_amount: Uint128,
return_amount: Uint128,
_spread_amount: Uint128,
spread_amount: Uint128,
) -> StdResult<()> {
let max_spread: Decimal256 = max_spread
.unwrap_or(Decimal::from_str(DEFAULT_SLIPPAGE)?)
.min(Decimal::from_str(MAX_ALLOWED_SLIPPAGE)?)
.into();

// println!(">>> assert_max_spread");
// println!("belief_price: {:?}", belief_price);
// println!("max_spread: {:?}", max_spread);
// println!("offer_amount: {:?}", offer_amount);
// println!("return_amount: {:?}", return_amount);
// println!("spread_amount: {:?}", spread_amount);
// println!("<<< assert_max_spread");

if let Some(belief_price) = belief_price {
let expected_return = offer_amount
* belief_price
Expand All @@ -42,10 +35,8 @@ pub fn assert_max_spread(
{
return Err(StdError::generic_err("Spread limit exceeded"));
}
// } else if Decimal256::from_ratio(spread_amount, return_amount + spread_amount) > max_spread {
// // TODO: >>> troubleshooting |
// // return Err(StdError::generic_err("Spread limit exceeded"));
// return Ok(());
} else if Decimal256::from_ratio(spread_amount, return_amount + spread_amount) > max_spread {
return Err(StdError::generic_err("Spread limit exceeded"));
}

Ok(())
Expand Down

0 comments on commit 90fc80e

Please sign in to comment.