mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 23:16:52 +00:00
swap event
This commit is contained in:
@@ -49,6 +49,12 @@ pub struct SwapEvent {
|
||||
/// Amount of quote tokens taken in fees.
|
||||
pub quote_fee: u64,
|
||||
|
||||
/// Amount of base tokens in the market.
|
||||
pub base_liquidity: u64,
|
||||
|
||||
/// Amount of quote tokens in the market.
|
||||
pub quote_liquidity: u64,
|
||||
|
||||
/// The timestamp of the event.
|
||||
pub ts: i64,
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ impl Market {
|
||||
base_via_curve: base_via_curve as u64,
|
||||
quote_via_curve: quote_via_curve as u64,
|
||||
quote_fee: quote_fee as u64,
|
||||
base_liquidity: self.base.liquidity() as u64,
|
||||
quote_liquidity: self.quote.liquidity() as u64,
|
||||
ts: 0,
|
||||
};
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ impl Market {
|
||||
base_via_curve: base_via_curve as u64,
|
||||
quote_via_curve: quote_via_curve as u64,
|
||||
quote_fee: quote_fee as u64,
|
||||
base_liquidity: self.base.liquidity() as u64,
|
||||
quote_liquidity: self.quote.liquidity() as u64,
|
||||
ts: 0,
|
||||
};
|
||||
|
||||
|
||||
@@ -74,6 +74,8 @@ impl Market {
|
||||
base_via_curve: base_via_curve as u64,
|
||||
quote_via_curve: quote_via_curve as u64,
|
||||
quote_fee: quote_fee as u64,
|
||||
base_liquidity: self.base.liquidity() as u64,
|
||||
quote_liquidity: self.quote.liquidity() as u64,
|
||||
ts: 0,
|
||||
};
|
||||
|
||||
|
||||
@@ -72,6 +72,8 @@ impl Market {
|
||||
base_via_curve: base_via_curve as u64,
|
||||
quote_via_curve: quote_via_curve as u64,
|
||||
quote_fee: quote_fee as u64,
|
||||
base_liquidity: self.base.liquidity() as u64,
|
||||
quote_liquidity: self.quote.liquidity() as u64,
|
||||
ts: 0,
|
||||
};
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ async fn main() {
|
||||
"close" => {
|
||||
close(&rpc, &payer).await.unwrap();
|
||||
}
|
||||
"close_all" => {
|
||||
close_all(&rpc, &payer).await.unwrap();
|
||||
}
|
||||
"clock" => {
|
||||
log_clock(&rpc).await.unwrap();
|
||||
}
|
||||
@@ -94,6 +97,28 @@ async fn close(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn close_all(
|
||||
rpc: &RpcClient,
|
||||
payer: &solana_sdk::signer::keypair::Keypair,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let config = get_config(rpc).await?;
|
||||
let clock = get_clock(rpc).await?;
|
||||
let blocks = get_blocks(rpc).await?;
|
||||
for (_, block) in blocks {
|
||||
if clock.slot > block.start_slot + 1500 {
|
||||
let ix = ore_api::sdk::close(
|
||||
payer.pubkey(),
|
||||
config.fee_collector,
|
||||
block.opener,
|
||||
payer.pubkey(),
|
||||
block.id,
|
||||
);
|
||||
submit_transaction(rpc, payer, &[ix]).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn commit(
|
||||
rpc: &RpcClient,
|
||||
payer: &solana_sdk::signer::keypair::Keypair,
|
||||
|
||||
Reference in New Issue
Block a user