abort if new tokens or perp markets listed (#411)
* abort if new tokens or perp markets listed Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> * fixes from review Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> * fixes from review Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
3f0ed5978c
commit
800fe73a9c
|
@ -335,6 +335,21 @@ impl MangoGroupContext {
|
|||
.chain(serum_oos.map(to_account_meta))
|
||||
.collect())
|
||||
}
|
||||
|
||||
pub async fn new_tokens_listed(&self, rpc: &RpcClientAsync) -> anyhow::Result<bool> {
|
||||
let mint_infos = fetch_mint_infos(rpc, mango_v4::id(), self.group).await?;
|
||||
Ok(mint_infos.len() > self.tokens.len())
|
||||
}
|
||||
|
||||
pub async fn new_serum3_markets_listed(&self, rpc: &RpcClientAsync) -> anyhow::Result<bool> {
|
||||
let serum3_markets = fetch_serum3_markets(rpc, mango_v4::id(), self.group).await?;
|
||||
Ok(serum3_markets.len() > self.serum3_markets.len())
|
||||
}
|
||||
|
||||
pub async fn new_perp_markets_listed(&self, rpc: &RpcClientAsync) -> anyhow::Result<bool> {
|
||||
let new_perp_markets = fetch_perp_markets(rpc, mango_v4::id(), self.group).await?;
|
||||
Ok(new_perp_markets.len() > self.perp_markets.len())
|
||||
}
|
||||
}
|
||||
|
||||
fn from_serum_style_pubkey(d: [u64; 4]) -> Pubkey {
|
||||
|
|
|
@ -21,6 +21,7 @@ pub async fn runner(
|
|||
interval_update_banks: u64,
|
||||
interval_consume_events: u64,
|
||||
interval_update_funding: u64,
|
||||
interval_check_new_listings_and_abort: u64,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let handles1 = mango_client
|
||||
.context
|
||||
|
@ -73,12 +74,37 @@ pub async fn runner(
|
|||
futures::future::join_all(handles1),
|
||||
futures::future::join_all(handles2),
|
||||
futures::future::join_all(handles3),
|
||||
loop_check_new_listings_and_abort(
|
||||
mango_client.clone(),
|
||||
interval_check_new_listings_and_abort
|
||||
),
|
||||
debugging_handle
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn loop_check_new_listings_and_abort(mango_client: Arc<MangoClient>, interval: u64) {
|
||||
let mut interval = time::interval(Duration::from_secs(interval));
|
||||
loop {
|
||||
if mango_client
|
||||
.context
|
||||
.new_tokens_listed(&mango_client.client.rpc_async())
|
||||
.await
|
||||
.unwrap()
|
||||
|| mango_client
|
||||
.context
|
||||
.new_perp_markets_listed(&mango_client.client.rpc_async())
|
||||
.await
|
||||
.unwrap()
|
||||
{
|
||||
std::process::abort();
|
||||
}
|
||||
|
||||
interval.tick().await;
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn loop_update_index_and_rate(
|
||||
mango_client: Arc<MangoClient>,
|
||||
token_indices: Vec<TokenIndex>,
|
||||
|
|
|
@ -53,6 +53,9 @@ struct Cli {
|
|||
#[clap(long, env, default_value_t = 5)]
|
||||
interval_update_funding: u64,
|
||||
|
||||
#[clap(long, env, default_value_t = 120)]
|
||||
interval_check_new_listings_and_abort: u64,
|
||||
|
||||
#[clap(long, env, default_value_t = 10)]
|
||||
timeout: u64,
|
||||
}
|
||||
|
@ -126,6 +129,7 @@ async fn main() -> Result<(), anyhow::Error> {
|
|||
cli.interval_update_banks,
|
||||
cli.interval_consume_events,
|
||||
cli.interval_update_funding,
|
||||
cli.interval_check_new_listings_and_abort,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue