fema-pf-calc 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +38 -38
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -62,12 +62,12 @@ That is all a developer needs to do. No RPC key, no math, no guessing.
62
62
 
63
63
  ```ts
64
64
  const result = await estimateFee({
65
- speed: "fast", // "slow" | "medium" | "fast"
66
- strategy: "balanced", // "cheap" | "balanced" | "aggressive"
67
- protocol: "jupiter", // see supported protocols below
65
+ speed: "fast", // "slow" | "medium" | "fast"
66
+ strategy: "balanced", // "cheap" | "balanced" | "aggressive"
67
+ protocol: "jupiter", // see supported protocols below
68
68
  transaction: myTransaction, // pass your actual tx for automatic protocol detection
69
- maxFee: 500_000, // optional cap in microLamports
70
- includeStats: true, // include full distribution in response
69
+ maxFee: 500_000, // optional cap in microLamports
70
+ includeStats: true, // include full distribution in response
71
71
  });
72
72
  ```
73
73
 
@@ -138,11 +138,11 @@ const { fee } = await estimateFee({
138
138
 
139
139
  ```ts
140
140
  {
141
- fee: 253637, // microLamports per CU — pass directly to setComputeUnitPrice
142
- congestion: "high", // "low" | "medium" | "high"
143
- percentileUsed: 75, // which percentile was used
144
- sampleSize: 1203, // number of transactions analyzed
145
- programFiltered: true, // true = fee is based on your protocol's txs specifically
141
+ fee: 253637, // microLamports per CU — pass directly to setComputeUnitPrice
142
+ congestion: "high", // "low" | "medium" | "high"
143
+ percentileUsed: 75, // which percentile was used
144
+ sampleSize: 1203, // number of transactions analyzed
145
+ programFiltered: true, // true = fee is based on your protocol's txs specifically
146
146
 
147
147
  // only included when includeStats: true
148
148
  stats: {
@@ -169,44 +169,44 @@ The `fee` value is in **microLamports per compute unit** — the exact unit that
169
169
 
170
170
  ```ts
171
171
  init({
172
- cluster: "mainnet-beta", // "mainnet-beta" | "devnet" (default: "mainnet-beta")
173
- rpcUrl: "https://your-rpc.com", // optional bring your own RPC to override the default
174
- cacheDurationMs: 7000, // how long to cache results in ms (default: 7000)
172
+ cluster: "mainnet-beta", // "mainnet-beta" | "devnet" (default: "mainnet-beta")
173
+ cacheDurationMs: 7000, // how long to cache results in ms (default: 7000)
175
174
  });
176
175
  ```
177
176
 
178
- You can also override the RPC via environment variables:
177
+ ---
179
178
 
180
- ```env
181
- # Optional: use your own RPC provider (overrides the built-in default)
182
- SOLANA_RPC_URL=https://your-custom-rpc.com
179
+ ## Sample Code
183
180
 
184
- # Or use your own Helius API key
185
- HELIUS_API_KEY=your-api-key-here
181
+ ```ts
182
+ import express from "express";
183
+ import { init, estimateFee } from "fema-pf-calc";
184
+ import { ComputeBudgetProgram } from "@solana/web3.js";
186
185
 
187
- # Network: mainnet-beta (default) or devnet
188
- SOLANA_CLUSTER=mainnet-beta
186
+ const app = express();
189
187
 
190
- # How long to cache fee data in milliseconds (default: 7000)
191
- CACHE_DURATION_MS=7000
192
- ```
188
+ init({ cluster: "mainnet-beta" }); // no RPC setup needed
193
189
 
194
- ---
190
+ app.get("/fee", async (req, res) => {
191
+ try {
192
+ const { fee } = await estimateFee({ speed: "fast", strategy: "balanced" });
195
193
 
196
- ## Project Structure
194
+ const priorityIx = ComputeBudgetProgram.setComputeUnitPrice({
195
+ microLamports: fee,
196
+ });
197
197
 
198
- ```
199
- src/
200
- ├── index.ts # SDK entry point — estimateFee() and init()
201
- ├── types.ts # TypeScript types and interfaces
202
- ├── config.ts # Configuration and RPC resolution
203
- ├── protocols.ts # Known protocol registry (Jupiter, Raydium, etc.)
204
- ├── engine/
205
- │ └── feeCalculator.ts # Percentile math, strategy modifiers, outlier filtering
206
- └── services/
207
- ├── solana.ts # RPC data fetching and block scanning
208
- ├── cache.ts # In-memory TTL cache
209
- └── database.ts # In-memory snapshot store and fallback
198
+ res.json({ fee, priorityIx });
199
+ } catch (err) {
200
+ console.error(err);
201
+ res.status(500).json({ error: err.message });
202
+ }
203
+ });
204
+
205
+ app.listen(8000, () => {
206
+ console.log("Server is running on port http://localhost:8000");
207
+ });
208
+
209
+ export default app;
210
210
  ```
211
211
 
212
212
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fema-pf-calc",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Intelligent Solana priority fee estimation engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",