8000 remove quote contraints by andrewsource147 · Pull Request #50 · MeteoraAg/cp-amm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

remove quote contraints #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. 8000 We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
8 changes: 0 additions & 8 deletions programs/cp-amm/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
use anchor_lang::prelude::Pubkey;
use anchor_lang::solana_program::pubkey;

/// refer raydium clmm
pub const MIN_SQRT_PRICE: u128 = 4295048016;
/// refer raydium clmm
Expand Down Expand Up @@ -121,8 +118,3 @@ pub mod treasury {
// https://app.squads.so/squads/4EWqcx3aNZmMetCnxwLYwyNjan6XLGp3Ca2W316vrSjv/treasury
pub const ID: Pubkey = pubkey!("4EWqcx3aNZmMetCnxwLYwyNjan6XLGp3Ca2W316vrSjv");
}

// Supported quote mints
const SOL: Pubkey = pubkey!("So11111111111111111111111111111111111111112");
const USDC: Pubkey = pubkey!("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
pub const DEFAULT_QUOTE_MINTS: [Pubkey; 2] = [SOL, USDC];
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
CUSTOMIZABLE_POOL_PREFIX, POOL_AUTHORITY_PREFIX, POSITION_NFT_ACCOUNT_PREFIX,
POSITION_PREFIX, TOKEN_VAULT_PREFIX,
},
DEFAULT_QUOTE_MINTS, MAX_SQRT_PRICE, MIN_SQRT_PRICE,
MAX_SQRT_PRICE, MIN_SQRT_PRICE,
},
create_position_nft,
curve::get_initialize_amounts,
Expand Down Expand Up @@ -264,14 +264,6 @@ pub fn handle_initialize_customizable_pool<'c: 'info, 'info>(
has_alpha_vault,
} = params;

// validate quote token
#[cfg(not(feature = "devnet"))]
validate_quote_token(
&ctx.accounts.token_a_mint.key(),
&ctx.accounts.token_b_mint.key(),
has_alpha_vault,
)?;

let (token_a_amount, token_b_amount) =
get_initialize_amounts(sqrt_min_price, sqrt_max_price, sqrt_price, liquidity)?;
require!(
Expand Down Expand Up @@ -399,31 +391,3 @@ pub fn get_whitelisted_alpha_vault(payer: Pubkey, pool: Pubkey, has_alpha_vault:
Pubkey::default()
}
}

pub fn validate_quote_token(
token_mint_a: &Pubkey,
token_mint_b: &Pubkey,
has_alpha_vault: bool,
) -> Result<()> {
let is_a_whitelisted_quote_token = is_whitelisted_quote_token(token_mint_a);
// A will never be a whitelisted quote token
require!(!is_a_whitelisted_quote_token, PoolError::InvalidQuoteMint);
let is_b_whitelisted_quote_token = is_whitelisted_quote_token(token_mint_b);
if !is_b_whitelisted_quote_token {
// BE AWARE!!!!!!!!!!!!!!!!!!!!!!!!!!
// even B is not whitelisted quote token, but deployer should always be aware that B is quote token, A is base token
// if B is not whitelisted quote token, then pool shouldn't be linked with an alpha-vault
require!(!has_alpha_vault, PoolError::InvalidQuoteMint);
}

Ok(())
}

fn is_whitelisted_quote_token(mint: &Pubkey) -> bool {
for i in 0..DEFAULT_QUOTE_MINTS.len() {
if DEFAULT_QUOTE_MINTS[i].eq(mint) {
return true;
}
}
false
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
calculate_transfer_fee_included_amount, get_token_program_flags, is_supported_mint,
is_token_badge_initialized, transfer_from_user,
},
validate_quote_token, EvtCreatePosition, EvtInitializePool, PoolError,
EvtCreatePosition, EvtInitializePool, PoolError,
};

use super::{max_key, min_key, InitializeCustomizablePoolParameters};
Expand Down Expand Up @@ -216,14 +216,6 @@ pub fn handle_initialize_pool_with_dynamic_config<'c: 'info, 'info>(
PoolError::InvalidConfigType
);

// validate quote token
#[cfg(not(feature = "devnet"))]
validate_quote_token(
&ctx.accounts.token_a_mint.key(),
&ctx.accounts.token_b_mint.key(),
has_alpha_vault,
)?;

let (token_a_amount, token_b_amount) =
get_initialize_amounts(sqrt_min_price, sqrt_max_price, sqrt_price, liquidity)?;
require!(
Expand Down
Loading
0