Permissioned markets#150
Closed
armaniferrante wants to merge 5 commits into
Closed
Conversation
armaniferrante
commented
Jul 19, 2021
| fee_tier, | ||
| } = args; | ||
|
|
||
| let open_orders_mut = open_orders.deref_mut(); |
Contributor
Author
There was a problem hiding this comment.
This change is required so that an open orders PDA can be the authority of itself. On CPI, solana_program::program::invoke will try to borrow the refcell, and so this borrow must be dropped prior to CPI.
39963a9 to
7485b53
Compare
7485b53 to
814c1fd
Compare
0eb42a1 to
22cb5cb
Compare
22cb5cb to
fdd0789
Compare
armaniferrante
commented
Jul 22, 2021
| pub struct MarketStateV2 { | ||
| pub inner: MarketState, | ||
| pub authority: Pubkey, | ||
| pub prune_authority: Pubkey, |
Contributor
Author
There was a problem hiding this comment.
Maybe we should add padding so that we can add additional fields in the future.
Contributor
Author
|
I've broken this PR into three components that can be reviewed separately.
|
This was referenced Jul 26, 2021
Contributor
Author
|
Closing. See the description above for subsequent changes. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Changes that provide the ability to host "permissioned markets" on the orderbook.
A permissioned market is a regular Serum market with an additional
authority, which must sign every transaction to create an open orders account. In practice, what this means is that one can create a program that acts as this authority and that marks its own PDAs as the owner of all created open orders accounts, making the program the sole arbiter over who can trade on a given market and what trades can be made.An example can be found here, where all trades that execute on the markets authorized by the program are required to both provide an identity token and set the referral to a hard coded address.
Accounts
Adds an
authorityandprune_authorityfield to theMarketState. To do this in a way that is not breaking, this PRMarketStateV2account layout that adds the new fields.Marketenum that acts as a a unified interface for accessing the different market state versions.Instructions
Pruneinstruction that removes all orders from the order book. This instruction must be authorized by the prune authority (optional).InitializeMarketandInitOpenOrdersinstructions, where an optional account--the market authority and prune authority (forInitailizeMarket)--is_ added to each instruction.Related Changes
Individual PRs.
For easier review, I've broken these changes into three PRs.
Breaking Changes
Although the program can be upgraded in a way such that existing accounts and composing programs on-chain will not break, there are some breaking changes made to the
serum_dexcrate.MarketState::loadmethod is removed. Programs and clients should switch to usingMarket::load.instruction::init_open_ordershas a newOption<&Pubkey>parameter added for the market authority.instruction::initialize_markethas a newOption<&Pubkey>parameter added for the market authority.