mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 23:16:52 +00:00
swap event
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 block id.
|
||||
pub block_id: u64,
|
||||
|
||||
/// Swap direction.
|
||||
pub direction: u64,
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ impl Market {
|
||||
// Produce swap result.
|
||||
let base_out = base_via_ask + base_via_curve;
|
||||
let swap_event = SwapEvent {
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Buy as u64,
|
||||
base_to_transfer: base_out as u64,
|
||||
quote_to_transfer: quote_in,
|
||||
|
||||
@@ -57,6 +57,7 @@ impl Market {
|
||||
|
||||
// Produce swap result.
|
||||
let swap_event = SwapEvent {
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Buy as u64,
|
||||
base_to_transfer: base_out as u64,
|
||||
quote_to_transfer: quote_in as u64,
|
||||
|
||||
@@ -61,6 +61,7 @@ impl Market {
|
||||
// Produce swap result.
|
||||
let quote_out = quote_via_bid + quote_via_curve;
|
||||
let swap_event = SwapEvent {
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Sell as u64,
|
||||
base_to_transfer: base_in as u64,
|
||||
quote_to_transfer: quote_out as u64,
|
||||
|
||||
@@ -59,6 +59,7 @@ impl Market {
|
||||
|
||||
// Produce swap result.
|
||||
let swap_event = SwapEvent {
|
||||
block_id: 0,
|
||||
direction: SwapDirection::Sell as u64,
|
||||
base_to_transfer: base_in as u64,
|
||||
quote_to_transfer: quote_out as u64,
|
||||
|
||||
@@ -49,7 +49,8 @@ pub fn process_swap(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
token_program.is_program(&spl_token::ID)?;
|
||||
|
||||
// Update market state.
|
||||
let swap_result = market.swap(amount, direction, precision, clock)?;
|
||||
let mut swap_result = market.swap(amount, direction, precision, clock)?;
|
||||
swap_result.block_id = block.id;
|
||||
swap_result.log_return();
|
||||
|
||||
// Get transfer amounts and accounts.
|
||||
|
||||
Reference in New Issue
Block a user