feat: add support for pump mayhem mode
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "sol-trade-sdk"
|
name = "sol-trade-sdk"
|
||||||
version = "3.2.1"
|
version = "3.3.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = [
|
authors = [
|
||||||
"William <byteblock6@gmail.com>",
|
"William <byteblock6@gmail.com>",
|
||||||
|
|||||||
@@ -87,14 +87,14 @@ Add the dependency to your `Cargo.toml`:
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.toml
|
# Add to your Cargo.toml
|
||||||
sol-trade-sdk = { path = "./sol-trade-sdk", version = "3.2.1" }
|
sol-trade-sdk = { path = "./sol-trade-sdk", version = "3.3.0" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use crates.io
|
### Use crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.toml
|
# Add to your Cargo.toml
|
||||||
sol-trade-sdk = "3.2.1"
|
sol-trade-sdk = "3.3.0"
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🛠️ Usage Examples
|
## 🛠️ Usage Examples
|
||||||
|
|||||||
+2
-2
@@ -87,14 +87,14 @@ git clone https://github.com/0xfnzero/sol-trade-sdk
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
sol-trade-sdk = { path = "./sol-trade-sdk", version = "3.2.1" }
|
sol-trade-sdk = { path = "./sol-trade-sdk", version = "3.3.0" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### 使用 crates.io
|
### 使用 crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
sol-trade-sdk = "3.2.1"
|
sol-trade-sdk = "3.3.0"
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🛠️ 使用示例
|
## 🛠️ 使用示例
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
|
|||||||
trade_info.real_token_reserves,
|
trade_info.real_token_reserves,
|
||||||
trade_info.real_sol_reserves,
|
trade_info.real_sol_reserves,
|
||||||
None,
|
None,
|
||||||
|
trade_info.fee_recipient,
|
||||||
)),
|
)),
|
||||||
address_lookup_table_account: address_lookup_table_account,
|
address_lookup_table_account: address_lookup_table_account,
|
||||||
wait_transaction_confirmed: true,
|
wait_transaction_confirmed: true,
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
|
|||||||
trade_info.real_token_reserves,
|
trade_info.real_token_reserves,
|
||||||
trade_info.real_sol_reserves,
|
trade_info.real_sol_reserves,
|
||||||
None,
|
None,
|
||||||
|
trade_info.fee_recipient,
|
||||||
)),
|
)),
|
||||||
address_lookup_table_account: None,
|
address_lookup_table_account: None,
|
||||||
wait_transaction_confirmed: true,
|
wait_transaction_confirmed: true,
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
|
|||||||
trade_info.real_token_reserves,
|
trade_info.real_token_reserves,
|
||||||
trade_info.real_sol_reserves,
|
trade_info.real_sol_reserves,
|
||||||
None,
|
None,
|
||||||
|
trade_info.fee_recipient,
|
||||||
)),
|
)),
|
||||||
address_lookup_table_account: None,
|
address_lookup_table_account: None,
|
||||||
wait_transaction_confirmed: true,
|
wait_transaction_confirmed: true,
|
||||||
@@ -187,6 +188,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
|
|||||||
trade_info.real_token_reserves,
|
trade_info.real_token_reserves,
|
||||||
trade_info.real_sol_reserves,
|
trade_info.real_sol_reserves,
|
||||||
Some(true),
|
Some(true),
|
||||||
|
trade_info.fee_recipient,
|
||||||
)),
|
)),
|
||||||
address_lookup_table_account: None,
|
address_lookup_table_account: None,
|
||||||
wait_transaction_confirmed: true,
|
wait_transaction_confirmed: true,
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ async fn pumpfun_sniper_trade_with_shreds(trade_info: PumpFunTradeEvent) -> AnyR
|
|||||||
trade_info.associated_bonding_curve,
|
trade_info.associated_bonding_curve,
|
||||||
trade_info.creator_vault,
|
trade_info.creator_vault,
|
||||||
None,
|
None,
|
||||||
|
trade_info.fee_recipient,
|
||||||
)),
|
)),
|
||||||
address_lookup_table_account: None,
|
address_lookup_table_account: None,
|
||||||
wait_transaction_confirmed: true,
|
wait_transaction_confirmed: true,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
PUMPSWAP_PROGRAM_ID.to_string(), // Listen to PumpSwap program ID
|
PUMPSWAP_PROGRAM_ID.to_string(), // Listen to PumpSwap program ID
|
||||||
];
|
];
|
||||||
let account_exclude = vec![];
|
let account_exclude = vec![];
|
||||||
|
|
||||||
let account_required = vec![];
|
let account_required = vec![];
|
||||||
|
|
||||||
// Listen to transaction data
|
// Listen to transaction data
|
||||||
@@ -148,9 +148,11 @@ async fn pumpswap_trade_with_grpc_buy_event(trade_info: PumpSwapBuyEvent) -> Any
|
|||||||
trade_info.coin_creator_vault_authority,
|
trade_info.coin_creator_vault_authority,
|
||||||
trade_info.base_token_program,
|
trade_info.base_token_program,
|
||||||
trade_info.quote_token_program,
|
trade_info.quote_token_program,
|
||||||
|
trade_info.protocol_fee_recipient,
|
||||||
);
|
);
|
||||||
let mint = if trade_info.base_mint == sol_trade_sdk::constants::USDC_TOKEN_ACCOUNT
|
let mint = if trade_info.base_mint == sol_trade_sdk::constants::USDC_TOKEN_ACCOUNT
|
||||||
|| trade_info.base_mint == sol_trade_sdk::constants::WSOL_TOKEN_ACCOUNT {
|
|| trade_info.base_mint == sol_trade_sdk::constants::WSOL_TOKEN_ACCOUNT
|
||||||
|
{
|
||||||
trade_info.quote_mint
|
trade_info.quote_mint
|
||||||
} else {
|
} else {
|
||||||
trade_info.base_mint
|
trade_info.base_mint
|
||||||
@@ -172,9 +174,11 @@ async fn pumpswap_trade_with_grpc_sell_event(trade_info: PumpSwapSellEvent) -> A
|
|||||||
trade_info.coin_creator_vault_authority,
|
trade_info.coin_creator_vault_authority,
|
||||||
trade_info.base_token_program,
|
trade_info.base_token_program,
|
||||||
trade_info.quote_token_program,
|
trade_info.quote_token_program,
|
||||||
|
trade_info.protocol_fee_recipient,
|
||||||
);
|
);
|
||||||
let mint = if trade_info.base_mint == sol_trade_sdk::constants::USDC_TOKEN_ACCOUNT
|
let mint = if trade_info.base_mint == sol_trade_sdk::constants::USDC_TOKEN_ACCOUNT
|
||||||
|| trade_info.base_mint == sol_trade_sdk::constants::WSOL_TOKEN_ACCOUNT {
|
|| trade_info.base_mint == sol_trade_sdk::constants::WSOL_TOKEN_ACCOUNT
|
||||||
|
{
|
||||||
trade_info.quote_mint
|
trade_info.quote_mint
|
||||||
} else {
|
} else {
|
||||||
trade_info.base_mint
|
trade_info.base_mint
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ pub struct BondingCurveAccount {
|
|||||||
pub complete: bool,
|
pub complete: bool,
|
||||||
/// Creator of the bonding curve
|
/// Creator of the bonding curve
|
||||||
pub creator: Pubkey,
|
pub creator: Pubkey,
|
||||||
|
/// Whether this is a mayhem mode token (Token2022)
|
||||||
|
pub is_mayhem_mode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BondingCurveAccount {
|
impl BondingCurveAccount {
|
||||||
@@ -67,6 +69,7 @@ impl BondingCurveAccount {
|
|||||||
dev_token_amount: u64,
|
dev_token_amount: u64,
|
||||||
dev_sol_amount: u64,
|
dev_sol_amount: u64,
|
||||||
creator: Pubkey,
|
creator: Pubkey,
|
||||||
|
is_mayhem_mode: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let account = if bonding_curve != Pubkey::default() {
|
let account = if bonding_curve != Pubkey::default() {
|
||||||
bonding_curve
|
bonding_curve
|
||||||
@@ -83,6 +86,7 @@ impl BondingCurveAccount {
|
|||||||
token_total_supply: TOKEN_TOTAL_SUPPLY,
|
token_total_supply: TOKEN_TOTAL_SUPPLY,
|
||||||
complete: false,
|
complete: false,
|
||||||
creator: creator,
|
creator: creator,
|
||||||
|
is_mayhem_mode: is_mayhem_mode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,6 +98,7 @@ impl BondingCurveAccount {
|
|||||||
virtual_sol_reserves: u64,
|
virtual_sol_reserves: u64,
|
||||||
real_token_reserves: u64,
|
real_token_reserves: u64,
|
||||||
real_sol_reserves: u64,
|
real_sol_reserves: u64,
|
||||||
|
is_mayhem_mode: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let account = if bonding_curve != Pubkey::default() {
|
let account = if bonding_curve != Pubkey::default() {
|
||||||
bonding_curve
|
bonding_curve
|
||||||
@@ -110,6 +115,7 @@ impl BondingCurveAccount {
|
|||||||
token_total_supply: TOKEN_TOTAL_SUPPLY,
|
token_total_supply: TOKEN_TOTAL_SUPPLY,
|
||||||
complete: false,
|
complete: false,
|
||||||
creator: creator,
|
creator: creator,
|
||||||
|
is_mayhem_mode: is_mayhem_mode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+53
-11
@@ -68,12 +68,25 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
|
|||||||
bonding_curve.account
|
bonding_curve.account
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Determine token program based on mayhem mode
|
||||||
|
let is_mayhem_mode = bonding_curve.is_mayhem_mode;
|
||||||
|
let token_program = if is_mayhem_mode {
|
||||||
|
crate::constants::TOKEN_PROGRAM_2022
|
||||||
|
} else {
|
||||||
|
crate::constants::TOKEN_PROGRAM
|
||||||
|
};
|
||||||
|
let token_program_meta = if is_mayhem_mode {
|
||||||
|
crate::constants::TOKEN_PROGRAM_2022_META
|
||||||
|
} else {
|
||||||
|
crate::constants::TOKEN_PROGRAM_META
|
||||||
|
};
|
||||||
|
|
||||||
let associated_bonding_curve =
|
let associated_bonding_curve =
|
||||||
if protocol_params.associated_bonding_curve == Pubkey::default() {
|
if protocol_params.associated_bonding_curve == Pubkey::default() {
|
||||||
crate::common::fast_fn::get_associated_token_address_with_program_id_fast(
|
crate::common::fast_fn::get_associated_token_address_with_program_id_fast(
|
||||||
&bonding_curve_addr,
|
&bonding_curve_addr,
|
||||||
¶ms.output_mint,
|
¶ms.output_mint,
|
||||||
&crate::constants::TOKEN_PROGRAM,
|
&token_program,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
protocol_params.associated_bonding_curve
|
protocol_params.associated_bonding_curve
|
||||||
@@ -83,7 +96,7 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
|
|||||||
crate::common::fast_fn::get_associated_token_address_with_program_id_fast_use_seed(
|
crate::common::fast_fn::get_associated_token_address_with_program_id_fast_use_seed(
|
||||||
¶ms.payer.pubkey(),
|
¶ms.payer.pubkey(),
|
||||||
¶ms.output_mint,
|
¶ms.output_mint,
|
||||||
&crate::constants::TOKEN_PROGRAM,
|
&token_program,
|
||||||
params.open_seed_optimize,
|
params.open_seed_optimize,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -102,7 +115,7 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
|
|||||||
¶ms.payer.pubkey(),
|
¶ms.payer.pubkey(),
|
||||||
¶ms.payer.pubkey(),
|
¶ms.payer.pubkey(),
|
||||||
¶ms.output_mint,
|
¶ms.output_mint,
|
||||||
&crate::constants::TOKEN_PROGRAM,
|
&token_program,
|
||||||
params.open_seed_optimize,
|
params.open_seed_optimize,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -113,16 +126,23 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
|
|||||||
buy_data[8..16].copy_from_slice(&buy_token_amount.to_le_bytes());
|
buy_data[8..16].copy_from_slice(&buy_token_amount.to_le_bytes());
|
||||||
buy_data[16..24].copy_from_slice(&max_sol_cost.to_le_bytes());
|
buy_data[16..24].copy_from_slice(&max_sol_cost.to_le_bytes());
|
||||||
|
|
||||||
|
// Determine fee recipient based on mayhem mode
|
||||||
|
let fee_recipient_meta = if is_mayhem_mode {
|
||||||
|
global_constants::MAYHEM_FEE_RECIPIENT_META
|
||||||
|
} else {
|
||||||
|
global_constants::FEE_RECIPIENT_META
|
||||||
|
};
|
||||||
|
|
||||||
let accounts: [AccountMeta; 16] = [
|
let accounts: [AccountMeta; 16] = [
|
||||||
global_constants::GLOBAL_ACCOUNT_META,
|
global_constants::GLOBAL_ACCOUNT_META,
|
||||||
global_constants::FEE_RECIPIENT_META,
|
fee_recipient_meta,
|
||||||
AccountMeta::new_readonly(params.output_mint, false),
|
AccountMeta::new_readonly(params.output_mint, false),
|
||||||
AccountMeta::new(bonding_curve_addr, false),
|
AccountMeta::new(bonding_curve_addr, false),
|
||||||
AccountMeta::new(associated_bonding_curve, false),
|
AccountMeta::new(associated_bonding_curve, false),
|
||||||
AccountMeta::new(user_token_account, false),
|
AccountMeta::new(user_token_account, false),
|
||||||
AccountMeta::new(params.payer.pubkey(), true),
|
AccountMeta::new(params.payer.pubkey(), true),
|
||||||
crate::constants::SYSTEM_PROGRAM_META,
|
crate::constants::SYSTEM_PROGRAM_META,
|
||||||
crate::constants::TOKEN_PROGRAM_META,
|
token_program_meta,
|
||||||
AccountMeta::new(creator_vault_pda, false),
|
AccountMeta::new(creator_vault_pda, false),
|
||||||
accounts::EVENT_AUTHORITY_META,
|
accounts::EVENT_AUTHORITY_META,
|
||||||
accounts::PUMPFUN_META,
|
accounts::PUMPFUN_META,
|
||||||
@@ -188,12 +208,25 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
|
|||||||
bonding_curve.account
|
bonding_curve.account
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Determine token program based on mayhem mode
|
||||||
|
let is_mayhem_mode = bonding_curve.is_mayhem_mode;
|
||||||
|
let token_program = if is_mayhem_mode {
|
||||||
|
crate::constants::TOKEN_PROGRAM_2022
|
||||||
|
} else {
|
||||||
|
crate::constants::TOKEN_PROGRAM
|
||||||
|
};
|
||||||
|
let token_program_meta = if is_mayhem_mode {
|
||||||
|
crate::constants::TOKEN_PROGRAM_2022_META
|
||||||
|
} else {
|
||||||
|
crate::constants::TOKEN_PROGRAM_META
|
||||||
|
};
|
||||||
|
|
||||||
let associated_bonding_curve =
|
let associated_bonding_curve =
|
||||||
if protocol_params.associated_bonding_curve == Pubkey::default() {
|
if protocol_params.associated_bonding_curve == Pubkey::default() {
|
||||||
crate::common::fast_fn::get_associated_token_address_with_program_id_fast(
|
crate::common::fast_fn::get_associated_token_address_with_program_id_fast(
|
||||||
&bonding_curve_addr,
|
&bonding_curve_addr,
|
||||||
¶ms.input_mint,
|
¶ms.input_mint,
|
||||||
&crate::constants::TOKEN_PROGRAM,
|
&token_program,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
protocol_params.associated_bonding_curve
|
protocol_params.associated_bonding_curve
|
||||||
@@ -203,7 +236,7 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
|
|||||||
crate::common::fast_fn::get_associated_token_address_with_program_id_fast_use_seed(
|
crate::common::fast_fn::get_associated_token_address_with_program_id_fast_use_seed(
|
||||||
¶ms.payer.pubkey(),
|
¶ms.payer.pubkey(),
|
||||||
¶ms.input_mint,
|
¶ms.input_mint,
|
||||||
&crate::constants::TOKEN_PROGRAM,
|
&token_program,
|
||||||
params.open_seed_optimize,
|
params.open_seed_optimize,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -217,9 +250,16 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
|
|||||||
sell_data[8..16].copy_from_slice(&token_amount.to_le_bytes());
|
sell_data[8..16].copy_from_slice(&token_amount.to_le_bytes());
|
||||||
sell_data[16..24].copy_from_slice(&min_sol_output.to_le_bytes());
|
sell_data[16..24].copy_from_slice(&min_sol_output.to_le_bytes());
|
||||||
|
|
||||||
|
// Determine fee recipient based on mayhem mode
|
||||||
|
let fee_recipient_meta = if is_mayhem_mode {
|
||||||
|
global_constants::MAYHEM_FEE_RECIPIENT_META
|
||||||
|
} else {
|
||||||
|
global_constants::FEE_RECIPIENT_META
|
||||||
|
};
|
||||||
|
|
||||||
let accounts: [AccountMeta; 14] = [
|
let accounts: [AccountMeta; 14] = [
|
||||||
global_constants::GLOBAL_ACCOUNT_META,
|
global_constants::GLOBAL_ACCOUNT_META,
|
||||||
global_constants::FEE_RECIPIENT_META,
|
fee_recipient_meta,
|
||||||
AccountMeta::new_readonly(params.input_mint, false),
|
AccountMeta::new_readonly(params.input_mint, false),
|
||||||
AccountMeta::new(bonding_curve_addr, false),
|
AccountMeta::new(bonding_curve_addr, false),
|
||||||
AccountMeta::new(associated_bonding_curve, false),
|
AccountMeta::new(associated_bonding_curve, false),
|
||||||
@@ -227,7 +267,7 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
|
|||||||
AccountMeta::new(params.payer.pubkey(), true),
|
AccountMeta::new(params.payer.pubkey(), true),
|
||||||
crate::constants::SYSTEM_PROGRAM_META,
|
crate::constants::SYSTEM_PROGRAM_META,
|
||||||
AccountMeta::new(creator_vault_pda, false),
|
AccountMeta::new(creator_vault_pda, false),
|
||||||
crate::constants::TOKEN_PROGRAM_META,
|
token_program_meta,
|
||||||
accounts::EVENT_AUTHORITY_META,
|
accounts::EVENT_AUTHORITY_META,
|
||||||
accounts::PUMPFUN_META,
|
accounts::PUMPFUN_META,
|
||||||
accounts::FEE_CONFIG_META,
|
accounts::FEE_CONFIG_META,
|
||||||
@@ -241,9 +281,11 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
|
|||||||
));
|
));
|
||||||
|
|
||||||
// Optional: Close token account
|
// Optional: Close token account
|
||||||
if protocol_params.close_token_account_when_sell.unwrap_or(false) || params.close_input_mint_ata {
|
if protocol_params.close_token_account_when_sell.unwrap_or(false)
|
||||||
|
|| params.close_input_mint_ata
|
||||||
|
{
|
||||||
instructions.push(close_account(
|
instructions.push(close_account(
|
||||||
&crate::constants::TOKEN_PROGRAM,
|
&token_program,
|
||||||
&user_token_account,
|
&user_token_account,
|
||||||
¶ms.payer.pubkey(),
|
¶ms.payer.pubkey(),
|
||||||
¶ms.payer.pubkey(),
|
¶ms.payer.pubkey(),
|
||||||
|
|||||||
+65
-41
@@ -53,10 +53,14 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
|||||||
let pool_base_token_account = protocol_params.pool_base_token_account;
|
let pool_base_token_account = protocol_params.pool_base_token_account;
|
||||||
let pool_quote_token_account = protocol_params.pool_quote_token_account;
|
let pool_quote_token_account = protocol_params.pool_quote_token_account;
|
||||||
|
|
||||||
let is_wsol = (base_mint == crate::constants::WSOL_TOKEN_ACCOUNT && quote_mint != crate::constants::USDC_TOKEN_ACCOUNT)
|
let is_wsol = (base_mint == crate::constants::WSOL_TOKEN_ACCOUNT
|
||||||
|| (quote_mint == crate::constants::WSOL_TOKEN_ACCOUNT && base_mint != crate::constants::USDC_TOKEN_ACCOUNT);
|
&& quote_mint != crate::constants::USDC_TOKEN_ACCOUNT)
|
||||||
let is_usdc = (base_mint == crate::constants::USDC_TOKEN_ACCOUNT && quote_mint != crate::constants::WSOL_TOKEN_ACCOUNT)
|
|| (quote_mint == crate::constants::WSOL_TOKEN_ACCOUNT
|
||||||
|| (quote_mint == crate::constants::USDC_TOKEN_ACCOUNT && base_mint != crate::constants::WSOL_TOKEN_ACCOUNT);
|
&& base_mint != crate::constants::USDC_TOKEN_ACCOUNT);
|
||||||
|
let is_usdc = (base_mint == crate::constants::USDC_TOKEN_ACCOUNT
|
||||||
|
&& quote_mint != crate::constants::WSOL_TOKEN_ACCOUNT)
|
||||||
|
|| (quote_mint == crate::constants::USDC_TOKEN_ACCOUNT
|
||||||
|
&& base_mint != crate::constants::WSOL_TOKEN_ACCOUNT);
|
||||||
if !is_wsol && !is_usdc {
|
if !is_wsol && !is_usdc {
|
||||||
return Err(anyhow!("Pool must contain WSOL or USDC"));
|
return Err(anyhow!("Pool must contain WSOL or USDC"));
|
||||||
}
|
}
|
||||||
@@ -64,7 +68,7 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
|||||||
// ========================================
|
// ========================================
|
||||||
// Trade calculation and account address preparation
|
// Trade calculation and account address preparation
|
||||||
// ========================================
|
// ========================================
|
||||||
let quote_is_wsol_or_usdc = quote_mint == crate::constants::WSOL_TOKEN_ACCOUNT
|
let quote_is_wsol_or_usdc = quote_mint == crate::constants::WSOL_TOKEN_ACCOUNT
|
||||||
|| quote_mint == crate::constants::USDC_TOKEN_ACCOUNT;
|
|| quote_mint == crate::constants::USDC_TOKEN_ACCOUNT;
|
||||||
let mut creator = Pubkey::default();
|
let mut creator = Pubkey::default();
|
||||||
if params_coin_creator_vault_authority != accounts::DEFAULT_COIN_CREATOR_VAULT_AUTHORITY {
|
if params_coin_creator_vault_authority != accounts::DEFAULT_COIN_CREATOR_VAULT_AUTHORITY {
|
||||||
@@ -113,7 +117,17 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
|||||||
"e_token_program,
|
"e_token_program,
|
||||||
params.open_seed_optimize,
|
params.open_seed_optimize,
|
||||||
);
|
);
|
||||||
let fee_recipient_ata = fee_recipient_ata(accounts::FEE_RECIPIENT, quote_mint);
|
|
||||||
|
// Determine fee recipient based on mayhem mode
|
||||||
|
let is_mayhem_mode = protocol_params.is_mayhem_mode;
|
||||||
|
let fee_recipient =
|
||||||
|
if is_mayhem_mode { accounts::MAYHEM_FEE_RECIPIENT } else { accounts::FEE_RECIPIENT };
|
||||||
|
let fee_recipient_meta = if is_mayhem_mode {
|
||||||
|
accounts::MAYHEM_FEE_RECIPIENT_META
|
||||||
|
} else {
|
||||||
|
accounts::FEE_RECIPIENT_META
|
||||||
|
};
|
||||||
|
let fee_recipient_ata = fee_recipient_ata(fee_recipient, quote_mint);
|
||||||
|
|
||||||
// ========================================
|
// ========================================
|
||||||
// Build instructions
|
// Build instructions
|
||||||
@@ -140,18 +154,18 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
|||||||
// Create buy instruction
|
// Create buy instruction
|
||||||
let mut accounts = Vec::with_capacity(23);
|
let mut accounts = Vec::with_capacity(23);
|
||||||
accounts.extend([
|
accounts.extend([
|
||||||
AccountMeta::new(pool, false), // pool_id
|
AccountMeta::new(pool, false), // pool_id
|
||||||
AccountMeta::new(params.payer.pubkey(), true), // user (signer)
|
AccountMeta::new(params.payer.pubkey(), true), // user (signer)
|
||||||
accounts::GLOBAL_ACCOUNT_META, // global (readonly)
|
accounts::GLOBAL_ACCOUNT_META, // global (readonly)
|
||||||
AccountMeta::new_readonly(base_mint, false), // base_mint (readonly)
|
AccountMeta::new_readonly(base_mint, false), // base_mint (readonly)
|
||||||
AccountMeta::new_readonly(quote_mint, false), // quote_mint (readonly)
|
AccountMeta::new_readonly(quote_mint, false), // quote_mint (readonly)
|
||||||
AccountMeta::new(user_base_token_account, false), // user_base_token_account
|
AccountMeta::new(user_base_token_account, false), // user_base_token_account
|
||||||
AccountMeta::new(user_quote_token_account, false), // user_quote_token_account
|
AccountMeta::new(user_quote_token_account, false), // user_quote_token_account
|
||||||
AccountMeta::new(pool_base_token_account, false), // pool_base_token_account
|
AccountMeta::new(pool_base_token_account, false), // pool_base_token_account
|
||||||
AccountMeta::new(pool_quote_token_account, false), // pool_quote_token_account
|
AccountMeta::new(pool_quote_token_account, false), // pool_quote_token_account
|
||||||
accounts::FEE_RECIPIENT_META, // fee_recipient (readonly)
|
fee_recipient_meta, // fee_recipient (readonly)
|
||||||
AccountMeta::new(fee_recipient_ata, false), // fee_recipient_ata
|
AccountMeta::new(fee_recipient_ata, false), // fee_recipient_ata
|
||||||
AccountMeta::new_readonly(base_token_program, false), // TOKEN_PROGRAM_ID (readonly)
|
AccountMeta::new_readonly(base_token_program, false), // TOKEN_PROGRAM_ID (readonly)
|
||||||
AccountMeta::new_readonly(quote_token_program, false), // TOKEN_PROGRAM_ID (readonly, duplicated as in JS)
|
AccountMeta::new_readonly(quote_token_program, false), // TOKEN_PROGRAM_ID (readonly, duplicated as in JS)
|
||||||
crate::constants::SYSTEM_PROGRAM_META, // System Program (readonly)
|
crate::constants::SYSTEM_PROGRAM_META, // System Program (readonly)
|
||||||
accounts::ASSOCIATED_TOKEN_PROGRAM_META, // ASSOCIATED_TOKEN_PROGRAM_ID (readonly)
|
accounts::ASSOCIATED_TOKEN_PROGRAM_META, // ASSOCIATED_TOKEN_PROGRAM_ID (readonly)
|
||||||
@@ -222,10 +236,14 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
|||||||
let base_token_program = protocol_params.base_token_program;
|
let base_token_program = protocol_params.base_token_program;
|
||||||
let quote_token_program = protocol_params.quote_token_program;
|
let quote_token_program = protocol_params.quote_token_program;
|
||||||
|
|
||||||
let is_wsol = (base_mint == crate::constants::WSOL_TOKEN_ACCOUNT && quote_mint != crate::constants::USDC_TOKEN_ACCOUNT)
|
let is_wsol = (base_mint == crate::constants::WSOL_TOKEN_ACCOUNT
|
||||||
|| (quote_mint == crate::constants::WSOL_TOKEN_ACCOUNT && base_mint != crate::constants::USDC_TOKEN_ACCOUNT);
|
&& quote_mint != crate::constants::USDC_TOKEN_ACCOUNT)
|
||||||
let is_usdc = (base_mint == crate::constants::USDC_TOKEN_ACCOUNT && quote_mint != crate::constants::WSOL_TOKEN_ACCOUNT)
|
|| (quote_mint == crate::constants::WSOL_TOKEN_ACCOUNT
|
||||||
|| (quote_mint == crate::constants::USDC_TOKEN_ACCOUNT && base_mint != crate::constants::WSOL_TOKEN_ACCOUNT);
|
&& base_mint != crate::constants::USDC_TOKEN_ACCOUNT);
|
||||||
|
let is_usdc = (base_mint == crate::constants::USDC_TOKEN_ACCOUNT
|
||||||
|
&& quote_mint != crate::constants::WSOL_TOKEN_ACCOUNT)
|
||||||
|
|| (quote_mint == crate::constants::USDC_TOKEN_ACCOUNT
|
||||||
|
&& base_mint != crate::constants::WSOL_TOKEN_ACCOUNT);
|
||||||
if !is_wsol && !is_usdc {
|
if !is_wsol && !is_usdc {
|
||||||
return Err(anyhow!("Pool must contain WSOL or USDC"));
|
return Err(anyhow!("Pool must contain WSOL or USDC"));
|
||||||
}
|
}
|
||||||
@@ -237,7 +255,7 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
|||||||
// ========================================
|
// ========================================
|
||||||
// Trade calculation and account address preparation
|
// Trade calculation and account address preparation
|
||||||
// ========================================
|
// ========================================
|
||||||
let quote_is_wsol_or_usdc = quote_mint == crate::constants::WSOL_TOKEN_ACCOUNT
|
let quote_is_wsol_or_usdc = quote_mint == crate::constants::WSOL_TOKEN_ACCOUNT
|
||||||
|| quote_mint == crate::constants::USDC_TOKEN_ACCOUNT;
|
|| quote_mint == crate::constants::USDC_TOKEN_ACCOUNT;
|
||||||
let mut creator = Pubkey::default();
|
let mut creator = Pubkey::default();
|
||||||
if params_coin_creator_vault_authority != accounts::DEFAULT_COIN_CREATOR_VAULT_AUTHORITY {
|
if params_coin_creator_vault_authority != accounts::DEFAULT_COIN_CREATOR_VAULT_AUTHORITY {
|
||||||
@@ -272,7 +290,17 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
|||||||
sol_amount = params.fixed_output_amount.unwrap();
|
sol_amount = params.fixed_output_amount.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let fee_recipient_ata = fee_recipient_ata(accounts::FEE_RECIPIENT, quote_mint);
|
// Determine fee recipient based on mayhem mode
|
||||||
|
let is_mayhem_mode = protocol_params.is_mayhem_mode;
|
||||||
|
let fee_recipient =
|
||||||
|
if is_mayhem_mode { accounts::MAYHEM_FEE_RECIPIENT } else { accounts::FEE_RECIPIENT };
|
||||||
|
let fee_recipient_meta = if is_mayhem_mode {
|
||||||
|
accounts::MAYHEM_FEE_RECIPIENT_META
|
||||||
|
} else {
|
||||||
|
accounts::FEE_RECIPIENT_META
|
||||||
|
};
|
||||||
|
let fee_recipient_ata = fee_recipient_ata(fee_recipient, quote_mint);
|
||||||
|
|
||||||
let user_base_token_account =
|
let user_base_token_account =
|
||||||
crate::common::fast_fn::get_associated_token_address_with_program_id_fast_use_seed(
|
crate::common::fast_fn::get_associated_token_address_with_program_id_fast_use_seed(
|
||||||
¶ms.payer.pubkey(),
|
¶ms.payer.pubkey(),
|
||||||
@@ -300,18 +328,18 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
|||||||
// Create sell instruction
|
// Create sell instruction
|
||||||
let mut accounts = Vec::with_capacity(23);
|
let mut accounts = Vec::with_capacity(23);
|
||||||
accounts.extend([
|
accounts.extend([
|
||||||
AccountMeta::new(pool, false), // pool_id
|
AccountMeta::new(pool, false), // pool_id
|
||||||
AccountMeta::new(params.payer.pubkey(), true), // user (signer)
|
AccountMeta::new(params.payer.pubkey(), true), // user (signer)
|
||||||
accounts::GLOBAL_ACCOUNT_META, // global (readonly)
|
accounts::GLOBAL_ACCOUNT_META, // global (readonly)
|
||||||
AccountMeta::new_readonly(base_mint, false), // mint (readonly)
|
AccountMeta::new_readonly(base_mint, false), // mint (readonly)
|
||||||
AccountMeta::new_readonly(quote_mint, false), // WSOL_TOKEN_ACCOUNT (readonly)
|
AccountMeta::new_readonly(quote_mint, false), // WSOL_TOKEN_ACCOUNT (readonly)
|
||||||
AccountMeta::new(user_base_token_account, false), // user_base_token_account
|
AccountMeta::new(user_base_token_account, false), // user_base_token_account
|
||||||
AccountMeta::new(user_quote_token_account, false), // user_quote_token_account
|
AccountMeta::new(user_quote_token_account, false), // user_quote_token_account
|
||||||
AccountMeta::new(pool_base_token_account, false), // pool_base_token_account
|
AccountMeta::new(pool_base_token_account, false), // pool_base_token_account
|
||||||
AccountMeta::new(pool_quote_token_account, false), // pool_quote_token_account
|
AccountMeta::new(pool_quote_token_account, false), // pool_quote_token_account
|
||||||
accounts::FEE_RECIPIENT_META, // fee_recipient (readonly)
|
fee_recipient_meta, // fee_recipient (readonly)
|
||||||
AccountMeta::new(fee_recipient_ata, false), // fee_recipient_ata
|
AccountMeta::new(fee_recipient_ata, false), // fee_recipient_ata
|
||||||
AccountMeta::new_readonly(base_token_program, false), // TOKEN_PROGRAM_ID (readonly)
|
AccountMeta::new_readonly(base_token_program, false), // TOKEN_PROGRAM_ID (readonly)
|
||||||
AccountMeta::new_readonly(quote_token_program, false), // TOKEN_PROGRAM_ID (readonly, duplicated as in JS)
|
AccountMeta::new_readonly(quote_token_program, false), // TOKEN_PROGRAM_ID (readonly, duplicated as in JS)
|
||||||
crate::constants::SYSTEM_PROGRAM_META, // System Program (readonly)
|
crate::constants::SYSTEM_PROGRAM_META, // System Program (readonly)
|
||||||
accounts::ASSOCIATED_TOKEN_PROGRAM_META, // ASSOCIATED_TOKEN_PROGRAM_ID (readonly)
|
accounts::ASSOCIATED_TOKEN_PROGRAM_META, // ASSOCIATED_TOKEN_PROGRAM_ID (readonly)
|
||||||
@@ -358,11 +386,7 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
|||||||
}
|
}
|
||||||
if params.close_input_mint_ata {
|
if params.close_input_mint_ata {
|
||||||
instructions.push(crate::common::spl_token::close_account(
|
instructions.push(crate::common::spl_token::close_account(
|
||||||
if quote_is_wsol_or_usdc {
|
if quote_is_wsol_or_usdc { &base_token_program } else { "e_token_program },
|
||||||
&base_token_program
|
|
||||||
} else {
|
|
||||||
"e_token_program
|
|
||||||
},
|
|
||||||
if quote_is_wsol_or_usdc {
|
if quote_is_wsol_or_usdc {
|
||||||
&user_base_token_account
|
&user_base_token_account
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
use crate::common::{bonding_curve::BondingCurveAccount, global::GlobalAccount, SolanaRpcClient};
|
use crate::common::{bonding_curve::BondingCurveAccount, SolanaRpcClient};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::sync::Arc;
|
||||||
use tokio::sync::RwLock;
|
|
||||||
|
|
||||||
/// Constants used as seeds for deriving PDAs (Program Derived Addresses)
|
/// Constants used as seeds for deriving PDAs (Program Derived Addresses)
|
||||||
pub mod seeds {
|
pub mod seeds {
|
||||||
@@ -58,6 +57,15 @@ pub mod global_constants {
|
|||||||
is_writable: true,
|
is_writable: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const MAYHEM_FEE_RECIPIENT: Pubkey =
|
||||||
|
pubkey!("GesfTA3X2arioaHp8bbKdjG9vJtskViWACZoYvxp4twS");
|
||||||
|
pub const MAYHEM_FEE_RECIPIENT_META: solana_sdk::instruction::AccountMeta =
|
||||||
|
solana_sdk::instruction::AccountMeta {
|
||||||
|
pubkey: FEE_RECIPIENT,
|
||||||
|
is_signer: false,
|
||||||
|
is_writable: true,
|
||||||
|
};
|
||||||
|
|
||||||
/// Public key for the global PDA
|
/// Public key for the global PDA
|
||||||
pub const GLOBAL_ACCOUNT: Pubkey = pubkey!("4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf");
|
pub const GLOBAL_ACCOUNT: Pubkey = pubkey!("4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf");
|
||||||
pub const GLOBAL_ACCOUNT_META: solana_sdk::instruction::AccountMeta =
|
pub const GLOBAL_ACCOUNT_META: solana_sdk::instruction::AccountMeta =
|
||||||
@@ -152,10 +160,6 @@ impl Symbol {
|
|||||||
pub const SOLANA: &'static str = "solana";
|
pub const SOLANA: &'static str = "solana";
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
|
||||||
static ref ACCOUNT_CACHE: RwLock<HashMap<Pubkey, Arc<GlobalAccount>>> = RwLock::new(HashMap::new());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_bonding_curve_pda(mint: &Pubkey) -> Option<Pubkey> {
|
pub fn get_bonding_curve_pda(mint: &Pubkey) -> Option<Pubkey> {
|
||||||
crate::common::fast_fn::get_cached_pda(
|
crate::common::fast_fn::get_cached_pda(
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ pub mod accounts {
|
|||||||
pub const DEFAULT_COIN_CREATOR_VAULT_AUTHORITY: Pubkey =
|
pub const DEFAULT_COIN_CREATOR_VAULT_AUTHORITY: Pubkey =
|
||||||
pubkey!("8N3GDaZ2iwN65oxVatKTLPNooAVUJTbfiVJ1ahyqwjSk");
|
pubkey!("8N3GDaZ2iwN65oxVatKTLPNooAVUJTbfiVJ1ahyqwjSk");
|
||||||
|
|
||||||
|
/// Mayhem fee recipient (for mayhem mode coins)
|
||||||
|
pub const MAYHEM_FEE_RECIPIENT: Pubkey =
|
||||||
|
pubkey!("GesfTA3X2arioaHp8bbKdjG9vJtskViWACZoYvxp4twS");
|
||||||
|
|
||||||
// META
|
// META
|
||||||
|
|
||||||
pub const GLOBAL_ACCOUNT_META: solana_sdk::instruction::AccountMeta =
|
pub const GLOBAL_ACCOUNT_META: solana_sdk::instruction::AccountMeta =
|
||||||
@@ -81,6 +85,13 @@ pub mod accounts {
|
|||||||
is_writable: false,
|
is_writable: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const MAYHEM_FEE_RECIPIENT_META: solana_sdk::instruction::AccountMeta =
|
||||||
|
solana_sdk::instruction::AccountMeta {
|
||||||
|
pubkey: MAYHEM_FEE_RECIPIENT,
|
||||||
|
is_signer: false,
|
||||||
|
is_writable: false,
|
||||||
|
};
|
||||||
|
|
||||||
pub const ASSOCIATED_TOKEN_PROGRAM_META: solana_sdk::instruction::AccountMeta =
|
pub const ASSOCIATED_TOKEN_PROGRAM_META: solana_sdk::instruction::AccountMeta =
|
||||||
solana_sdk::instruction::AccountMeta {
|
solana_sdk::instruction::AccountMeta {
|
||||||
pubkey: ASSOCIATED_TOKEN_PROGRAM,
|
pubkey: ASSOCIATED_TOKEN_PROGRAM,
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ pub struct Pool {
|
|||||||
pub pool_quote_token_account: Pubkey,
|
pub pool_quote_token_account: Pubkey,
|
||||||
pub lp_supply: u64,
|
pub lp_supply: u64,
|
||||||
pub coin_creator: Pubkey,
|
pub coin_creator: Pubkey,
|
||||||
|
pub is_mayhem_mode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const POOL_SIZE: usize = 1 + 2 + 32 * 6 + 8 + 32;
|
pub const POOL_SIZE: usize = 1 + 2 + 32 * 6 + 8 + 32 + 1;
|
||||||
|
|
||||||
pub fn pool_decode(data: &[u8]) -> Option<Pool> {
|
pub fn pool_decode(data: &[u8]) -> Option<Pool> {
|
||||||
if data.len() < POOL_SIZE {
|
if data.len() < POOL_SIZE {
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ use crate::common::nonce_cache::DurableNonceInfo;
|
|||||||
use crate::common::spl_associated_token_account::get_associated_token_address_with_program_id;
|
use crate::common::spl_associated_token_account::get_associated_token_address_with_program_id;
|
||||||
use crate::common::{GasFeeStrategy, SolanaRpcClient};
|
use crate::common::{GasFeeStrategy, SolanaRpcClient};
|
||||||
use crate::constants::TOKEN_PROGRAM;
|
use crate::constants::TOKEN_PROGRAM;
|
||||||
|
use crate::instruction::utils::pumpfun::global_constants::MAYHEM_FEE_RECIPIENT;
|
||||||
|
use crate::instruction::utils::pumpswap::accounts::MAYHEM_FEE_RECIPIENT as MAYHEM_FEE_RECIPIENT_SWAP;
|
||||||
use crate::swqos::{SwqosClient, TradeType};
|
use crate::swqos::{SwqosClient, TradeType};
|
||||||
use crate::trading::common::get_multi_token_balances;
|
use crate::trading::common::get_multi_token_balances;
|
||||||
use crate::trading::MiddlewareManager;
|
use crate::trading::MiddlewareManager;
|
||||||
@@ -79,13 +81,16 @@ impl PumpFunParams {
|
|||||||
associated_bonding_curve: Pubkey,
|
associated_bonding_curve: Pubkey,
|
||||||
creator_vault: Pubkey,
|
creator_vault: Pubkey,
|
||||||
close_token_account_when_sell: Option<bool>,
|
close_token_account_when_sell: Option<bool>,
|
||||||
|
fee_recipient: Pubkey,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
let is_mayhem_mode = fee_recipient == MAYHEM_FEE_RECIPIENT;
|
||||||
let bonding_curve_account = BondingCurveAccount::from_dev_trade(
|
let bonding_curve_account = BondingCurveAccount::from_dev_trade(
|
||||||
bonding_curve,
|
bonding_curve,
|
||||||
&mint,
|
&mint,
|
||||||
token_amount,
|
token_amount,
|
||||||
max_sol_cost,
|
max_sol_cost,
|
||||||
creator,
|
creator,
|
||||||
|
is_mayhem_mode,
|
||||||
);
|
);
|
||||||
Self {
|
Self {
|
||||||
bonding_curve: Arc::new(bonding_curve_account),
|
bonding_curve: Arc::new(bonding_curve_account),
|
||||||
@@ -106,7 +111,9 @@ impl PumpFunParams {
|
|||||||
real_token_reserves: u64,
|
real_token_reserves: u64,
|
||||||
real_sol_reserves: u64,
|
real_sol_reserves: u64,
|
||||||
close_token_account_when_sell: Option<bool>,
|
close_token_account_when_sell: Option<bool>,
|
||||||
|
fee_recipient: Pubkey,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
let is_mayhem_mode = fee_recipient == MAYHEM_FEE_RECIPIENT;
|
||||||
let bonding_curve = BondingCurveAccount::from_trade(
|
let bonding_curve = BondingCurveAccount::from_trade(
|
||||||
bonding_curve,
|
bonding_curve,
|
||||||
mint,
|
mint,
|
||||||
@@ -115,6 +122,7 @@ impl PumpFunParams {
|
|||||||
virtual_sol_reserves,
|
virtual_sol_reserves,
|
||||||
real_token_reserves,
|
real_token_reserves,
|
||||||
real_sol_reserves,
|
real_sol_reserves,
|
||||||
|
is_mayhem_mode,
|
||||||
);
|
);
|
||||||
Self {
|
Self {
|
||||||
bonding_curve: Arc::new(bonding_curve),
|
bonding_curve: Arc::new(bonding_curve),
|
||||||
@@ -140,6 +148,7 @@ impl PumpFunParams {
|
|||||||
token_total_supply: account.0.token_total_supply,
|
token_total_supply: account.0.token_total_supply,
|
||||||
complete: account.0.complete,
|
complete: account.0.complete,
|
||||||
creator: account.0.creator,
|
creator: account.0.creator,
|
||||||
|
is_mayhem_mode: account.0.is_mayhem_mode,
|
||||||
};
|
};
|
||||||
let associated_bonding_curve = get_associated_token_address_with_program_id(
|
let associated_bonding_curve = get_associated_token_address_with_program_id(
|
||||||
&bonding_curve.account,
|
&bonding_curve.account,
|
||||||
@@ -201,6 +210,8 @@ pub struct PumpSwapParams {
|
|||||||
pub base_token_program: Pubkey,
|
pub base_token_program: Pubkey,
|
||||||
/// Quote token program ID
|
/// Quote token program ID
|
||||||
pub quote_token_program: Pubkey,
|
pub quote_token_program: Pubkey,
|
||||||
|
/// Whether the pool is in mayhem mode
|
||||||
|
pub is_mayhem_mode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PumpSwapParams {
|
impl PumpSwapParams {
|
||||||
@@ -216,7 +227,9 @@ impl PumpSwapParams {
|
|||||||
coin_creator_vault_authority: Pubkey,
|
coin_creator_vault_authority: Pubkey,
|
||||||
base_token_program: Pubkey,
|
base_token_program: Pubkey,
|
||||||
quote_token_program: Pubkey,
|
quote_token_program: Pubkey,
|
||||||
|
fee_recipient: Pubkey,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
let is_mayhem_mode = fee_recipient == MAYHEM_FEE_RECIPIENT_SWAP;
|
||||||
Self {
|
Self {
|
||||||
pool,
|
pool,
|
||||||
base_mint,
|
base_mint,
|
||||||
@@ -229,6 +242,7 @@ impl PumpSwapParams {
|
|||||||
coin_creator_vault_authority,
|
coin_creator_vault_authority,
|
||||||
base_token_program,
|
base_token_program,
|
||||||
quote_token_program,
|
quote_token_program,
|
||||||
|
is_mayhem_mode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,6 +309,7 @@ impl PumpSwapParams {
|
|||||||
} else {
|
} else {
|
||||||
crate::constants::TOKEN_PROGRAM_2022
|
crate::constants::TOKEN_PROGRAM_2022
|
||||||
},
|
},
|
||||||
|
is_mayhem_mode: pool_data.is_mayhem_mode,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user