From 98ab9a81b31b930240267f621f8301aba5d8d562 Mon Sep 17 00:00:00 2001 From: Dagur Valberg Johannsson Date: Mon, 15 Apr 2024 23:05:06 +0200 Subject: [PATCH] bugfix: List most recent pool utxos --- src/rpc/mod.rs | 3 +-- src/rpc/pool.rs | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/rpc/mod.rs b/src/rpc/mod.rs index 4e79c55..bf57126 100644 --- a/src/rpc/mod.rs +++ b/src/rpc/mod.rs @@ -76,8 +76,7 @@ pub fn list_tokens_by_volume( ORDER BY total_trade_volume DESC, tvl_sats DESC LIMIT ?; ", - ) - .unwrap(); + )?; let tokens: Vec<(String, u64, u64, u64, u64, u64, u64)> = statement .query_and_then([seconds, limit], |row| { diff --git a/src/rpc/pool.rs b/src/rpc/pool.rs index 3135be3..104ef0b 100644 --- a/src/rpc/pool.rs +++ b/src/rpc/pool.rs @@ -166,19 +166,21 @@ fn db_list_active_pools( conn: &Connection, ) -> Result> { let mut query: String = " - SELECT - p.owner_pkh, - uf.sats, - uf.token_amount, - uf.new_utxo_txid, - uf.new_utxo_n, - p.token_id - - FROM - pool p - JOIN utxo_funding uf ON p.creation_utxo = uf.new_utxo_hash - WHERE - p.withdrawn_in_utxo IS NULL + SELECT + p.owner_pkh, + uf.sats, + uf.token_amount, + uf.new_utxo_txid, + uf.new_utxo_n, + p.token_id + FROM + pool p + JOIN pool_history_entry phe ON p.creation_utxo = phe.pool + JOIN utxo_funding uf ON phe.utxo = uf.new_utxo_hash + LEFT JOIN utxo_spending us ON uf.new_utxo_hash = us.spent_utxo_hash + WHERE + p.withdrawn_in_utxo IS NULL + AND us.spent_utxo_hash IS NULL " .to_string();