Skip to content
Open
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
6 changes: 1 addition & 5 deletions programs/dynamic-bonding-curve/src/params/fee_parameters.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Fees module includes information about fee charges
use crate::activation_handler::ActivationType;
use crate::base_fee::get_base_fee_handler;
use crate::constants::fee::{HOST_FEE_PERCENT, MAX_BASIS_POINT, PROTOCOL_FEE_PERCENT};
use crate::constants::fee::MAX_BASIS_POINT;
use crate::constants::{BASIS_POINT_MAX, BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, U24_MAX};
use crate::error::PoolError;
use crate::safe_math::SafeMath;
Expand Down Expand Up @@ -60,16 +60,12 @@ impl PoolFeeParameters {
if let Some(dynamic_fee) = dynamic_fee {
PoolFeesConfig {
base_fee: base_fee.to_base_fee_config(),
protocol_fee_percent: PROTOCOL_FEE_PERCENT,
referral_fee_percent: HOST_FEE_PERCENT,
dynamic_fee: dynamic_fee.to_dynamic_fee_config(),
..Default::default()
}
} else {
PoolFeesConfig {
base_fee: base_fee.to_base_fee_config(),
protocol_fee_percent: PROTOCOL_FEE_PERCENT,
referral_fee_percent: HOST_FEE_PERCENT,
..Default::default()
}
}
Expand Down
15 changes: 5 additions & 10 deletions programs/dynamic-bonding-curve/src/state/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use static_assertions::const_assert_eq;
use crate::{
base_fee::{get_base_fee_handler, FeeRateLimiter},
constants::{
fee::{FEE_DENOMINATOR, MAX_FEE_NUMERATOR},
fee::{FEE_DENOMINATOR, HOST_FEE_PERCENT, MAX_FEE_NUMERATOR, PROTOCOL_FEE_PERCENT},
MAX_CURVE_POINT_CONFIG, MAX_SQRT_PRICE, MAX_SWALLOW_PERCENTAGE, SWAP_BUFFER_PERCENTAGE,
},
params::{
Expand Down Expand Up @@ -51,8 +51,8 @@ pub struct PoolFeesConfig {
pub dynamic_fee: DynamicFeeConfig,
pub padding_0: [u64; 5],
pub padding_1: [u8; 6],
pub protocol_fee_percent: u8,
pub referral_fee_percent: u8,
/// padding, previous protocol_fee_percent, referral_fee_percent. be careful when use this field
pub padding_2: [u8; 2],
}

const_assert_eq!(PoolFeesConfig::INIT_SPACE, 128);
Expand Down Expand Up @@ -118,7 +118,7 @@ impl PoolFeesConfig {

let protocol_fee = safe_mul_div_cast_u64(
trading_fee,
self.protocol_fee_percent.into(),
PROTOCOL_FEE_PERCENT.into(),
100,
Rounding::Down,
)?;
Expand All @@ -127,12 +127,7 @@ impl PoolFeesConfig {
let trading_fee: u64 = trading_fee.safe_sub(protocol_fee)?;

let referral_fee = if has_referral {
safe_mul_div_cast_u64(
protocol_fee,
self.referral_fee_percent.into(),
100,
Rounding::Down,
)?
safe_mul_div_cast_u64(protocol_fee, HOST_FEE_PERCENT.into(), 100, Rounding::Down)?
} else {
0
};
Expand Down
Loading