lib.rs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // This file is autogenerated with https://github.com/acheroncrypto/native-to-anchor
  2. use anchor_lang::prelude::*;
  3. declare_id!("11111111111111111111111111111111");
  4. #[program]
  5. pub mod spl_binary_option {
  6. use super::*;
  7. pub fn initialize_binary_option(
  8. ctx: Context<InitializeBinaryOption>,
  9. decimals: u8,
  10. ) -> Result<()> {
  11. Ok(())
  12. }
  13. pub fn trade(ctx: Context<Trade>, size: u64, buy_price: u64, sell_price: u64) -> Result<()> {
  14. Ok(())
  15. }
  16. pub fn settle(ctx: Context<Settle>) -> Result<()> {
  17. Ok(())
  18. }
  19. pub fn collect(ctx: Context<Collect>) -> Result<()> {
  20. Ok(())
  21. }
  22. }
  23. #[derive(Accounts)]
  24. pub struct InitializeBinaryOption<'info> {
  25. #[account(mut)]
  26. pool_account: Signer<'info>,
  27. escrow_mint: AccountInfo<'info>,
  28. #[account(mut)]
  29. escrow_account: Signer<'info>,
  30. #[account(mut)]
  31. long_token_mint: Signer<'info>,
  32. #[account(mut)]
  33. short_token_mint: Signer<'info>,
  34. mint_authority: Signer<'info>,
  35. update_authority: Signer<'info>,
  36. token_program: Program<'info, Token>,
  37. system_program: Program<'info, System>,
  38. rent: Sysvar<'info, Rent>,
  39. }
  40. #[derive(Accounts)]
  41. pub struct Trade<'info> {
  42. #[account(mut)]
  43. pool_account: AccountInfo<'info>,
  44. #[account(mut)]
  45. escrow_account: AccountInfo<'info>,
  46. #[account(mut)]
  47. long_token_mint: AccountInfo<'info>,
  48. #[account(mut)]
  49. short_token_mint: AccountInfo<'info>,
  50. buyer: Signer<'info>,
  51. seller: Signer<'info>,
  52. #[account(mut)]
  53. buyer_account: AccountInfo<'info>,
  54. #[account(mut)]
  55. seller_account: AccountInfo<'info>,
  56. #[account(mut)]
  57. buyer_long_token_account: AccountInfo<'info>,
  58. #[account(mut)]
  59. buyer_short_token_account: AccountInfo<'info>,
  60. #[account(mut)]
  61. seller_long_token_account: AccountInfo<'info>,
  62. #[account(mut)]
  63. seller_short_token_account: AccountInfo<'info>,
  64. escrow_authority: AccountInfo<'info>,
  65. token_program: Program<'info, Token>,
  66. }
  67. #[derive(Accounts)]
  68. pub struct Settle<'info> {
  69. #[account(mut)]
  70. pool_account: AccountInfo<'info>,
  71. winning_mint: AccountInfo<'info>,
  72. pool_authority: Signer<'info>,
  73. }
  74. #[derive(Accounts)]
  75. pub struct Collect<'info> {
  76. #[account(mut)]
  77. pool_account: AccountInfo<'info>,
  78. collector_account: AccountInfo<'info>,
  79. #[account(mut)]
  80. collector_long_token_account: AccountInfo<'info>,
  81. #[account(mut)]
  82. collector_short_token_account: AccountInfo<'info>,
  83. #[account(mut)]
  84. collector_collateral_account: AccountInfo<'info>,
  85. #[account(mut)]
  86. long_token_mint_account: AccountInfo<'info>,
  87. #[account(mut)]
  88. short_token_mint_account: AccountInfo<'info>,
  89. #[account(mut)]
  90. escrow_account: AccountInfo<'info>,
  91. #[account(mut)]
  92. escrow_authority_account: AccountInfo<'info>,
  93. token_program: Program<'info, Token>,
  94. }
  95. #[account]
  96. pub struct BinaryOption {
  97. pub decimals: u8,
  98. pub circulation: u64,
  99. pub settled: bool,
  100. pub escrow_mint_account_pubkey: Pubkey,
  101. pub escrow_account_pubkey: Pubkey,
  102. pub long_mint_account_pubkey: Pubkey,
  103. pub short_mint_account_pubkey: Pubkey,
  104. pub owner: Pubkey,
  105. pub winning_side_pubkey: Pubkey,
  106. }
  107. #[error_code]
  108. pub enum BinaryOptionError {
  109. #[msg("PublicKeyMismatch")]
  110. PublicKeyMismatch,
  111. #[msg("InvalidMintAuthority")]
  112. InvalidMintAuthority,
  113. #[msg("NotMintAuthority")]
  114. NotMintAuthority,
  115. #[msg("InvalidSupply")]
  116. InvalidSupply,
  117. #[msg("InvalidWinner")]
  118. InvalidWinner,
  119. #[msg("UninitializedAccount")]
  120. UninitializedAccount,
  121. #[msg("IncorrectOwner")]
  122. IncorrectOwner,
  123. #[msg("AlreadySettled")]
  124. AlreadySettled,
  125. #[msg("BetNotSettled")]
  126. BetNotSettled,
  127. #[msg("TokenNotFoundInPool")]
  128. TokenNotFoundInPool,
  129. #[msg("PublicKeysShouldBeUnique")]
  130. PublicKeysShouldBeUnique,
  131. #[msg("TradePricesIncorrect")]
  132. TradePricesIncorrect,
  133. }