diff --git a/api/src/event.rs b/api/src/event.rs index fa1e894..80292d6 100644 --- a/api/src/event.rs +++ b/api/src/event.rs @@ -71,6 +71,12 @@ pub struct SwapEvent { /// Amount of quote tokens in the market. pub quote_liquidity: u64, + /// Amount of hashpower the miner now has. + pub miner_hashpower: u64, + + /// Amount of hashpower the block now has. + pub block_hashpower: u64, + /// The timestamp of the event. pub ts: i64, } diff --git a/api/src/state/market/buy_exact_in.rs b/api/src/state/market/buy_exact_in.rs index db7b341..55db73b 100644 --- a/api/src/state/market/buy_exact_in.rs +++ b/api/src/state/market/buy_exact_in.rs @@ -67,6 +67,8 @@ impl Market { quote_fee: quote_fee as u64, base_liquidity: self.base.liquidity() as u64, quote_liquidity: self.quote.liquidity() as u64, + miner_hashpower: 0, + block_hashpower: 0, ts: 0, }; diff --git a/api/src/state/market/buy_exact_out.rs b/api/src/state/market/buy_exact_out.rs index 14b24bb..b7b55d8 100644 --- a/api/src/state/market/buy_exact_out.rs +++ b/api/src/state/market/buy_exact_out.rs @@ -72,6 +72,8 @@ impl Market { quote_fee: quote_fee as u64, base_liquidity: self.base.liquidity() as u64, quote_liquidity: self.quote.liquidity() as u64, + miner_hashpower: 0, + block_hashpower: 0, ts: 0, }; diff --git a/api/src/state/market/sell_exact_in.rs b/api/src/state/market/sell_exact_in.rs index d68a3d6..e41de69 100644 --- a/api/src/state/market/sell_exact_in.rs +++ b/api/src/state/market/sell_exact_in.rs @@ -76,6 +76,8 @@ impl Market { quote_fee: quote_fee as u64, base_liquidity: self.base.liquidity() as u64, quote_liquidity: self.quote.liquidity() as u64, + miner_hashpower: 0, + block_hashpower: 0, ts: 0, }; diff --git a/api/src/state/market/sell_exact_out.rs b/api/src/state/market/sell_exact_out.rs index 7ee84cd..38bac79 100644 --- a/api/src/state/market/sell_exact_out.rs +++ b/api/src/state/market/sell_exact_out.rs @@ -74,6 +74,8 @@ impl Market { quote_fee: quote_fee as u64, base_liquidity: self.base.liquidity() as u64, quote_liquidity: self.quote.liquidity() as u64, + miner_hashpower: 0, + block_hashpower: 0, ts: 0, }; diff --git a/program/src/swap.rs b/program/src/swap.rs index 47bb404..b469c11 100644 --- a/program/src/swap.rs +++ b/program/src/swap.rs @@ -122,6 +122,10 @@ pub fn process_swap(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult let vault = vault_info.as_token_account()?; market.check_quote_vault(&vault)?; + // Update swap event hashpower. + swap_event.miner_hashpower = miner.hashpower; + swap_event.block_hashpower = block.total_hashpower; + // Emit event. program_log( &[market_info.clone(), ore_program.clone()],