-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add decimal fuzzing through manual randomness
- Loading branch information
Showing
5 changed files
with
60 additions
and
10 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
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,32 @@ | ||
use std::sync::{Mutex, OnceLock}; | ||
|
||
pub struct AmmParameters { | ||
token_x_decimals: u8, | ||
token_y_decimals: u8, | ||
} | ||
|
||
pub static GLOBAL_COUNTER: OnceLock<Mutex<AmmParameters>> = OnceLock::new(); | ||
|
||
pub fn get_token_x_decimals() -> u8 | ||
{ | ||
let amm_params = GLOBAL_COUNTER.get_or_init(|| Mutex::new(AmmParameters { token_x_decimals: 6, token_y_decimals: 6 })); // Initialize if not already set | ||
let decimals = amm_params.lock().unwrap(); | ||
|
||
return decimals.token_x_decimals; | ||
} | ||
|
||
pub fn get_token_y_decimals() -> u8 | ||
{ | ||
let amm_params = GLOBAL_COUNTER.get_or_init(|| Mutex::new(AmmParameters { token_x_decimals: 6, token_y_decimals: 6 })); // Initialize if not already set | ||
let decimals = amm_params.lock().unwrap(); | ||
|
||
return decimals.token_y_decimals; | ||
} | ||
|
||
pub fn set_token_decimals(x: u8, y: u8) { | ||
let amm_params = GLOBAL_COUNTER.get_or_init(|| Mutex::new(AmmParameters { token_x_decimals: 6, token_y_decimals: 6 })); // Initialize if not already set | ||
let mut decimals = amm_params.lock().unwrap(); | ||
|
||
decimals.token_x_decimals = x; | ||
decimals.token_y_decimals = y; | ||
} |