Skip to content

Commit

Permalink
api: add skipZeros to gRPF solfees (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid authored Nov 17, 2024
1 parent 9b79795 commit 49f9d88
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
5 changes: 3 additions & 2 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Accept `percentile` option that calculate fee as percentile (bps, i.e. allowed v

#### `getRecentPrioritizationFees`

Provide more filters: accept read-write accounts, read-only accounts and up to 5 desired percentile levels. Response includes number of transactions, number of filtered transactions, average fee and requested levels with slot and commitment.
Provide more filters: accept read-write accounts, read-only accounts, up to 5 desired percentile levels and allow to exclude transactions with zero unit price. Response includes number of transactions, number of filtered transactions, average fee and requested levels with slot and commitment.

## Original Solana API

Expand Down Expand Up @@ -149,7 +149,8 @@ defaults:

- `readWrite`: `[]`
- `readOnly`: `[]`
- `percentile`: `0`
- `levels`: `[]`
- `skipZeros`: `false`

```
> {"method":"getRecentPrioritizationFees","jsonrpc":"2.0","params":[{"readWrite":[],"readOnly":["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],"levels":[5000, 9500]}],"id":"1"}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ The minor version will be incremented upon a breaking change and the patch versi
- geyser: do not stream outdated data ([#17](https://github.com/solana-stream-solutions/solfees/pull/17))
- backend: add metrics of used resources ([#18](https://github.com/solana-stream-solutions/solfees/pull/18))
- backend: fix ws stream shutdown ([#19](https://github.com/solana-stream-solutions/solfees/pull/19))
- api: add `skipZeros` to `gRPF` solfees ([#20](https://github.com/solana-stream-solutions/solfees/pull/20))

### Breaking
6 changes: 6 additions & 0 deletions solfees-be/src/bin/solfees-ws-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ struct Args {
/// Up to 5 levels (bps)
#[clap(long, default_values_t = [2000, 5000, 9000])]
levels: Vec<u16>,

/// Skip transactions with zero unit price
#[clap(long, default_value_t = false)]
skip_zeros: bool,
}

#[derive(Debug, Serialize)]
Expand All @@ -32,6 +36,7 @@ struct SubscriptionParams {
read_write: Vec<String>,
read_only: Vec<String>,
levels: Vec<u16>,
skip_zeros: bool,
}

#[tokio::main]
Expand All @@ -46,6 +51,7 @@ async fn main() -> anyhow::Result<()> {
read_write: args.read_write.unwrap_or_default(),
read_only: args.read_only.unwrap_or_default(),
levels: args.levels,
skip_zeros: args.skip_zeros,
}
}))
.context("failed to create request")?;
Expand Down
7 changes: 6 additions & 1 deletion solfees-be/src/rpc_solana.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,9 @@ impl StreamsSlotInfo {
.iter()
.all(|pubkey| tx.accounts.readable.contains(pubkey))
}) {
fees.push(transaction.unit_price);
if transaction.unit_price > 0 || !filter.skip_zeros {
fees.push(transaction.unit_price);
}
}
let total_transactions_filtered = fees.len();

Expand Down Expand Up @@ -1389,13 +1391,15 @@ struct ReqParamsSlotsSubscribeConfig {
read_write: Vec<String>,
read_only: Vec<String>,
levels: Vec<u16>,
skip_zeros: bool,
}

#[derive(Debug)]
struct SlotSubscribeFilter {
read_write: Vec<Pubkey>,
read_only: Vec<Pubkey>,
levels: Vec<u16>,
skip_zeros: bool,
}

impl TryFrom<ReqParamsSlotsSubscribeConfig> for SlotSubscribeFilter {
Expand Down Expand Up @@ -1446,6 +1450,7 @@ impl TryFrom<ReqParamsSlotsSubscribeConfig> for SlotSubscribeFilter {
read_write,
read_only,
levels: config.levels,
skip_zeros: config.skip_zeros,
})
}
}
Expand Down

0 comments on commit 49f9d88

Please sign in to comment.