An open API service indexing awesome lists of open source software.

https://github.com/rpcpool/solana-prioritization-fees-api

Solana prioritization fees API client examples.
https://github.com/rpcpool/solana-prioritization-fees-api

Last synced: 10 months ago
JSON representation

Solana prioritization fees API client examples.

Awesome Lists containing this project

README

          

# `getRecentPrioritizationFees` Trition Example

Ref: [JSON RPC getrecentprioritizationfees](https://solana.com/docs/rpc/http/getrecentprioritizationfees)

This repo contains example usage of the `percentile` flag in the `getRecentPrioritizationFees` JSON RPC call to Triton's Solana RPC endpoints.

**This functionality is currently in beta testing. It requires a patch applied to the Solana validator source for proper operation. Details on the patches are available here: https://docs.triton.one/chains/solana/improved-priority-fees-api/for-rpc-providers**

### How to use it?
This repo contains a function `getRecentPrioritizationFeesByPercentile` in `src/grpf.ts` that you can directly copy paste in your code and start using it. See the example usage in `/tests/grpf2.test.ts`

Function Details:
`getRecentPrioritizationFeesByPercentile`
Params:
```
connection: @solana/web3.js.Connection;
config: GetRecentPrioritizationFeesByPercentileConfig {
lockedWritableAccounts?: PublicKey[];
percentile?: number | PriotitizationFeeLevels, allowed range: 1 - 10_000;
fallback?: boolean, default: true;
}
slotsToReturn?: n number of slots will returned. By default RPC returns 150
```

`PriotitizationFeeLevels` is an enum for user convenience which has numeric values. It is intended to keep the percentile values less confusing for the users

Returns: `RecentPrioritizationFees[]` same as `Connection.getRecentPrioritizationFees`

To maintain compatibility with other RPC providers who might not support the `percentile` parameter, this function takes in a `fallback` parameter which defaults to `true`. The function makes 2 JSON RPC calls in parallel with and without the `percentile` parameter. If your RPC is Triton, you'll get the result returned by it. If not, you'll get the result returned by your other RPC provider.

### Helper Functions
There are the following helper functions that return `Promise`
- `getMinPrioritizationFeeByPercentile`
- `getMaxPrioritizationFeeByPercentile`
- `getMeanPrioritizationFeeByPercentile`
- `getMedianPrioritizationFeeByPercentile`