Skip to content
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

Add permissioned markets #46

Merged
merged 5 commits into from
May 26, 2023
Merged

Add permissioned markets #46

merged 5 commits into from
May 26, 2023

Conversation

metaproph3t
Copy link
Collaborator

@metaproph3t metaproph3t force-pushed the feature/permissioned-markets branch 4 times, most recently from 79264a1 to 232da79 Compare May 24, 2023 08:46
For [permissioned
markets](#33), we need
to store the `Pubkey`s of market authorities. Assuming that we do not
want to require *all* markets to be permissioned, we will need to store
both (1) whether or not this market has an authority and (2) the
authority, if any.

Traditionally, this would be done in an `Option<Pubkey>`, but we use
[zero copy
deserialization](https://docs.rs/anchor-lang/latest/anchor_lang/prelude/attr.zero_copy.html),
which requires all types to implement `bytemuck::Pod`. `std::option::Option<T>` does not implement `Pod`, and because of the way enum bit patterns work in Rust, it cannot. So we need to add a custom option implementation that *does* implement `Pod`.
Store the various admins, such as `fee_collector`, `close_authority`,
etc. inside the `Market` struct.
If an `open_orders_admin` is set inside a `Market`, require all orders
submitted to that market to have the signature of the
`open_orders_admin`.
Add an optional `consume_events_admin` to the market struct that, if
present, must sign off on any consume event instruction.
@metaproph3t metaproph3t force-pushed the feature/permissioned-markets branch 4 times, most recently from 2824ff8 to 487dc51 Compare May 25, 2023 12:54
@metaproph3t metaproph3t force-pushed the feature/permissioned-markets branch 2 times, most recently from b994ad8 to 2649484 Compare May 25, 2023 19:34
@metaproph3t metaproph3t marked this pull request as ready for review May 25, 2023 19:45
Copy link
Contributor

@binyebarwe binyebarwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me. Some users recommended us to have the admin as the seed of the Market. This PR removes it, but we could add instead the sweep admin?

/// Admin who can collect fees from the market
pub collect_fee_admin: Pubkey,
/// Admin who can manage the oracle
pub manage_oracle_admin: PodOption<Pubkey>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This admin would be able to manage the oracle, which currently just means setting the stub oracle. I included it in case there was a use for it later (e.g., a change oracle instruction), but on second thought it seems that it should be removed from this PR and included later only if there's a defined use for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

@metaproph3t
Copy link
Collaborator Author

It looks good to me. Some users recommended us to have the admin as the seed of the Market. This PR removes it, but we could add instead the sweep admin?

Certainly, I will fix this, sir.

@metaproph3t metaproph3t force-pushed the feature/permissioned-markets branch 2 times, most recently from f799a5a to e0e1ecc Compare May 26, 2023 07:20
Copy link
Contributor

@binyebarwe binyebarwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, thanks a lot!!

@binyebarwe binyebarwe merged commit 6395de8 into master May 26, 2023
@binyebarwe binyebarwe deleted the feature/permissioned-markets branch May 26, 2023 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants