refactor: Refactor SDK core architecture and trading parameter system
- Refactor SolanaTrade main class structure with improved modular design - Refactor trading parameter system: BuyParams/SellParams -> InternalBuyParams/InternalSellParams - Remove deprecated PriorityFee and related utility functions - Add SwqosSettings to replace legacy SwqosConfig - Add comprehensive technical documentation: • Address Lookup Table usage guide (EN/CN) • Nonce Cache mechanism documentation (EN/CN) • Trading Parameters documentation (EN/CN) - Refactor all example code to adapt to new API interfaces - Optimize public API design and code comments - Clean up redundant utility functions and type definitions Impact: 43 files changed, 2013 insertions(+), 1735 deletions(-)
This commit is contained in:
@@ -7,7 +7,7 @@ use crate::{
|
||||
trading::{
|
||||
common::utils::get_token_balance,
|
||||
core::{
|
||||
params::{BonkParams, BuyParams, SellParams},
|
||||
params::{BonkParams, InternalBuyParams, InternalSellParams},
|
||||
traits::InstructionBuilder,
|
||||
},
|
||||
},
|
||||
@@ -27,7 +27,7 @@ pub struct BonkInstructionBuilder;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl InstructionBuilder for BonkInstructionBuilder {
|
||||
async fn build_buy_instructions(&self, params: &BuyParams) -> Result<Vec<Instruction>> {
|
||||
async fn build_buy_instructions(&self, params: &InternalBuyParams) -> Result<Vec<Instruction>> {
|
||||
// ========================================
|
||||
// Parameter validation and basic data preparation
|
||||
// ========================================
|
||||
@@ -144,7 +144,7 @@ impl InstructionBuilder for BonkInstructionBuilder {
|
||||
Ok(instructions)
|
||||
}
|
||||
|
||||
async fn build_sell_instructions(&self, params: &SellParams) -> Result<Vec<Instruction>> {
|
||||
async fn build_sell_instructions(&self, params: &InternalSellParams) -> Result<Vec<Instruction>> {
|
||||
// ========================================
|
||||
// Parameter validation and basic data preparation
|
||||
// ========================================
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
constants::trade::trade::DEFAULT_SLIPPAGE,
|
||||
trading::core::{
|
||||
params::{BuyParams, PumpFunParams, SellParams},
|
||||
params::{InternalBuyParams, PumpFunParams, InternalSellParams},
|
||||
traits::InstructionBuilder,
|
||||
},
|
||||
};
|
||||
@@ -25,7 +25,7 @@ pub struct PumpFunInstructionBuilder;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl InstructionBuilder for PumpFunInstructionBuilder {
|
||||
async fn build_buy_instructions(&self, params: &BuyParams) -> Result<Vec<Instruction>> {
|
||||
async fn build_buy_instructions(&self, params: &InternalBuyParams) -> Result<Vec<Instruction>> {
|
||||
// ========================================
|
||||
// Parameter validation and basic data preparation
|
||||
// ========================================
|
||||
@@ -138,7 +138,7 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
|
||||
Ok(instructions)
|
||||
}
|
||||
|
||||
async fn build_sell_instructions(&self, params: &SellParams) -> Result<Vec<Instruction>> {
|
||||
async fn build_sell_instructions(&self, params: &InternalSellParams) -> Result<Vec<Instruction>> {
|
||||
// ========================================
|
||||
// Parameter validation and basic data preparation
|
||||
// ========================================
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::{
|
||||
trading::{
|
||||
common::wsol_manager,
|
||||
core::{
|
||||
params::{BuyParams, PumpSwapParams, SellParams},
|
||||
params::{InternalBuyParams, PumpSwapParams, InternalSellParams},
|
||||
traits::InstructionBuilder,
|
||||
},
|
||||
},
|
||||
@@ -25,7 +25,7 @@ pub struct PumpSwapInstructionBuilder;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl InstructionBuilder for PumpSwapInstructionBuilder {
|
||||
async fn build_buy_instructions(&self, params: &BuyParams) -> Result<Vec<Instruction>> {
|
||||
async fn build_buy_instructions(&self, params: &InternalBuyParams) -> Result<Vec<Instruction>> {
|
||||
// ========================================
|
||||
// Parameter validation and basic data preparation
|
||||
// ========================================
|
||||
@@ -197,7 +197,7 @@ impl InstructionBuilder for PumpSwapInstructionBuilder {
|
||||
Ok(instructions)
|
||||
}
|
||||
|
||||
async fn build_sell_instructions(&self, params: &SellParams) -> Result<Vec<Instruction>> {
|
||||
async fn build_sell_instructions(&self, params: &InternalSellParams) -> Result<Vec<Instruction>> {
|
||||
// ========================================
|
||||
// Parameter validation and basic data preparation
|
||||
// ========================================
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::{
|
||||
constants::trade::trade::DEFAULT_SLIPPAGE,
|
||||
instruction::utils::raydium_amm_v4::{accounts, SWAP_BASE_IN_DISCRIMINATOR},
|
||||
trading::core::{
|
||||
params::{BuyParams, RaydiumAmmV4Params, SellParams},
|
||||
params::{InternalBuyParams, RaydiumAmmV4Params, InternalSellParams},
|
||||
traits::InstructionBuilder,
|
||||
},
|
||||
utils::calc::raydium_amm_v4::compute_swap_amount,
|
||||
@@ -18,7 +18,7 @@ pub struct RaydiumAmmV4InstructionBuilder;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl InstructionBuilder for RaydiumAmmV4InstructionBuilder {
|
||||
async fn build_buy_instructions(&self, params: &BuyParams) -> Result<Vec<Instruction>> {
|
||||
async fn build_buy_instructions(&self, params: &InternalBuyParams) -> Result<Vec<Instruction>> {
|
||||
// ========================================
|
||||
// Parameter validation and basic data preparation
|
||||
// ========================================
|
||||
@@ -122,7 +122,7 @@ impl InstructionBuilder for RaydiumAmmV4InstructionBuilder {
|
||||
Ok(instructions)
|
||||
}
|
||||
|
||||
async fn build_sell_instructions(&self, params: &SellParams) -> Result<Vec<Instruction>> {
|
||||
async fn build_sell_instructions(&self, params: &InternalSellParams) -> Result<Vec<Instruction>> {
|
||||
// ========================================
|
||||
// Parameter validation and basic data preparation
|
||||
// ========================================
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::{
|
||||
SWAP_BASE_IN_DISCRIMINATOR,
|
||||
},
|
||||
trading::core::{
|
||||
params::{BuyParams, RaydiumCpmmParams, SellParams},
|
||||
params::{InternalBuyParams, RaydiumCpmmParams, InternalSellParams},
|
||||
traits::InstructionBuilder,
|
||||
},
|
||||
utils::calc::raydium_cpmm::compute_swap_amount,
|
||||
@@ -23,7 +23,7 @@ pub struct RaydiumCpmmInstructionBuilder;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl InstructionBuilder for RaydiumCpmmInstructionBuilder {
|
||||
async fn build_buy_instructions(&self, params: &BuyParams) -> Result<Vec<Instruction>> {
|
||||
async fn build_buy_instructions(&self, params: &InternalBuyParams) -> Result<Vec<Instruction>> {
|
||||
// ========================================
|
||||
// Parameter validation and basic data preparation
|
||||
// ========================================
|
||||
@@ -153,7 +153,7 @@ impl InstructionBuilder for RaydiumCpmmInstructionBuilder {
|
||||
Ok(instructions)
|
||||
}
|
||||
|
||||
async fn build_sell_instructions(&self, params: &SellParams) -> Result<Vec<Instruction>> {
|
||||
async fn build_sell_instructions(&self, params: &InternalSellParams) -> Result<Vec<Instruction>> {
|
||||
// ========================================
|
||||
// Parameter validation and basic data preparation
|
||||
// ========================================
|
||||
|
||||
Reference in New Issue
Block a user