fema-pf-calc 1.0.3 → 1.0.5

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.
package/README.md CHANGED
@@ -18,13 +18,13 @@ FEMA solves this by scanning recent blocks, building a real fee distribution, an
18
18
 
19
19
  ## How It Works
20
20
 
21
- 1. FEMA connects to a Solana RPC and fetches data from the last 30 blocks
22
- 2. For each transaction in those blocks it extracts the fee paid in microLamports per compute unit
21
+ 1. FEMA connects to Solana via a built-in Helius-backed RPC proxy no API key or RPC setup required
22
+ 2. For each transaction in the last 30 blocks it extracts the fee paid in microLamports per compute unit
23
23
  3. It sorts these into a distribution and computes percentiles (p25, p50, p75)
24
24
  4. If you specify a protocol or pass your transaction, it filters the data to only transactions that used the same programs as yours
25
25
  5. It returns the fee at the percentile matching your chosen speed and strategy
26
26
 
27
- Results are cached for 30 seconds to avoid hammering the RPC on every call.
27
+ Results are cached for 7 seconds to avoid hammering the RPC on every call.
28
28
 
29
29
  ---
30
30
 
@@ -43,10 +43,7 @@ import { init, estimateFee } from "fema-pf-calc";
43
43
  import { ComputeBudgetProgram } from "@solana/web3.js";
44
44
 
45
45
  // Configure once at app startup
46
- init({
47
- cluster: "mainnet-beta", // or "devnet"
48
- rpcUrl: "https://mainnet.helius-rpc.com/?api-key=YOUR_KEY", // optional override
49
- });
46
+ init({ cluster: "mainnet-beta" }); // no RPC setup needed
50
47
 
51
48
  // Get the recommended fee
52
49
  const { fee } = await estimateFee({ speed: "fast", strategy: "balanced" });
@@ -57,7 +54,7 @@ const priorityIx = ComputeBudgetProgram.setComputeUnitPrice({
57
54
  });
58
55
  ```
59
56
 
60
- That is all a developer needs to do. No RPC calls, no math, no guessing.
57
+ That is all a developer needs to do. No RPC key, no math, no guessing.
61
58
 
62
59
  ---
63
60
 
@@ -65,12 +62,12 @@ That is all a developer needs to do. No RPC calls, no math, no guessing.
65
62
 
66
63
  ```ts
67
64
  const result = await estimateFee({
68
- speed: "fast", // "slow" | "medium" | "fast"
69
- strategy: "balanced", // "cheap" | "balanced" | "aggressive"
70
- 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
71
68
  transaction: myTransaction, // pass your actual tx for automatic protocol detection
72
- maxFee: 500_000, // optional cap in microLamports
73
- includeStats: true, // include full distribution in response
69
+ maxFee: 500_000, // optional cap in microLamports
70
+ includeStats: true, // include full distribution in response
74
71
  });
75
72
  ```
76
73
 
@@ -172,31 +169,23 @@ The `fee` value is in **microLamports per compute unit** — the exact unit that
172
169
 
173
170
  ```ts
174
171
  init({
175
- cluster: "mainnet-beta", // "mainnet-beta" | "devnet" (default: "mainnet-beta")
176
- rpcUrl: "https://your-rpc.com", // optional — overrides the cluster default
177
- cacheDurationMs: 7000, // how long to cache results in ms (default: 7000)
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)
178
175
  });
179
176
  ```
180
177
 
181
- ### Cluster RPC defaults
182
-
183
- | Cluster | Default RPC |
184
- | -------------- | ------------------------------------- |
185
- | `mainnet-beta` | `https://api.mainnet-beta.solana.com` |
186
- | `devnet` | `https://api.devnet.solana.com` |
187
-
188
- Or configure via `.env`:
178
+ You can also override the RPC via environment variables:
189
179
 
190
180
  ```env
191
- # Network: mainnet-beta (default) or devnet
192
- SOLANA_CLUSTER=mainnet-beta
181
+ # Optional: use your own RPC provider (overrides the built-in default)
182
+ SOLANA_RPC_URL=https://your-custom-rpc.com
193
183
 
194
- # Helius API key get one free at https://helius.dev
195
- # The base URL is set in code; only your key goes here
184
+ # Or use your own Helius API key
196
185
  HELIUS_API_KEY=your-api-key-here
197
186
 
198
- # Optional: use a different RPC provider entirely (overrides HELIUS_API_KEY)
199
- # SOLANA_RPC_URL=https://your-custom-rpc.com
187
+ # Network: mainnet-beta (default) or devnet
188
+ SOLANA_CLUSTER=mainnet-beta
200
189
 
201
190
  # How long to cache fee data in milliseconds (default: 7000)
202
191
  CACHE_DURATION_MS=7000
@@ -204,23 +193,13 @@ CACHE_DURATION_MS=7000
204
193
 
205
194
  ---
206
195
 
207
- ## RPC Recommendations
208
-
209
- The public Solana RPC endpoints rate-limit aggressively. For reliable results use a private RPC:
210
-
211
- - [Helius](https://helius.dev) — free tier available
212
- - [QuickNode](https://quicknode.com)
213
- - [Alchemy](https://alchemy.com)
214
-
215
- ---
216
-
217
196
  ## Project Structure
218
197
 
219
198
  ```
220
199
  src/
221
200
  ├── index.ts # SDK entry point — estimateFee() and init()
222
201
  ├── types.ts # TypeScript types and interfaces
223
- ├── config.ts # Configuration and cluster RPC resolution
202
+ ├── config.ts # Configuration and RPC resolution
224
203
  ├── protocols.ts # Known protocol registry (Jupiter, Raydium, etc.)
225
204
  ├── engine/
226
205
  │ └── feeCalculator.ts # Percentile math, strategy modifiers, outlier filtering
package/dist/config.js CHANGED
@@ -4,8 +4,8 @@ exports.CLUSTER_RPC = void 0;
4
4
  exports.init = init;
5
5
  exports.getConfig = getConfig;
6
6
  const CLUSTER_RPC = {
7
- "mainnet-beta": "https://api.mainnet-beta.solana.com",
8
- "devnet": "https://api.devnet.solana.com",
7
+ "mainnet-beta": "https://fema-rpc-proxy.fema-proxy.workers.dev",
8
+ "devnet": "https://fema-rpc-proxy.fema-proxy.workers.dev",
9
9
  };
10
10
  exports.CLUSTER_RPC = CLUSTER_RPC;
11
11
  const DEFAULT_CACHE_MS = 7000;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AA+BA,oBAIC;AAID,8BAEC;AAvCD,MAAM,WAAW,GAAkC;IACjD,cAAc,EAAE,qCAAqC;IACrD,QAAQ,EAAE,+BAA+B;CAC1C,CAAC;AAgCO,kCAAW;AA9BpB,MA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,14 @@
1
1
  {
2
2
  "name": "fema-pf-calc",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Intelligent Solana priority fee estimation engine",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
+ "types": "./dist/index.d.ts",
9
10
  "require": "./dist/index.js",
10
- "import": "./dist/index.js",
11
- "types": "./dist/index.d.ts"
11
+ "import": "./dist/index.js"
12
12
  }
13
13
  },
14
14
  "files": [