From 98914932781fcdf307f5ec0289e88b3cd7dbfce1 Mon Sep 17 00:00:00 2001 From: drunest Date: Mon, 28 Mar 2022 09:37:09 +0800 Subject: [PATCH] rename exchanger --- Cargo.lock | 2 +- .../aldrin/instruction.rs | 0 .../src/{swappers => exchanger}/aldrin/mod.rs | 0 .../crema/instruction.rs | 0 .../src/{swappers => exchanger}/crema/mod.rs | 0 .../cropper/instruction.rs | 0 .../{swappers => exchanger}/cropper/mod.rs | 0 .../src/{swappers => exchanger}/mod.rs | 0 .../raydium/instruction.rs | 0 .../{swappers => exchanger}/raydium/mod.rs | 0 .../serum_dex/instruction.rs | 0 .../serum_dex/matching.rs | 0 .../{swappers => exchanger}/serum_dex/mod.rs | 0 .../serum_dex/order.rs | 0 .../serum_dex/state.rs | 0 .../spl_token_swap/instruction.rs | 0 .../spl_token_swap/mod.rs | 0 .../stable_swap/instruction.rs | 0 .../stable_swap/mod.rs | 0 src/program-rust/src/lib.rs | 2 +- src/program-rust/src/parser/aldrin.rs | 2 +- src/program-rust/src/parser/serum_dex.rs | 2 +- src/program-rust/src/processor.rs | 31 +++++++++---------- 23 files changed, 18 insertions(+), 21 deletions(-) rename src/program-rust/src/{swappers => exchanger}/aldrin/instruction.rs (100%) rename src/program-rust/src/{swappers => exchanger}/aldrin/mod.rs (100%) rename src/program-rust/src/{swappers => exchanger}/crema/instruction.rs (100%) rename src/program-rust/src/{swappers => exchanger}/crema/mod.rs (100%) rename src/program-rust/src/{swappers => exchanger}/cropper/instruction.rs (100%) rename src/program-rust/src/{swappers => exchanger}/cropper/mod.rs (100%) rename src/program-rust/src/{swappers => exchanger}/mod.rs (100%) rename src/program-rust/src/{swappers => exchanger}/raydium/instruction.rs (100%) rename src/program-rust/src/{swappers => exchanger}/raydium/mod.rs (100%) rename src/program-rust/src/{swappers => exchanger}/serum_dex/instruction.rs (100%) rename src/program-rust/src/{swappers => exchanger}/serum_dex/matching.rs (100%) rename src/program-rust/src/{swappers => exchanger}/serum_dex/mod.rs (100%) rename src/program-rust/src/{swappers => exchanger}/serum_dex/order.rs (100%) rename src/program-rust/src/{swappers => exchanger}/serum_dex/state.rs (100%) rename src/program-rust/src/{swappers => exchanger}/spl_token_swap/instruction.rs (100%) rename src/program-rust/src/{swappers => exchanger}/spl_token_swap/mod.rs (100%) rename src/program-rust/src/{swappers => exchanger}/stable_swap/instruction.rs (100%) rename src/program-rust/src/{swappers => exchanger}/stable_swap/mod.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index fbe9beb..71f3a77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1099,7 +1099,7 @@ checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" [[package]] name = "onesol-protocol" -version = "0.4.1" +version = "0.4.2" dependencies = [ "arrayref", "bs58 0.3.1", diff --git a/src/program-rust/src/swappers/aldrin/instruction.rs b/src/program-rust/src/exchanger/aldrin/instruction.rs similarity index 100% rename from src/program-rust/src/swappers/aldrin/instruction.rs rename to src/program-rust/src/exchanger/aldrin/instruction.rs diff --git a/src/program-rust/src/swappers/aldrin/mod.rs b/src/program-rust/src/exchanger/aldrin/mod.rs similarity index 100% rename from src/program-rust/src/swappers/aldrin/mod.rs rename to src/program-rust/src/exchanger/aldrin/mod.rs diff --git a/src/program-rust/src/swappers/crema/instruction.rs b/src/program-rust/src/exchanger/crema/instruction.rs similarity index 100% rename from src/program-rust/src/swappers/crema/instruction.rs rename to src/program-rust/src/exchanger/crema/instruction.rs diff --git a/src/program-rust/src/swappers/crema/mod.rs b/src/program-rust/src/exchanger/crema/mod.rs similarity index 100% rename from src/program-rust/src/swappers/crema/mod.rs rename to src/program-rust/src/exchanger/crema/mod.rs diff --git a/src/program-rust/src/swappers/cropper/instruction.rs b/src/program-rust/src/exchanger/cropper/instruction.rs similarity index 100% rename from src/program-rust/src/swappers/cropper/instruction.rs rename to src/program-rust/src/exchanger/cropper/instruction.rs diff --git a/src/program-rust/src/swappers/cropper/mod.rs b/src/program-rust/src/exchanger/cropper/mod.rs similarity index 100% rename from src/program-rust/src/swappers/cropper/mod.rs rename to src/program-rust/src/exchanger/cropper/mod.rs diff --git a/src/program-rust/src/swappers/mod.rs b/src/program-rust/src/exchanger/mod.rs similarity index 100% rename from src/program-rust/src/swappers/mod.rs rename to src/program-rust/src/exchanger/mod.rs diff --git a/src/program-rust/src/swappers/raydium/instruction.rs b/src/program-rust/src/exchanger/raydium/instruction.rs similarity index 100% rename from src/program-rust/src/swappers/raydium/instruction.rs rename to src/program-rust/src/exchanger/raydium/instruction.rs diff --git a/src/program-rust/src/swappers/raydium/mod.rs b/src/program-rust/src/exchanger/raydium/mod.rs similarity index 100% rename from src/program-rust/src/swappers/raydium/mod.rs rename to src/program-rust/src/exchanger/raydium/mod.rs diff --git a/src/program-rust/src/swappers/serum_dex/instruction.rs b/src/program-rust/src/exchanger/serum_dex/instruction.rs similarity index 100% rename from src/program-rust/src/swappers/serum_dex/instruction.rs rename to src/program-rust/src/exchanger/serum_dex/instruction.rs diff --git a/src/program-rust/src/swappers/serum_dex/matching.rs b/src/program-rust/src/exchanger/serum_dex/matching.rs similarity index 100% rename from src/program-rust/src/swappers/serum_dex/matching.rs rename to src/program-rust/src/exchanger/serum_dex/matching.rs diff --git a/src/program-rust/src/swappers/serum_dex/mod.rs b/src/program-rust/src/exchanger/serum_dex/mod.rs similarity index 100% rename from src/program-rust/src/swappers/serum_dex/mod.rs rename to src/program-rust/src/exchanger/serum_dex/mod.rs diff --git a/src/program-rust/src/swappers/serum_dex/order.rs b/src/program-rust/src/exchanger/serum_dex/order.rs similarity index 100% rename from src/program-rust/src/swappers/serum_dex/order.rs rename to src/program-rust/src/exchanger/serum_dex/order.rs diff --git a/src/program-rust/src/swappers/serum_dex/state.rs b/src/program-rust/src/exchanger/serum_dex/state.rs similarity index 100% rename from src/program-rust/src/swappers/serum_dex/state.rs rename to src/program-rust/src/exchanger/serum_dex/state.rs diff --git a/src/program-rust/src/swappers/spl_token_swap/instruction.rs b/src/program-rust/src/exchanger/spl_token_swap/instruction.rs similarity index 100% rename from src/program-rust/src/swappers/spl_token_swap/instruction.rs rename to src/program-rust/src/exchanger/spl_token_swap/instruction.rs diff --git a/src/program-rust/src/swappers/spl_token_swap/mod.rs b/src/program-rust/src/exchanger/spl_token_swap/mod.rs similarity index 100% rename from src/program-rust/src/swappers/spl_token_swap/mod.rs rename to src/program-rust/src/exchanger/spl_token_swap/mod.rs diff --git a/src/program-rust/src/swappers/stable_swap/instruction.rs b/src/program-rust/src/exchanger/stable_swap/instruction.rs similarity index 100% rename from src/program-rust/src/swappers/stable_swap/instruction.rs rename to src/program-rust/src/exchanger/stable_swap/instruction.rs diff --git a/src/program-rust/src/swappers/stable_swap/mod.rs b/src/program-rust/src/exchanger/stable_swap/mod.rs similarity index 100% rename from src/program-rust/src/swappers/stable_swap/mod.rs rename to src/program-rust/src/exchanger/stable_swap/mod.rs diff --git a/src/program-rust/src/lib.rs b/src/program-rust/src/lib.rs index 096032a..877bac6 100644 --- a/src/program-rust/src/lib.rs +++ b/src/program-rust/src/lib.rs @@ -2,12 +2,12 @@ mod constraints; pub mod error; +mod exchanger; pub mod instruction; mod parser; pub mod processor; mod spl_token; pub mod state; -mod swappers; #[cfg(not(feature = "no-entrypoint"))] mod entrypoint; diff --git a/src/program-rust/src/parser/aldrin.rs b/src/program-rust/src/parser/aldrin.rs index 49e5ae3..258096f 100644 --- a/src/program-rust/src/parser/aldrin.rs +++ b/src/program-rust/src/parser/aldrin.rs @@ -2,7 +2,7 @@ use super::base::{validate_authority_pubkey, TokenAccount, TokenMint}; use crate::{ declare_validated_account_wrapper, error::{ProtocolError, ProtocolResult}, - swappers::aldrin::instruction::Side, + exchanger::aldrin::instruction::Side, }; use arrayref::array_ref; use solana_program::{account_info::AccountInfo, msg, pubkey::Pubkey}; diff --git a/src/program-rust/src/parser/serum_dex.rs b/src/program-rust/src/parser/serum_dex.rs index 8eddcb0..aab7950 100644 --- a/src/program-rust/src/parser/serum_dex.rs +++ b/src/program-rust/src/parser/serum_dex.rs @@ -1,7 +1,7 @@ -use crate::swappers::serum_dex::matching::Side as DexSide; use crate::{ declare_validated_account_wrapper, error::{ProtocolError, ProtocolResult}, + exchanger::serum_dex::matching::Side as DexSide, parser::base::TokenAccount, }; use arrayref::{array_ref, array_refs}; diff --git a/src/program-rust/src/processor.rs b/src/program-rust/src/processor.rs index cef280a..3001526 100644 --- a/src/program-rust/src/processor.rs +++ b/src/program-rust/src/processor.rs @@ -2,36 +2,32 @@ use std::cmp; -use crate::constraints::OWNER_KEY; -use crate::instruction::SwapOutSlimInstruction; -use crate::parser::aldrin::AldrinPoolArgs; -use crate::parser::crema::CremaSwapV1Args; -use crate::parser::cropper::CropperArgs; -use crate::spl_token; -use crate::state::Status; -use crate::swappers::{aldrin, crema, cropper, stable_swap}; use crate::{ + constraints::OWNER_KEY, error::ProtocolError, + exchanger::{ + aldrin, crema, cropper, raydium, + serum_dex::{self, matching::Side as DexSide}, + spl_token_swap, stable_swap, + }, instruction::{ ExchangerType, ProtocolInstruction, SwapInInstruction, SwapInstruction, SwapOutInstruction, + SwapOutSlimInstruction, }, parser::{ + aldrin::AldrinPoolArgs, base::{SplTokenProgram, SwapInfoArgs, TokenAccount, UserArgs}, + crema::CremaSwapV1Args, + cropper::CropperArgs, raydium::{RaydiumSwapArgs, RaydiumSwapArgs2}, serum_dex::SerumDexArgs, spl_token_swap::SplTokenSwapArgs, stable_swap::StableSwapArgs, }, - state::SwapInfo, - swappers::{ - raydium, - serum_dex::{self, matching::Side as DexSide}, - spl_token_swap, - }, + spl_token, + state::{Status, SwapInfo}, }; use arrayref::array_refs; -use solana_program::program_memory::{sol_memcmp, sol_memset}; -use solana_program::pubkey::PUBKEY_BYTES; use solana_program::{ account_info::AccountInfo, entrypoint::ProgramResult, @@ -39,9 +35,10 @@ use solana_program::{ msg, program::{invoke, invoke_signed}, program_error::ProgramError, + program_memory::{sol_memcmp, sol_memset}, program_option::COption, program_pack::Pack, - pubkey::Pubkey, + pubkey::{Pubkey, PUBKEY_BYTES}, rent::Rent, sysvar::Sysvar, };