pub fn new_order(
    program: &Program,
    retail_account_owner: Pubkey,
    retail_data_account_nonce: u64,
    auction_id: u64,
    auction_epoch: u64,
    previous_auction_epoch: u64,
    signatory_server: Pubkey,
    retail_encryption_pub_key: [u8; 32],
    mm_encryption_pub_key: [u8; 32],
    encrypted_order_details: String,
    retail_signing_pub_key: [u8; 32],
    retail_signature: [u8; 64],
    deposit_amount: u64,
    order_type: u8,
    retail_x_token_account: Pubkey,
    rebate_receiver_token_account: Pubkey,
    retail_data_account: Pubkey,
    market_maker_data_account: Pubkey,
    x_mint: Pubkey,
    price_oracles: Vec<Pubkey>
) -> Instruction
Expand description

This instruction is called by retail traders when they submit their order. A transaction containing this instruction must be signed by a signatory server.

When submitting orders, retail traders must encrypt the details of their order in order to hide information regarding which token is being received.

Arguments

  • retail_account_owner The public key of the retail_account_owner account.
  • retail_data_account_nonce The unsigned integer field named nonce in the retail_data_account account. The nonce in the retail trader’s account used to generate a PDA for the vault token account. This nonce must be saved and used when referencing this order in the future.
  • auction_id An unsigned 64 bit integer. The auction ID used as a seed to generate the program derived address
  • auction_epoch An unsigned 64 bit integer. The integer epoch used to generate the PDA of the auction epoch account
  • previous_auction_epoch An unsigned 64 bit integer. The previous epoch. This must be equal to auction_epoch - 1.
  • signatory_server The public key of the signatory_server account.
  • retail_encryption_pub_key The retail trader’s X25519 public key.
  • mm_encryption_pub_key The market maker’s X25519 public key.
  • encrypted_order_details The ciphertext of the order details, encrypted using a 24-byte nonce of zeros and the key derived from the market maker’s X25519 public key and the retail trader’s X25519 private key.
  • retail_signing_pub_key The public key of the Ed25519 key pair that the retail trader used to generate the signature.
  • retail_signature The signature of the plaintext order details.
  • deposit_amount The amount of tokens being sent by the retail trader in the trade.
  • order_type The order type, must be either 0 for limit or 1 for market. All other values result in a failed transaction.
  • retail_x_token_account The SPL token account associated with the retail trader which is used to deposit the sold token into escrow prior to the trade occurring. This account is expected to be mutable
  • rebate_receiver_token_account The SPL token account associated with the order used to receive a payment from the network, with the same mint as the token accounts used by market makers to bid in the associated auction.
  • retail_data_account The retail data account holds state specific to the retail trader. This account is expected to be mutable
  • market_maker_data_account The account storing state specific to the market maker. This account must be owned by the DFlow program, and this account must be initialized by calling the initialize market maker instruction. This account is expected to be mutable
  • x_mint The SPL mint account associated with the token that is sold by the retail trader during the swap.
  • price_oracles These price oracles are the Pyth price accounts associated with the products that could possibly be received by the retail trader based on which token they are selling. For example, if a retail trader is swapping X for some other token, then the price oracles that must be passed here are all price oracles which exist as a pair with X in this auction.

Returns an instruction