1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
use anchor_lang::prelude::*;
use crate::state::*;
use crate::util::ID;
use crate::instructions::*;
#[allow(unused_variables)]
#[program]
mod aprogram {
use super::*;
/// This instruction creates the global config account and sets the
/// DFlow admin.
///
/// The DFlow admin controls access to the protocol by granting roles
/// to accounts that allow them to perform privileged actions such
/// as auction management. This instruction must be the first instruction
/// called after program deployment and can only be called once.
pub fn init_global_config_instruction(
ctx: Context<InitGlobalConfigInstruction>,
// Bumps
global_config_account_bump: u8,
) -> Result<()> {
Ok(())
}
/// This instruction updates the DFlow admin.
///
/// The current DFlow admin can use this instruction to assign a
/// new DFlow admin.
pub fn set_new_dflow_admin(
ctx: Context<SetNewDflowAdmin>,
// Bumps
global_config_account_bump: u8,
) -> Result<()> {
Ok(())
}
/// This instruction creates the principal's whitelist entry account
/// and grants the specified role to the principal.
pub fn grant_role_uninitialized_entry(
ctx: Context<GrantRoleUninitializedEntry>,
// Bumps
global_config_account_bump: u8,
whitelist_entry_bump: u8,
// Function Arguments
role: u8,
) -> Result<()> {
Ok(())
}
/// This instruction grants the specified role to the principal.
pub fn grant_role(
ctx: Context<GrantRole>,
// Bumps
global_config_account_bump: u8,
whitelist_entry_bump: u8,
// Function Arguments
role: u8,
) -> Result<()> {
Ok(())
}
/// This instruction revokes the specified role from the principal
/// and closes the principal's whitelist account if it no longer
/// grants any permissions.
pub fn revoke_role(
ctx: Context<RevokeRole>,
// Bumps
global_config_account_bump: u8,
whitelist_entry_bump: u8,
// Function Arguments
role: u8,
) -> Result<()> {
Ok(())
}
/// This instruction creates a recovery vault.
///
/// Recovery vaults are required for all mints used in the protocol.
/// If a transfer recipient does not have a token account set up,
/// the transferor can direct the protocol to transfer the tokens
/// to the recovery vault. The intended recipient can then recover
/// the tokens by submitting a recovery claim.
pub fn init_recovery_vault_instruction(
ctx: Context<InitRecoveryVaultInstruction>,
// Bumps
recovery_state_account_bump: u8,
recovery_vault_account_bump: u8,
auction_owner_whitelist_entry_bump: u8,
) -> Result<()> {
Ok(())
}
/// This instruction initializes the auction mapper account.
///
/// The auction mapper account contains a list of auctions that are
/// not deprecated. Auctions will either be in a trading or halted
/// state. This function can only be called by the DFlow admin.
pub fn init_auction_mapper_instruction(
ctx: Context<InitAuctionMapperInstruction>,
// Bumps
global_config_account_bump: u8,
auction_mapper_bump: u8,
) -> Result<()> {
Ok(())
}
/// This instruction initializes an auction for order flow, and describes
/// the specifications of the order flow account.
///
/// This instruction is only callable by an auction owner. Once the
/// auction is initialized, it remains in a Halted state until the
/// auction owner sets the auction state to Trading.
pub fn init_auction_state(
ctx: Context<InitAuctionState>,
// Bumps
auction_state_account_bump: u8,
bid_vault_account_bump: u8,
vote_vault_account_bump: u8,
auction_mapper_bump: u8,
auction_owner_whitelist_entry_bump: u8,
bid_recovery_state_account_bump: u8,
bid_recovery_vault_account_bump: u8,
vote_recovery_state_account_bump: u8,
vote_recovery_vault_account_bump: u8,
// Seed Dependencies
auction_id: u64,
// Function Arguments
min_notional_order_size: u64,
max_notional_order_size: u64,
notional_decimals: u8,
batch_notional_size: u64,
vote_size: u64,
supported_pairs_count: u8,
vote_period: u32,
claim_period: u32,
) -> Result<()> {
Ok(())
}
/// This instruction adds a currency pair to an existing auction.
///
/// Only a certain number of token pairs are allowed to exist in
/// an auction and an error is thrown if this instruction is called
/// when the token pairs count is saturated
pub fn add_currency_pair(
ctx: Context<AddCurrencyPair>,
// Bumps
auction_state_account_bump: u8,
base_recovery_state_account_bump: u8,
base_recovery_vault_account_bump: u8,
quote_recovery_state_account_bump: u8,
quote_recovery_vault_account_bump: u8,
auction_owner_whitelist_entry_bump: u8,
// Seed Dependencies
auction_id: u64,
) -> Result<()> {
Ok(())
}
/// This instruction changes the status of an auction
///
/// This instruction can be used to change the status of an auction
/// between Halted, Trading, or Expired. Once Expired, the auction
/// will not be revivable.
pub fn change_auction_status(
ctx: Context<ChangeAuctionStatus>,
// Bumps
auction_state_account_bump: u8,
auction_mapper_bump: u8,
auction_owner_whitelist_entry_bump: u8,
// Seed Dependencies
auction_id: u64,
// Function Arguments
new_status: u8,
) -> Result<()> {
Ok(())
}
/// This instruction initializes the market maker account
///
/// The market maker account tracks state specific to the market
/// maker's market making activities. This instruction must be called
/// prior to a market maker being active on DFlow.
pub fn init_market_maker_account_instruction(
ctx: Context<InitMarketMakerAccountInstruction>,
// Bumps
market_maker_whitelist_entry_bump: u8,
// Function Arguments
max_orders_supported: u64,
encryption_pub_key: [u8; 32],
) -> Result<()> {
Ok(())
}
/// This instruction updates the market maker's 256-bit X25519 public
/// key.
///
/// Retail traders use the market maker's 256-bit X25519 public key
/// to encrypt their order details when routing orders to the market
/// maker. This instruction updates the market maker's X25519 public
/// key.
pub fn update_encryption_key_instruction(
ctx: Context<UpdateEncryptionKeyInstruction>,
// Bumps
market_maker_whitelist_entry_bump: u8,
// Function Arguments
encryption_pub_key: [u8; 32],
) -> Result<()> {
Ok(())
}
/// This instruction initializes an auction epoch state account
///
/// AuctionEpochState carries state specific to a certain auction
/// that needs to be remembered after the epoch ends. The AuctionEpochState
/// accounts associated with auction epochs N and N + 1 need to be
/// initialized when the auction for epoch N begins (i.e. in the
/// first SubmitAuctionBid that auction N will receive). Recall that
/// if the AuctionState has an epoch field that has value X, then
/// auction X is currently active, and auction X - 1 is currently
/// receiving order flow.
pub fn init_auction_epoch_state_instruction(
ctx: Context<InitAuctionEpochStateInstruction>,
// Bumps
auction_epoch_state_bump: u8,
auction_state_account_bump: u8,
// Seed Dependencies
auction_id: u64,
auction_epoch: u64,
) -> Result<()> {
Ok(())
}
/// This instruction initializes the retail traders account.
///
/// The retail data account tracks state specific to the retail trader's
/// trading activities on DFlow.
pub fn init_retail_data_account_instruction(
ctx: Context<InitRetailDataAccountInstruction>,
// Function Arguments
max_orders_supported: u64,
) -> Result<()> {
Ok(())
}
/// This instruction closes the retail trader's data account.
///
/// When retail traders wish to close their account, and regain the
/// lamports used to allocate the space for their data account, they
/// can call this instruction. Retail traders may not close their
/// account if they have open orders, and must wait for the orders
/// to be filled, or cancel them.
pub fn close_retail_data_account(
ctx: Context<CloseRetailDataAccount>,
) -> Result<()> {
Ok(())
}
/// This instruction is called by the market maker prior to bidding
/// in an auction.
///
/// Before a market maker bids in an auction, they must use this
/// instruction to initialize an account to track their current bid
/// in the auction.
pub fn init_bid_record_account(
ctx: Context<InitBidRecordAccount>,
// Bumps
auction_state_account_bump: u8,
auction_epoch_state_bump: u8,
bid_record_account_bump: u8,
market_maker_whitelist_entry_bump: u8,
// Seed Dependencies
auction_id: u64,
auction_epoch: u64,
) -> Result<()> {
Ok(())
}
/// This instruction is called by the market maker to bid in an auction.
///
/// When a market maker wishes to bid in an auction, they can use
/// this instruction to specify the parameters of their bid. Note
/// that the first bidder in auction epoch N must ensure that auction
/// epoch state accounts are initialized for auction epochs N and
/// N + 1.
pub fn submit_auction_bid_instruction(
ctx: Context<SubmitAuctionBidInstruction>,
// Bumps
auction_state_account_bump: u8,
auction_epoch_state_bump: u8,
next_auction_epoch_state_bump: u8,
bid_vault_account_bump: u8,
bid_record_account_bump: u8,
market_maker_whitelist_entry_bump: u8,
// Seed Dependencies
auction_id: u64,
auction_epoch: u64,
next_auction_epoch: u64,
// Function Arguments
bid_size: u64,
) -> Result<()> {
Ok(())
}
/// This instruction is called by the market maker to withdraw its
/// losing auction bids and close its bid record account for the
/// given auction.
///
/// A market maker who is outbid in an auction can use this instruction
/// to withdraw its bids in the auction and close its bid record
/// account for the auction. A market maker who has won an auction
/// can use this instruction to close its bid record account for
/// the auction.
pub fn reclaim_auction_bid_instruction(
ctx: Context<ReclaimAuctionBidInstruction>,
// Bumps
auction_state_account_bump: u8,
auction_epoch_state_bump: u8,
bid_vault_account_bump: u8,
bid_record_account_bump: u8,
market_maker_whitelist_entry_bump: u8,
// Seed Dependencies
auction_id: u64,
auction_epoch: u64,
) -> Result<()> {
Ok(())
}
/// 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.
pub fn new_order_instruction(
ctx: Context<NewOrderInstruction>,
// Bumps
vault_token_account_bump: u8,
vault_meta_account_bump: u8,
current_auction_epoch_state_bump: u8,
previous_auction_epoch_state_bump: u8,
auction_state_account_bump: u8,
signatory_record_bump: u8,
// Seed Dependencies
auction_id: u64,
auction_epoch: u64,
previous_auction_epoch: u64,
// Function Arguments
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,
) -> Result<()> {
Ok(())
}
/// This instruction cancels an open order.
///
/// Cancelling an open order can only be done if it has not been
/// filled and if the order has been filled partially, the retail
/// trader can only cancel the part of the order which is still open.
pub fn cancel_order_instruction(
ctx: Context<CancelOrderInstruction>,
// Bumps
vault_token_account_bump: u8,
vault_meta_account_bump: u8,
auction_epoch_state_bump: u8,
// Seed Dependencies
nonce: u64,
) -> Result<()> {
Ok(())
}
/// This instruction is used to fill an open order
///
/// When a market maker fills an order that is assigned to them,
/// this instruction will partially settle the trade; the retail
/// trader will receive the tokens from the market maker, but the
/// market maker must wait until arbiters have voted on the fairness
/// of the fill in order to receive the retail trader's tokens.
pub fn fill_order_instruction(
ctx: Context<FillOrderInstruction>,
// Bumps
vault_meta_account_bump: u8,
fill_record_account_bump: u8,
auction_epoch_state_bump: u8,
auction_state_account_bump: u8,
market_maker_whitelist_entry_bump: u8,
y_recovery_vault_account_bump: u8,
// Seed Dependencies
nonce: u64,
// Function Arguments
order_details: String,
fill_amount: u64,
fill_price: u64,
) -> Result<()> {
Ok(())
}
/// This instruction is used to vote on the fairness of a fill
///
/// Arbiters vote on the fairness of a fill when the fill is open
/// for voting. In order to vote on a fill, the arbiter must stake
/// tokens on the accuracy of their vote. If the arbiter voted in
/// the majority, they receive their tokens back. Otherwise the tokens
/// are deposited into a DAO governed backstop fund for the protocol.
pub fn fill_vote_instruction(
ctx: Context<FillVoteInstruction>,
// Bumps
vault_meta_account_bump: u8,
fill_record_account_bump: u8,
vote_record_account_bump: u8,
auction_state_account_bump: u8,
arbiter_whitelist_entry_bump: u8,
vote_vault_account_bump: u8,
// Seed Dependencies
nonce: u64,
fill_nonce: u16,
// Function Arguments
vote: u8,
) -> Result<()> {
Ok(())
}
/// This instruction is used to claim back the tokens staked during
/// a fill vote by an arbiter.
///
/// If voting with the majority, the arbiter will receieve a payment
/// from the network along with their original vote. However, if
/// the arbiter did not vote in the majority on the fill, they will
/// not receive their tokens back.
pub fn claim_vote_reward_instruction(
ctx: Context<ClaimVoteRewardInstruction>,
// Bumps
vault_meta_account_bump: u8,
fill_record_account_bump: u8,
vote_record_account_bump: u8,
vote_vault_account_bump: u8,
bid_vault_account_bump: u8,
auction_state_account_bump: u8,
auction_epoch_state_bump: u8,
arbiter_whitelist_entry_bump: u8,
// Seed Dependencies
nonce: u64,
fill_nonce: u16,
) -> Result<()> {
Ok(())
}
/// This instruction is used to close the various accounts opened
/// during the lifecycle of the trade, and additionally give a rebate
/// to the order flow source for its order flow.
///
/// Lamports used to open the accounts will be returned to the payers
/// who opened the accounts.
pub fn close_fill_accounts(
ctx: Context<CloseFillAccounts>,
// Bumps
vault_token_account_bump: u8,
vault_meta_account_bump: u8,
fill_record_account_bump: u8,
bid_vault_account_bump: u8,
auction_state_account_bump: u8,
auction_epoch_state_bump: u8,
arbiter_whitelist_entry_bump: u8,
bid_recovery_vault_account_bump: u8,
x_recovery_vault_account_bump: u8,
// Seed Dependencies
nonce: u64,
fill_nonce: u16,
) -> Result<()> {
Ok(())
}
/// This instruction is used to initialize global state for tracking
/// the system of signatory servers.
///
/// This instruction can only be called by the DFlow admin and can
/// only be called once.
pub fn init_signatory_system(
ctx: Context<InitSignatorySystem>,
// Bumps
global_config_account_bump: u8,
signatory_state_bump: u8,
signatory_stake_vault_bump: u8,
) -> Result<()> {
Ok(())
}
/// This instruction is used to stake the requisite amount of tokens
/// necessary to endorse flow as retail. This stake is subject to
/// slashing based on the quality of the order flow sent by the signatory
/// server.
///
/// Signatory server operators provide helpful network participation
/// by endorsing and forwarding retail order flow to the network.
/// This helpful network participation is rewarded, or slashed based
/// on the quality of order flow sent.
pub fn create_signatory(
ctx: Context<CreateSignatory>,
// Bumps
signatory_record_bump: u8,
signatory_stake_vault_bump: u8,
signatory_server_whitelist_entry_bump: u8,
) -> Result<()> {
Ok(())
}
/// This instruction is used to stake additional tokens into an existing
/// signatory server stake vault.
///
/// Signatory servers are subject to slashing, and if slashed to
/// below the stake minimum they may no longer be qualified to endorse
/// order flow as originated from a retail source.
pub fn stake_signatory(
ctx: Context<StakeSignatory>,
// Bumps
signatory_record_bump: u8,
signatory_stake_vault_bump: u8,
signatory_server_whitelist_entry_bump: u8,
// Function Arguments
stake_size: u64,
) -> Result<()> {
Ok(())
}
/// This instruction is used to close an AuctionEpochState account.
///
/// The auction owner can use this instruction to close the AuctionEpochState
/// account for an old epoch that has no open orders or fills pending
/// settlement. The auction owner can also use this instruction close
/// the AuctionEpochState account for the last, current, or next
/// epoch if the auction is in the Draining state.
pub fn close_auction_epoch_state(
ctx: Context<CloseAuctionEpochState>,
// Bumps
auction_epoch_state_bump: u8,
auction_state_account_bump: u8,
// Seed Dependencies
auction_id: u64,
auction_epoch: u64,
) -> Result<()> {
Ok(())
}
}