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
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Breaking Changes

## cp_amm [0.2.0]
[TODO]

### Removed

- Removed `partner` field from Pool struct
- Removed unused `partner_fee` feature and the `claim_partner_fee` endpoint

## cp_amm [0.1.8][PR #177](https://github.com/MeteoraAg/damm-v2/pull/177)

### Added

- New endpoint `fix_pool_params` and `fix_config_fee_params` to allow `operator` to fix invalid scheduler params that causes blocking operation on `update_pool_fees` endpoint.
- New endpoint `lock_inner_position`, that allow to vest liquidity without external `Vesting` account for better composability.
- New endpoint `lock_inner_position`, that allow to vest liquidity without external `Vesting` account for better composability.

### Changed

Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ MCPA is a brand new AMM program of Meteora that includes almost all features fro
- fund_reward: fund reward for on-chain liquidity mining
- withdraw_ineligible_reward: withdraw ineligible reward

### Partner (aka Launchpad)
- claim_partner_fee: claim partner fee

### Token deployer
- initialize_pool: create a new pool from a static config key
- initialize_pool_with_dynamic_config: create a new pool from a dynamic config key
Expand All @@ -54,7 +51,7 @@ MCPA is a brand new AMM program of Meteora that includes almost all features fro
## Config key state
- vault_config_key: alpha-vault address that is able to buy pool before activation_point
- pool_creator_authority: if this address is non-default, then only this address can create pool with that config key (for launchpad)
- pool_fees: includes base fee scheduler, dynamic-fee, protocol fee percent, partner fee percent, and referral fee percent configuration
- pool_fees: includes base fee scheduler, dynamic-fee, protocol fee percent, and referral fee percent configuration
- activation_type: determines whether pools are run in slot or timestamp
- collect_fee_mode: determines whether pool should collect fees in both tokens or only one token
- sqrt_min_price: square root of min price for pools
Expand Down
3 changes: 0 additions & 3 deletions programs/cp-amm/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,8 @@ pub mod fee {

pub const HOST_FEE_PERCENT: u8 = 20; // 20% of protocol fee

pub const PARTNER_FEE_PERCENT: u8 = 0; // percentage of partner fee

static_assertions::const_assert!(PROTOCOL_FEE_PERCENT <= 50);
static_assertions::const_assert!(HOST_FEE_PERCENT <= 50);
static_assertions::const_assert!(PARTNER_FEE_PERCENT <= 50);

#[constant]
pub const CURRENT_POOL_VERSION: u8 = 1;
Expand Down
7 changes: 0 additions & 7 deletions programs/cp-amm/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,6 @@ pub struct EvtClaimProtocolFee {
pub token_b_amount: u64,
}

#[event]
pub struct EvtClaimPartnerFee {
pub pool: Pubkey,
pub token_a_amount: u64,
pub token_b_amount: u64,
}

#[event]
pub struct EvtSetPoolStatus {
pub pool: Pubkey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ pub fn handle_initialize_customizable_pool<'c: 'info, 'info>(
ctx.accounts.token_a_vault.key(),
ctx.accounts.token_b_vault.key(),
alpha_vault,
Pubkey::default(),
sqrt_min_price,
sqrt_max_price,
sqrt_price,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ pub fn handle_initialize_pool<'c: 'info, 'info>(
ctx.accounts.token_a_vault.key(),
ctx.accounts.token_b_vault.key(),
alpha_vault,
config.pool_creator_authority,
config.sqrt_min_price,
config.sqrt_max_price,
sqrt_price,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ pub fn handle_initialize_pool_with_dynamic_config<'c: 'info, 'info>(
ctx.accounts.token_a_vault.key(),
ctx.accounts.token_b_vault.key(),
alpha_vault,
config.pool_creator_authority,
sqrt_min_price,
sqrt_max_price,
sqrt_price,
Expand Down
2 changes: 0 additions & 2 deletions programs/cp-amm/src/instructions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ pub mod ix_permanent_lock_position;
pub use ix_permanent_lock_position::*;
pub mod ix_claim_reward;
pub use ix_claim_reward::*;
pub mod partner;
pub use partner::*;
pub mod ix_fund_reward;
pub use ix_fund_reward::*;
pub mod ix_withdraw_ineligible_reward;
Expand Down
92 changes: 0 additions & 92 deletions programs/cp-amm/src/instructions/partner/ix_claim_partner_fee.rs

This file was deleted.

2 changes: 0 additions & 2 deletions programs/cp-amm/src/instructions/partner/mod.rs

This file was deleted.

9 changes: 0 additions & 9 deletions programs/cp-amm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,6 @@ pub mod cp_amm {
instructions::handle_zap_protocol_fee(ctx, max_amount)
}

#[deprecated = "We currently disable this, and could enable this in the future"]
pub fn claim_partner_fee(
ctx: Context<ClaimPartnerFeesCtx>,
max_amount_a: u64,
max_amount_b: u64,
) -> Result<()> {
instructions::handle_claim_partner_fee(ctx, max_amount_a, max_amount_b)
}

#[access_control(is_valid_operator_role(&ctx.accounts.operator, ctx.accounts.signer.key, OperatorPermission::CloseTokenBadge))]
pub fn close_token_badge(ctx: Context<CloseTokenBadgeCtx>) -> Result<()> {
instructions::handle_close_token_badge(ctx)
Expand Down
30 changes: 1 addition & 29 deletions programs/cp-amm/src/params/fee_parameters.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//! Fees module includes information about fee charges
use crate::activation_handler::ActivationType;
use crate::base_fee::{base_fee_parameters_to_base_fee_info, BaseFeeHandlerBuilder};
use crate::constants::fee::{
HOST_FEE_PERCENT, MAX_BASIS_POINT, PARTNER_FEE_PERCENT, PROTOCOL_FEE_PERCENT,
};
use crate::constants::fee::{HOST_FEE_PERCENT, MAX_BASIS_POINT, PROTOCOL_FEE_PERCENT};
use crate::constants::{BIN_STEP_BPS_DEFAULT, BIN_STEP_BPS_U128_DEFAULT, U24_MAX};
use crate::error::PoolError;
use crate::safe_math::SafeMath;
Expand Down Expand Up @@ -58,7 +56,6 @@ impl PoolFeeParameters {
Ok(PoolFeesConfig {
base_fee: base_fee.to_base_fee_config()?,
protocol_fee_percent: PROTOCOL_FEE_PERCENT,
partner_fee_percent: PARTNER_FEE_PERCENT,
referral_fee_percent: HOST_FEE_PERCENT,
dynamic_fee: dynamic_fee.to_dynamic_fee_config(),
..Default::default()
Expand All @@ -67,7 +64,6 @@ impl PoolFeeParameters {
Ok(PoolFeesConfig {
base_fee: base_fee.to_base_fee_config()?,
protocol_fee_percent: PROTOCOL_FEE_PERCENT,
partner_fee_percent: PARTNER_FEE_PERCENT,
referral_fee_percent: HOST_FEE_PERCENT,
..Default::default()
})
Expand All @@ -82,7 +78,6 @@ impl PoolFeeParameters {
Ok(PoolFeesStruct {
base_fee: base_fee.to_base_fee_struct()?,
protocol_fee_percent: PROTOCOL_FEE_PERCENT,
partner_fee_percent: PARTNER_FEE_PERCENT,
referral_fee_percent: HOST_FEE_PERCENT,
dynamic_fee: dynamic_fee.to_dynamic_fee_struct(),
init_sqrt_price,
Expand All @@ -92,7 +87,6 @@ impl PoolFeeParameters {
Ok(PoolFeesStruct {
base_fee: base_fee.to_base_fee_struct()?,
protocol_fee_percent: PROTOCOL_FEE_PERCENT,
partner_fee_percent: PARTNER_FEE_PERCENT,
referral_fee_percent: HOST_FEE_PERCENT,
init_sqrt_price,
..Default::default()
Expand Down Expand Up @@ -233,25 +227,3 @@ impl PoolFeeParameters {
Ok(())
}
}

#[derive(Copy, Clone, Debug, AnchorSerialize, AnchorDeserialize, InitSpace, Default)]
pub struct PartnerInfo {
pub fee_percent: u8,
pub partner_authority: Pubkey,
pub pending_fee_a: u64,
pub pending_fee_b: u64,
}

impl PartnerInfo {
pub fn have_partner(&self) -> bool {
self.partner_authority != Pubkey::default()
}

pub fn validate(&self) -> Result<()> {
if !self.have_partner() {
require!(self.fee_percent == 0, PoolError::InvalidFee);
}

Ok(())
}
}
20 changes: 4 additions & 16 deletions programs/cp-amm/src/state/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use crate::{
base_fee::base_fee_info_to_base_fee_parameters,
constants::activation::*,
error::PoolError,
params::fee_parameters::{
BaseFeeParameters, DynamicFeeParameters, PartnerInfo, PoolFeeParameters,
},
params::fee_parameters::{BaseFeeParameters, DynamicFeeParameters, PoolFeeParameters},
safe_math::SafeMath,
state::fee::{BaseFeeStruct, DynamicFeeStruct, PoolFeesStruct},
};
Expand Down Expand Up @@ -41,10 +39,10 @@ pub struct PoolFeesConfig {
pub base_fee: BaseFeeInfo,
pub dynamic_fee: DynamicFeeConfig,
pub protocol_fee_percent: u8,
pub partner_fee_percent: u8,
pub padding_0: u8,
pub referral_fee_percent: u8,
pub padding_0: [u8; 5],
pub padding_1: [u64; 5],
pub padding_1: [u8; 5],
pub padding_2: [u64; 5],
}

const_assert_eq!(PoolFeesConfig::INIT_SPACE, 128);
Expand Down Expand Up @@ -114,7 +112,6 @@ impl PoolFeesConfig {
let &PoolFeesConfig {
base_fee,
protocol_fee_percent,
partner_fee_percent,
referral_fee_percent,
dynamic_fee,
..
Expand All @@ -123,7 +120,6 @@ impl PoolFeesConfig {
PoolFeesStruct {
base_fee: base_fee.to_base_fee_struct(),
protocol_fee_percent,
partner_fee_percent,
referral_fee_percent,
dynamic_fee: dynamic_fee.to_dynamic_fee_struct(),
init_sqrt_price,
Expand Down Expand Up @@ -282,14 +278,6 @@ impl Config {
self.config_type = ConfigType::Dynamic.into();
}

pub fn get_partner_info(&self) -> PartnerInfo {
PartnerInfo {
partner_authority: self.pool_creator_authority,
fee_percent: self.pool_fees.partner_fee_percent,
..Default::default()
}
}

pub fn has_alpha_vault(&self) -> bool {
self.vault_config_key.ne(&Pubkey::default())
}
Expand Down
Loading
Loading