-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: fix rust swap quote and test after switch to dlmm interface
- Loading branch information
1 parent
7b0a112
commit 0b1570c
Showing
29 changed files
with
1,561 additions
and
316 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,16 +10,17 @@ authors = ["tian <[email protected]>"] | |
[dependencies] | ||
anchor-client = { workspace = true, features = ["async"] } | ||
anyhow = { workspace = true } | ||
lb_clmm = { path = "../programs/lb_clmm", features = ["cpi"] } | ||
dlmm_interface = { path = "../dlmm_interface" } | ||
tokio = { workspace = true, features = ["full", "parking_lot"] } | ||
bincode = "1.3.3" | ||
bincode = { workspace = true } | ||
solana-sdk = { workspace = true } | ||
ruint = { workspace = true } | ||
num-traits = { workspace = true } | ||
num-integer = { workspace = true } | ||
|
||
[dev-dependencies] | ||
anchor-lang = { workspace = true } | ||
anchor-spl = { workspace = true } | ||
spl-associated-token-account = { workspace = true } | ||
solana-program-test = "1.16.0" | ||
solana-sdk = "1.16.0" | ||
async-trait = "0.1.52" | ||
assert_matches = "1.5.0" | ||
spl-associated-token-account = { workspace = true } | ||
solana-program = "1.16.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
pub const BASIS_POINT_MAX: i32 = 10000; | ||
|
||
/// Maximum number of bin a bin array able to contains. | ||
pub const MAX_BIN_PER_ARRAY: usize = 70; | ||
|
||
/// Default number of bin per position contains. | ||
pub const DEFAULT_BIN_PER_POSITION: usize = 70; | ||
|
||
/// Max resize length allowed | ||
pub const MAX_RESIZE_LENGTH: usize = 70; | ||
|
||
/// Maximum number of bin per position contains. | ||
pub const POSITION_MAX_LENGTH: usize = 1400; | ||
|
||
/// Minimum bin ID supported. Computed based on 1 bps. | ||
pub const MIN_BIN_ID: i32 = -443636; | ||
|
||
/// Maximum bin ID supported. Computed based on 1 bps. | ||
pub const MAX_BIN_ID: i32 = 443636; | ||
|
||
/// Maximum fee rate. 10% | ||
pub const MAX_FEE_RATE: u64 = 100_000_000; | ||
|
||
pub const FEE_PRECISION: u64 = 1_000_000_000; | ||
|
||
/// Maximum protocol share of the fee. 25% | ||
pub const MAX_PROTOCOL_SHARE: u16 = 2_500; | ||
|
||
/// Host fee. 20% | ||
pub const HOST_FEE_BPS: u16 = 2_000; | ||
|
||
// Number of rewards supported by pool | ||
pub const NUM_REWARDS: usize = 2; | ||
|
||
// Minimum reward duration | ||
pub const MIN_REWARD_DURATION: u64 = 1; | ||
|
||
pub const MAX_REWARD_DURATION: u64 = 31536000; // 1 year = 365 * 24 * 3600 | ||
|
||
pub const DEFAULT_OBSERVATION_LENGTH: u64 = 100; | ||
|
||
pub const SAMPLE_LIFETIME: u64 = 120; // 2 | ||
|
||
pub const EXTENSION_BINARRAY_BITMAP_SIZE: usize = 12; | ||
|
||
pub const BIN_ARRAY_BITMAP_SIZE: i32 = 512; | ||
|
||
pub const MAX_BASE_FACTOR_STEP: u16 = 100; // 100 bps, 1% | ||
|
||
pub const MAX_FEE_UPDATE_WINDOW: i64 = 0; | ||
|
||
pub const MAX_REWARD_BIN_SPLIT: usize = 15; | ||
|
||
pub const SLOT_BUFFER: u64 = 9000; | ||
|
||
pub const TIME_BUFFER: u64 = 3600; | ||
|
||
pub const MAX_ACTIVATION_SLOT_DURATION: u64 = SLOT_BUFFER * 24 * 31; // 31 days | ||
|
||
pub const MAX_ACTIVATION_TIME_DURATION: u64 = TIME_BUFFER * 24 * 31; // 31 days | ||
|
||
pub const FIVE_MINUTES_SLOT_BUFFER: u64 = SLOT_BUFFER / 12; // 5 minutes | ||
|
||
pub const FIVE_MINUTES_TIME_BUFFER: u64 = TIME_BUFFER / 12; // 5 minutes | ||
|
||
// ILM token launch protocol fee | ||
pub const ILM_PROTOCOL_SHARE: u16 = 2000; // 20% | ||
|
||
/// Maximum bin step | ||
pub const MAX_BIN_STEP: u16 = 400; | ||
|
||
/// Maximum base fee, base_fee / 10^9 = fee_in_percentage | ||
pub const MAX_BASE_FEE: u128 = 100_000_000; // 10% (10^9 * 10 / 100) | ||
|
||
/// Minimum base fee | ||
pub const MIN_BASE_FEE: u128 = 100_000; // 0.01% (10^9 * 0.01 / 100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use dlmm_interface::ActivationType; | ||
use std::ops::Deref; | ||
|
||
pub struct ActivationTypeWrapper(ActivationType); | ||
|
||
impl Deref for ActivationTypeWrapper { | ||
type Target = ActivationType; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl TryFrom<u8> for ActivationTypeWrapper { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(value: u8) -> Result<Self, Self::Error> { | ||
match value { | ||
0 => Ok(ActivationTypeWrapper(ActivationType::Slot)), | ||
1 => Ok(ActivationTypeWrapper(ActivationType::Timestamp)), | ||
_ => Err(anyhow::anyhow!("Invalid ActivationType value: {}", value)), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
pub mod status; | ||
pub use status::*; | ||
|
||
pub mod pair_type; | ||
pub use pair_type::*; | ||
|
||
pub mod activation_type; | ||
pub use activation_type::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use dlmm_interface::PairType; | ||
use std::ops::Deref; | ||
|
||
pub struct PairTypeWrapper(PairType); | ||
|
||
impl Deref for PairTypeWrapper { | ||
type Target = PairType; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl TryFrom<u8> for PairTypeWrapper { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(value: u8) -> Result<Self, Self::Error> { | ||
match value { | ||
0 => Ok(PairTypeWrapper(PairType::Permissionless)), | ||
1 => Ok(PairTypeWrapper(PairType::Permission)), | ||
2 => Ok(PairTypeWrapper(PairType::CustomizablePermissionless)), | ||
_ => Err(anyhow::anyhow!("Invalid PairType value: {}", value)), | ||
} | ||
} | ||
} |
Oops, something went wrong.