Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ impl MockEnvBuilder {
perps: "n/a".to_string(),
keeper_fee_config: Default::default(),
perps_liquidation_bonus_ratio: Decimal::percent(60),
governance: "n/a".to_string(),
},
},
&[],
Expand Down
3 changes: 3 additions & 0 deletions contracts/credit-manager/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ pub enum ContractError {
#[error("Duplicate voting power thresholds")]
DuplicateVotingPowerThresholds,

#[error("Lowest tier must have min_voting_power equal to 0")]
Copy link
Contributor Author

@Subham2804 Subham2804 Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowest tier must have 0 min voting power

LowestTierMinVotingPowerMustBeZero,

#[error("Discount percentage must be less than or equal to 100%")]
InvalidDiscountPercentage,

Expand Down
9 changes: 4 additions & 5 deletions contracts/credit-manager/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ use crate::{
error::ContractResult,
staking::get_account_tier_and_discount,
state::{
ACCOUNT_KINDS, ACCOUNT_NFT, COIN_BALANCES, DEBT_SHARES, FEE_TIER_CONFIG, GOVERNANCE,
HEALTH_CONTRACT, INCENTIVES, KEEPER_FEE_CONFIG, MAX_SLIPPAGE, MAX_UNLOCKING_POSITIONS,
ORACLE, OWNER, PARAMS, PERPS, PERPS_LB_RATIO, RED_BANK, REWARDS_COLLECTOR, SWAPPER,
SWAP_FEE, TOTAL_DEBT_SHARES, TRIGGER_ORDERS, VAULTS, VAULT_POSITIONS, ZAPPER,
ACCOUNT_KINDS, ACCOUNT_NFT, COIN_BALANCES, DEBT_SHARES, FEE_TIER_CONFIG, HEALTH_CONTRACT,
INCENTIVES, KEEPER_FEE_CONFIG, MAX_SLIPPAGE, MAX_UNLOCKING_POSITIONS, ORACLE, OWNER,
PARAMS, PERPS, PERPS_LB_RATIO, RED_BANK, REWARDS_COLLECTOR, SWAPPER, SWAP_FEE,
TOTAL_DEBT_SHARES, TRIGGER_ORDERS, VAULTS, VAULT_POSITIONS, ZAPPER,
},
utils::debt_shares_to_amount,
vault::vault_utilization_in_deposit_cap_denom,
Expand Down Expand Up @@ -70,7 +70,6 @@ pub fn query_config(deps: Deps) -> ContractResult<ConfigResponse> {
rewards_collector: REWARDS_COLLECTOR.may_load(deps.storage)?,
keeper_fee_config: KEEPER_FEE_CONFIG.load(deps.storage)?,
perps_liquidation_bonus_ratio: PERPS_LB_RATIO.load(deps.storage)?,
governance: GOVERNANCE.load(deps.storage)?.into(),
})
}

Expand Down
7 changes: 7 additions & 0 deletions contracts/credit-manager/src/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ impl StakingTierManager {
// Check for descending order
assert_tiers_sorted_descending(&voting_powers)?;

// Ensure the lowest tier requires min_voting_power == 0
if let Some(lowest) = self.config.tiers.last() {
if !lowest.min_voting_power.is_zero() {
return Err(ContractError::LowestTierMinVotingPowerMustBeZero);
}
}

Ok(())
}

Expand Down
17 changes: 9 additions & 8 deletions contracts/credit-manager/tests/tests/test_staking_tiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ fn test_validation_single_tier_valid() {
let config = FeeTierConfig {
tiers: vec![FeeTier {
id: "single".to_string(),
min_voting_power: Uint128::new(1000),
min_voting_power: Uint128::zero(),
discount_pct: Decimal::percent(25),
}],
};
Expand Down Expand Up @@ -544,7 +544,7 @@ fn test_validation_valid_voting_power_format() {
let config = FeeTierConfig {
tiers: vec![FeeTier {
id: "tier_1".to_string(),
min_voting_power: Uint128::new(1000),
min_voting_power: Uint128::new(0),
discount_pct: Decimal::percent(50),
}],
};
Expand All @@ -559,7 +559,7 @@ fn test_validation_discount_100_percent() {
let config = FeeTierConfig {
tiers: vec![FeeTier {
id: "tier_1".to_string(),
min_voting_power: Uint128::new(1000),
min_voting_power: Uint128::new(0),
discount_pct: Decimal::one(), // 100% discount - now valid!
}],
};
Expand All @@ -574,7 +574,7 @@ fn test_validation_discount_over_100_percent() {
let config = FeeTierConfig {
tiers: vec![FeeTier {
id: "tier_1".to_string(),
min_voting_power: Uint128::new(1000),
min_voting_power: Uint128::new(0),
discount_pct: Decimal::percent(150), // 150% discount!
}],
};
Expand All @@ -590,7 +590,7 @@ fn test_validation_discount_99_percent_valid() {
let config = FeeTierConfig {
tiers: vec![FeeTier {
id: "tier_1".to_string(),
min_voting_power: Uint128::new(1000),
min_voting_power: Uint128::zero(),
discount_pct: Decimal::percent(99), // 99% discount - valid!
}],
};
Expand All @@ -605,7 +605,7 @@ fn test_validation_zero_discount_valid() {
let config = FeeTierConfig {
tiers: vec![FeeTier {
id: "tier_1".to_string(),
min_voting_power: Uint128::new(1000),
min_voting_power: Uint128::new(0),
discount_pct: Decimal::zero(), // 0% discount - valid!
}],
};
Expand Down Expand Up @@ -703,8 +703,9 @@ fn test_validation_max_tier_size(
for i in 0..tier_count {
tiers.push(FeeTier {
id: format!("tier_{}", i),
min_voting_power: Uint128::new(((tier_count - i) * 1000) as u128), // Descending order
discount_pct: Decimal::percent((i * 5) as u64), // 0% to max
// Ensure strictly descending and the final tier has min_voting_power == 0
min_voting_power: Uint128::new(((tier_count - i - 1) * 1000) as u128),
discount_pct: Decimal::percent((i * 5) as u64),
});
}

Expand Down
1 change: 0 additions & 1 deletion contracts/health/tests/tests/helpers/mock_env_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ impl MockEnvBuilder {
perps: "n/a".to_string(),
keeper_fee_config: Default::default(),
perps_liquidation_bonus_ratio: Decimal::percent(60),
governance: "n/a".to_string(),
},
},
&[],
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/credit_manager/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ pub struct ConfigResponse {
pub rewards_collector: Option<RewardsCollector>,
pub keeper_fee_config: KeeperFeeConfig,
pub perps_liquidation_bonus_ratio: Decimal,
pub governance: String,
}

#[cw_serde]
Expand Down
4 changes: 0 additions & 4 deletions schemas/mars-credit-manager/mars-credit-manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -6977,7 +6977,6 @@
"title": "ConfigResponse",
"type": "object",
"required": [
"governance",
"health_contract",
"incentives",
"keeper_fee_config",
Expand All @@ -6999,9 +6998,6 @@
"null"
]
},
"governance": {
"type": "string"
},
"health_contract": {
"type": "string"
},
Expand Down
Binary file modified scripts/health/pkg-web/index_bg.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,6 @@ export interface VaultUtilizationResponse {
}
export interface ConfigResponse {
account_nft?: string | null
governance: string
health_contract: string
incentives: string
keeper_fee_config: KeeperFeeConfig
Expand Down
Loading