instruction.rs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. use steel::*;
  2. #[repr(u8)]
  3. #[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
  4. pub enum TokenSwapInstruction {
  5. CreateAmm = 0,
  6. CreatePool = 1,
  7. DepositLiquidity = 2,
  8. WithdrawLiquidity = 3,
  9. Swap = 4,
  10. }
  11. #[repr(C)]
  12. #[derive(Clone, Copy, Debug, Pod, Zeroable)]
  13. pub struct CreateAmm {
  14. pub id: Pubkey,
  15. pub fee: [u8; 2],
  16. }
  17. #[repr(C)]
  18. #[derive(Clone, Copy, Debug, Pod, Zeroable)]
  19. pub struct CreatePool {}
  20. #[repr(C)]
  21. #[derive(Clone, Copy, Debug, Pod, Zeroable)]
  22. pub struct DepositLiquidity {
  23. pub amount_a: [u8; 8],
  24. pub amount_b: [u8; 8],
  25. }
  26. #[repr(C)]
  27. #[derive(Clone, Copy, Debug, Pod, Zeroable)]
  28. pub struct WithdrawLiquidity {
  29. pub amount: [u8; 8],
  30. }
  31. #[repr(C)]
  32. #[derive(Clone, Copy, Debug, Pod, Zeroable)]
  33. pub struct Swap {
  34. pub swap_a: u8,
  35. pub input_amount: [u8; 8],
  36. pub min_output_amount: [u8; 8],
  37. }
  38. instruction!(TokenSwapInstruction, CreateAmm);
  39. instruction!(TokenSwapInstruction, CreatePool);
  40. instruction!(TokenSwapInstruction, DepositLiquidity);
  41. instruction!(TokenSwapInstruction, WithdrawLiquidity);
  42. instruction!(TokenSwapInstruction, Swap);