Skip to content

Commit 49f9d88

Browse files
authored
api: add skipZeros to gRPF solfees (#20)
1 parent 9b79795 commit 49f9d88

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

API.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Accept `percentile` option that calculate fee as percentile (bps, i.e. allowed v
1616

1717
#### `getRecentPrioritizationFees`
1818

19-
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.
19+
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.
2020

2121
## Original Solana API
2222

@@ -149,7 +149,8 @@ defaults:
149149

150150
- `readWrite`: `[]`
151151
- `readOnly`: `[]`
152-
- `percentile`: `0`
152+
- `levels`: `[]`
153+
- `skipZeros`: `false`
153154

154155
```
155156
> {"method":"getRecentPrioritizationFees","jsonrpc":"2.0","params":[{"readWrite":[],"readOnly":["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],"levels":[5000, 9500]}],"id":"1"}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ The minor version will be incremented upon a breaking change and the patch versi
2929
- geyser: do not stream outdated data ([#17](https://github.com/solana-stream-solutions/solfees/pull/17))
3030
- backend: add metrics of used resources ([#18](https://github.com/solana-stream-solutions/solfees/pull/18))
3131
- backend: fix ws stream shutdown ([#19](https://github.com/solana-stream-solutions/solfees/pull/19))
32+
- api: add `skipZeros` to `gRPF` solfees ([#20](https://github.com/solana-stream-solutions/solfees/pull/20))
3233

3334
### Breaking

solfees-be/src/bin/solfees-ws-client.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ struct Args {
2424
/// Up to 5 levels (bps)
2525
#[clap(long, default_values_t = [2000, 5000, 9000])]
2626
levels: Vec<u16>,
27+
28+
/// Skip transactions with zero unit price
29+
#[clap(long, default_value_t = false)]
30+
skip_zeros: bool,
2731
}
2832

2933
#[derive(Debug, Serialize)]
@@ -32,6 +36,7 @@ struct SubscriptionParams {
3236
read_write: Vec<String>,
3337
read_only: Vec<String>,
3438
levels: Vec<u16>,
39+
skip_zeros: bool,
3540
}
3641

3742
#[tokio::main]
@@ -46,6 +51,7 @@ async fn main() -> anyhow::Result<()> {
4651
read_write: args.read_write.unwrap_or_default(),
4752
read_only: args.read_only.unwrap_or_default(),
4853
levels: args.levels,
54+
skip_zeros: args.skip_zeros,
4955
}
5056
}))
5157
.context("failed to create request")?;

solfees-be/src/rpc_solana.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,9 @@ impl StreamsSlotInfo {
12671267
.iter()
12681268
.all(|pubkey| tx.accounts.readable.contains(pubkey))
12691269
}) {
1270-
fees.push(transaction.unit_price);
1270+
if transaction.unit_price > 0 || !filter.skip_zeros {
1271+
fees.push(transaction.unit_price);
1272+
}
12711273
}
12721274
let total_transactions_filtered = fees.len();
12731275

@@ -1389,13 +1391,15 @@ struct ReqParamsSlotsSubscribeConfig {
13891391
read_write: Vec<String>,
13901392
read_only: Vec<String>,
13911393
levels: Vec<u16>,
1394+
skip_zeros: bool,
13921395
}
13931396

13941397
#[derive(Debug)]
13951398
struct SlotSubscribeFilter {
13961399
read_write: Vec<Pubkey>,
13971400
read_only: Vec<Pubkey>,
13981401
levels: Vec<u16>,
1402+
skip_zeros: bool,
13991403
}
14001404

14011405
impl TryFrom<ReqParamsSlotsSubscribeConfig> for SlotSubscribeFilter {
@@ -1446,6 +1450,7 @@ impl TryFrom<ReqParamsSlotsSubscribeConfig> for SlotSubscribeFilter {
14461450
read_write,
14471451
read_only,
14481452
levels: config.levels,
1453+
skip_zeros: config.skip_zeros,
14491454
})
14501455
}
14511456
}

0 commit comments

Comments
 (0)