mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-21 15:10:35 +00:00
swap authority
This commit is contained in:
@@ -5,6 +5,9 @@ use crate::state::SwapDirection;
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)]
|
||||
pub struct SwapEvent {
|
||||
/// The authority of the swap.
|
||||
pub authority: [u8; 32],
|
||||
|
||||
/// The block id.
|
||||
pub block_id: u64,
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use steel::Pubkey;
|
||||
|
||||
use crate::error::OreError;
|
||||
|
||||
use super::{Market, SwapDirection, TokenType, VirtualLimitOrder};
|
||||
@@ -52,6 +54,7 @@ impl Market {
|
||||
// Produce swap result.
|
||||
let base_out = base_via_ask + base_via_curve;
|
||||
let swap_event = SwapEvent {
|
||||
authority: [0; 32],
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Buy as u64,
|
||||
base_to_transfer: base_out as u64,
|
||||
|
||||
@@ -57,6 +57,7 @@ impl Market {
|
||||
|
||||
// Produce swap result.
|
||||
let swap_event = SwapEvent {
|
||||
authority: [0; 32],
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Buy as u64,
|
||||
base_to_transfer: base_out as u64,
|
||||
|
||||
@@ -61,6 +61,7 @@ impl Market {
|
||||
// Produce swap result.
|
||||
let quote_out = quote_via_bid + quote_via_curve;
|
||||
let swap_event = SwapEvent {
|
||||
authority: [0; 32],
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Sell as u64,
|
||||
base_to_transfer: base_in as u64,
|
||||
|
||||
@@ -59,6 +59,7 @@ impl Market {
|
||||
|
||||
// Produce swap result.
|
||||
let swap_event = SwapEvent {
|
||||
authority: [0; 32],
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Sell as u64,
|
||||
base_to_transfer: base_in as u64,
|
||||
|
||||
@@ -100,6 +100,7 @@ pub fn process_swap(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
|
||||
// Update market state.
|
||||
let mut swap_result = market.swap(amount, direction, precision, clock)?;
|
||||
swap_result.authority = signer_info.key.to_bytes();
|
||||
swap_result.block_id = block.id;
|
||||
swap_result.log_return();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user