-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 159 add position caps #174
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8f41dff
Pool: added max position management
markuspluna 71d980d
Pool: added new_admin auth requirement for admin swaps
markuspluna eea02dc
Pool: position cap refactor
markuspluna f37f382
pool: chore: move max positions check logic to once per request process
mootz12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -94,6 +94,7 @@ pub struct UserEmissionData { | |
/********** Storage Key Types **********/ | ||
|
||
const ADMIN_KEY: &str = "Admin"; | ||
const MAX_POSITIONS_KEY: &str = "MaxPos"; | ||
const NAME_KEY: &str = "Name"; | ||
const BACKSTOP_KEY: &str = "Backstop"; | ||
const BLND_TOKEN_KEY: &str = "BLNDTkn"; | ||
|
@@ -227,6 +228,26 @@ pub fn has_admin(e: &Env) -> bool { | |
e.storage().instance().has(&Symbol::new(e, ADMIN_KEY)) | ||
} | ||
|
||
/*********** Max Positions ***********/ | ||
// Fetch the current max posoitions | ||
/// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix comment |
||
pub fn get_max_positions(e: &Env) -> u32 { | ||
e.storage() | ||
.instance() | ||
.get(&Symbol::new(e, MAX_POSITIONS_KEY)) | ||
.unwrap_or(0) | ||
} | ||
|
||
/// Set a new admin | ||
/// | ||
/// ### Arguments | ||
/// * `max_positions` - The max positions for the pool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix comment |
||
pub fn set_max_positions(e: &Env, max_positions: &u32) { | ||
e.storage() | ||
.instance() | ||
.set::<Symbol, u32>(&Symbol::new(e, MAX_POSITIONS_KEY), max_positions); | ||
} | ||
|
||
/********** Metadata **********/ | ||
|
||
/// Set a pool name | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should likely be included with
pool_init_meta
, right? Like backstopTakeRate, it feels like a vital piece of setup required for the pool to function and should be set on initialization.In the same vein, it feels appropriate to include this with
update_pool
or rename that function toset_backstop_rate
to avoid confusion.Having one function that sets multiple pieces of pool configuration doesn't seem problematic to me, but I don't have a strong opinion either way.