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.
- Host: GitHub
- URL: https://github.com/rpcpool/solana-prioritization-fees-api
- Owner: rpcpool
- License: apache-2.0
- Created: 2024-02-23T08:24:19.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-04T06:40:50.000Z (about 2 years ago)
- Last Synced: 2024-03-04T07:49:53.875Z (about 2 years ago)
- Language: TypeScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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`