From f80b72d9e0548071371e2c6c3fef9c4df65ab46e Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Wed, 24 Apr 2024 10:38:23 +0200 Subject: [PATCH 1/3] keeper: dont crank closed tokens Signed-off-by: microwavedcola1 --- bin/keeper/src/crank.rs | 4 +++- lib/client/src/context.rs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/keeper/src/crank.rs b/bin/keeper/src/crank.rs index 82359c859..791230dd2 100644 --- a/bin/keeper/src/crank.rs +++ b/bin/keeper/src/crank.rs @@ -104,7 +104,9 @@ pub async fn runner( let handles1 = mango_client .context .tokens - .keys() + .values() + .filter(|t| t.closed == false) + .map(|t| &t.token_index) // TODO: grouping tokens whose oracle might have less confidencen e.g. ORCA with the rest, fails whole ix // TokenUpdateIndexAndRate is known to take max 71k cu // from cargo test-bpf local tests diff --git a/lib/client/src/context.rs b/lib/client/src/context.rs index 365dc47f7..ff1b90aeb 100644 --- a/lib/client/src/context.rs +++ b/lib/client/src/context.rs @@ -28,6 +28,7 @@ use solana_sdk::pubkey::Pubkey; pub struct TokenContext { pub group: Pubkey, pub token_index: TokenIndex, + pub closed: bool, pub name: String, pub mint: Pubkey, pub oracle: Pubkey, @@ -271,6 +272,7 @@ impl MangoGroupContext { name: String::new(), mint_info_address: *pk, decimals: u8::MAX, + closed: false, banks: mi.banks, vaults: mi.vaults, oracle: mi.oracle, @@ -297,6 +299,8 @@ impl MangoGroupContext { let fallback_oracle_accounts = fetch_multiple_accounts(rpc, &fallback_keys[..]).await?; for (index, (_, bank)) in bank_tuples.iter().enumerate() { let token = tokens.get_mut(&bank.token_index).unwrap(); + token.closed = + bank.native_deposits() == 0 && bank.native_borrows() == 0 && bank.reduce_only == 1; token.name = bank.name().into(); token.decimals = bank.mint_decimals; token.oracle_config = bank.oracle_config; From 128992f6c4cb33d8455b80899bf26318bb41ae4f Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Wed, 24 Apr 2024 14:02:22 +0200 Subject: [PATCH 2/3] Fixes from review Signed-off-by: microwavedcola1 --- bin/keeper/src/crank.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/keeper/src/crank.rs b/bin/keeper/src/crank.rs index 791230dd2..2ae29b5d0 100644 --- a/bin/keeper/src/crank.rs +++ b/bin/keeper/src/crank.rs @@ -105,7 +105,7 @@ pub async fn runner( .context .tokens .values() - .filter(|t| t.closed == false) + .filter(|t| !t.closed) .map(|t| &t.token_index) // TODO: grouping tokens whose oracle might have less confidencen e.g. ORCA with the rest, fails whole ix // TokenUpdateIndexAndRate is known to take max 71k cu From 3d1e8b69840342483793534ed5ce5f625a28adb7 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Wed, 24 Apr 2024 14:18:05 +0200 Subject: [PATCH 3/3] Fixes from review Signed-off-by: microwavedcola1 --- lib/client/src/context.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/src/context.rs b/lib/client/src/context.rs index ff1b90aeb..d8f4c5d3f 100644 --- a/lib/client/src/context.rs +++ b/lib/client/src/context.rs @@ -272,7 +272,7 @@ impl MangoGroupContext { name: String::new(), mint_info_address: *pk, decimals: u8::MAX, - closed: false, + closed: true, banks: mi.banks, vaults: mi.vaults, oracle: mi.oracle, @@ -299,7 +299,7 @@ impl MangoGroupContext { let fallback_oracle_accounts = fetch_multiple_accounts(rpc, &fallback_keys[..]).await?; for (index, (_, bank)) in bank_tuples.iter().enumerate() { let token = tokens.get_mut(&bank.token_index).unwrap(); - token.closed = + token.closed &= bank.native_deposits() == 0 && bank.native_borrows() == 0 && bank.reduce_only == 1; token.name = bank.name().into(); token.decimals = bank.mint_decimals;