Add vaults protocol-fee endpoint - #166
Open
zahorodnyi wants to merge 2 commits into
Open
zahorodnyi wants to merge 2 commits into
zahorodnyi wants to merge 2 commits into
Conversation
Hrom131
reviewed
Sep 10, 2026
Hrom131
reviewed
Sep 14, 2026
Comment on lines
+38
to
+61
| let rows = sqlx::query_as!( | ||
| HarvestableProtocolFeeVaultRow, | ||
| r#" | ||
| SELECT | ||
| offer_vaults.offer_id, | ||
| offer_vaults.txid, | ||
| offer_vaults.vout, | ||
| offer_vaults.amount, | ||
| offer_vaults.created_at_height, | ||
| offer_vaults.updated_at_height, | ||
| offers.borrower_nft_asset_id, | ||
| offers.protocol_fee_keeper_asset_id | ||
| FROM offer_vaults | ||
| JOIN offers ON offers.id = offer_vaults.offer_id | ||
| WHERE offer_vaults.vault_type = 'protocol_fee' | ||
| AND offer_vaults.is_finalized = true | ||
| AND offer_vaults.spent_txid IS NULL | ||
| AND offers.principal_asset_id = $1 | ||
| ORDER BY offer_vaults.amount DESC, offer_vaults.id DESC | ||
| "#, | ||
| principal_asset_id, | ||
| ) | ||
| .fetch_all(db) | ||
| .await?; |
Collaborator
There was a problem hiding this comment.
Let's add pagination logic here
Hrom131
reviewed
Sep 14, 2026
| .await?; | ||
|
|
||
| let count = rows.len() as u64; | ||
| let total_amount: i64 = rows.iter().map(|row| row.amount).sum(); |
Collaborator
There was a problem hiding this comment.
With pagination logic, total_amount needs to be calculated through a separate Query
Hrom131
reviewed
Sep 14, 2026
| ) | ||
| )] | ||
| #[tracing::instrument(name = "Getting unspent protocol-fee vaults", skip(state, query))] | ||
| pub async fn list_protocol_fee_vaults( |
Collaborator
There was a problem hiding this comment.
We need to add this method to the IndexerClient
Hrom131
reviewed
Sep 14, 2026
Comment on lines
+12
to
+23
| pub struct ProtocolFeeVaultDto { | ||
| #[schema(example = "1")] | ||
| pub offer_id: String, | ||
| pub txid: String, | ||
| pub vout: u32, | ||
| #[schema(example = "1000")] | ||
| pub amount: String, | ||
| pub borrower_nft_asset: String, | ||
| pub protocol_fee_keeper_asset: String, | ||
| pub created_at_height: u64, | ||
| pub updated_at_height: u64, | ||
| } |
Collaborator
There was a problem hiding this comment.
Is this information enough to build the AssetAuthVault contract and spend it?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.