Skip to content

Commit

Permalink
chore: cleanup things after PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x committed Apr 12, 2024
1 parent fb30f1f commit 64ec60f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 24 deletions.
11 changes: 0 additions & 11 deletions contracts/liquidity_hub/incentive-manager/src/bin/schema.rs

This file was deleted.

3 changes: 1 addition & 2 deletions contracts/liquidity_hub/incentive-manager/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) fn process_incentive_creation_fee(
config: &Config,
info: &MessageInfo,
incentive_creation_fee: &Coin,
params: &mut IncentiveParams,
params: &IncentiveParams,
) -> Result<Vec<CosmosMsg>, ContractError> {
let mut messages: Vec<CosmosMsg> = vec![];

Expand Down Expand Up @@ -80,7 +80,6 @@ pub(crate) fn process_incentive_creation_fee(
}

/// Asserts the incentive asset was sent correctly, considering the incentive creation fee if applicable.
/// Returns a vector of messages to be sent (applies only when the incentive asset is a CW20 token)
pub(crate) fn assert_incentive_asset(
info: &MessageInfo,
incentive_creation_fee: &Coin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ use cosmwasm_std::{
Storage, Uint128, Uint64,
};

use white_whale_std::coin::{get_subdenom, is_factory_token};
use white_whale_std::coin::{get_factory_token_subdenom, is_factory_token};
use white_whale_std::epoch_manager::hooks::EpochChangedHookMsg;
use white_whale_std::incentive_manager::MIN_INCENTIVE_AMOUNT;
use white_whale_std::incentive_manager::{Curve, Incentive, IncentiveParams};
use white_whale_std::lp_common::LP_SYMBOL;

use crate::helpers::{
assert_incentive_asset, process_incentive_creation_fee, validate_emergency_unlock_penalty,
Expand Down Expand Up @@ -43,7 +44,7 @@ pub(crate) fn fill_incentive(
fn create_incentive(
deps: DepsMut,
info: MessageInfo,
mut params: IncentiveParams,
params: IncentiveParams,
) -> Result<Response, ContractError> {
// check if there are any expired incentives for this LP asset
let config = CONFIG.load(deps.storage)?;
Expand Down Expand Up @@ -86,15 +87,15 @@ fn create_incentive(
}
);

let incentive_creation_fee = config.create_incentive_fee.clone();
let incentive_creation_fee = config.clone().create_incentive_fee;

if incentive_creation_fee.amount != Uint128::zero() {
// verify the fee to create an incentive is being paid
messages.append(&mut process_incentive_creation_fee(
&config,
&info,
&incentive_creation_fee,
&mut params,
&params,
)?);
}

Expand Down Expand Up @@ -304,8 +305,10 @@ pub(crate) fn on_epoch_changed(
.into_iter()
.filter(|asset| {
if is_factory_token(asset.denom.as_str()) {
//todo remove this hardcoded uLP and point to the pool manager const, to be moved to the white-whale-std package
get_subdenom(asset.denom.as_str()) == "uLP"
match get_factory_token_subdenom(asset.denom.as_str()) {
Ok(subdenom) => subdenom == LP_SYMBOL,
Err(_) => false,

Check warning on line 310 in contracts/liquidity_hub/incentive-manager/src/manager/commands.rs

View check run for this annotation

Codecov / codecov/patch

contracts/liquidity_hub/incentive-manager/src/manager/commands.rs#L310

Added line #L310 was not covered by tests
}
} else {
false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ pub fn create_pair(
let lp_symbol = format!("{pair_label}.pool.{identifier}.{LP_SYMBOL}");
let lp_asset = format!("{}/{}/{}", "factory", env.contract.address, lp_symbol);

#[allow(clippy::redundant_clone)]
PAIRS.save(
deps.storage,
&identifier,
Expand Down
16 changes: 11 additions & 5 deletions packages/white-whale-std/src/coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,17 @@ pub fn is_factory_token(denom: &str) -> bool {
}

/// Gets the subdenom of a factory token. To be called after [is_factory_token] has been successful.
pub fn get_subdenom(denom: &str) -> &str {
denom
.splitn(3, '/')
.nth(2)
.expect("Expected at least three elements")
pub fn get_factory_token_subdenom(denom: &str) -> StdResult<&str> {
let subdenom = denom.splitn(3, '/').nth(2);

subdenom.map_or_else(
|| {
Err(StdError::generic_err(

Check warning on line 110 in packages/white-whale-std/src/coin.rs

View check run for this annotation

Codecov / codecov/patch

packages/white-whale-std/src/coin.rs#L109-L110

Added lines #L109 - L110 were not covered by tests
"Splitting factory token subdenom failed",
))
},
Ok,
)
}

/// Builds the label for a factory token denom in such way that it returns a label like "factory/mig...xyz/123...456".
Expand Down
Empty file.
Empty file.

0 comments on commit 64ec60f

Please sign in to comment.