fema-pf-calc 1.0.1 → 1.0.3
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 +41 -35
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Supports **mainnet-beta** and **devnet**.
|
|
|
8
8
|
|
|
9
9
|
## The Problem
|
|
10
10
|
|
|
11
|
-
Every Solana transaction can include a priority fee
|
|
11
|
+
Every Solana transaction can include a priority fee, a tip paid to validators to land the transaction faster. Set it too low and your transaction gets stuck or dropped. Set it too high and you overpay.
|
|
12
12
|
|
|
13
13
|
The fee you need also depends on what kind of transaction you are sending. A Jupiter swap competes with other Jupiter swaps. An NFT mint competes with other NFT mints. They are not in the same queue, so they should not use the same fee.
|
|
14
14
|
|
|
@@ -65,30 +65,30 @@ That is all a developer needs to do. No RPC calls, no math, no guessing.
|
|
|
65
65
|
|
|
66
66
|
```ts
|
|
67
67
|
const result = await estimateFee({
|
|
68
|
-
speed:
|
|
69
|
-
strategy:
|
|
70
|
-
protocol:
|
|
71
|
-
transaction:
|
|
72
|
-
maxFee:
|
|
73
|
-
includeStats: true,
|
|
68
|
+
speed: "fast", // "slow" | "medium" | "fast"
|
|
69
|
+
strategy: "balanced", // "cheap" | "balanced" | "aggressive"
|
|
70
|
+
protocol: "jupiter", // see supported protocols below
|
|
71
|
+
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
|
|
74
74
|
});
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
### Speed
|
|
78
78
|
|
|
79
|
-
| Speed
|
|
80
|
-
|
|
81
|
-
| `slow`
|
|
82
|
-
| `medium` | p50
|
|
83
|
-
| `fast`
|
|
79
|
+
| Speed | Percentile | What it means |
|
|
80
|
+
| -------- | ---------- | --------------------------------------------------- |
|
|
81
|
+
| `slow` | p25 | Cheaper. May take a few blocks to land. |
|
|
82
|
+
| `medium` | p50 | Balanced. Lands within a couple of blocks. |
|
|
83
|
+
| `fast` | p75 | More expensive. Designed to land in the next block. |
|
|
84
84
|
|
|
85
85
|
### Strategy
|
|
86
86
|
|
|
87
|
-
| Strategy
|
|
88
|
-
|
|
89
|
-
| `cheap`
|
|
90
|
-
| `balanced`
|
|
91
|
-
| `aggressive` | +15 percentile points | Slightly overpay to guarantee landing.
|
|
87
|
+
| Strategy | Adjustment | What it means |
|
|
88
|
+
| ------------ | --------------------- | ------------------------------------------------------------------------- |
|
|
89
|
+
| `cheap` | −10 percentile points | Slightly undercut the target. Risk: might not land if the network spikes. |
|
|
90
|
+
| `balanced` | none | Hit the target exactly. Safe default for most use cases. |
|
|
91
|
+
| `aggressive` | +15 percentile points | Slightly overpay to guarantee landing. |
|
|
92
92
|
|
|
93
93
|
---
|
|
94
94
|
|
|
@@ -98,13 +98,19 @@ The most powerful feature of FEMA. When you specify a protocol, FEMA filters the
|
|
|
98
98
|
|
|
99
99
|
```ts
|
|
100
100
|
// Jupiter swap
|
|
101
|
-
const { fee: swapFee } = await estimateFee({
|
|
101
|
+
const { fee: swapFee } = await estimateFee({
|
|
102
|
+
speed: "fast",
|
|
103
|
+
protocol: "jupiter",
|
|
104
|
+
});
|
|
102
105
|
|
|
103
106
|
// NFT mint
|
|
104
107
|
const { fee: nftFee } = await estimateFee({ speed: "fast", protocol: "nft" });
|
|
105
108
|
|
|
106
109
|
// Pump.fun trade
|
|
107
|
-
const { fee: pumpFee } = await estimateFee({
|
|
110
|
+
const { fee: pumpFee } = await estimateFee({
|
|
111
|
+
speed: "fast",
|
|
112
|
+
protocol: "pumpfun",
|
|
113
|
+
});
|
|
108
114
|
```
|
|
109
115
|
|
|
110
116
|
Alternatively, pass your actual transaction and FEMA will detect the protocol automatically:
|
|
@@ -118,16 +124,16 @@ const { fee } = await estimateFee({
|
|
|
118
124
|
|
|
119
125
|
### Supported Protocols
|
|
120
126
|
|
|
121
|
-
| Protocol
|
|
122
|
-
|
|
123
|
-
| `jupiter`
|
|
124
|
-
| `raydium`
|
|
125
|
-
| `orca`
|
|
126
|
-
| `nft`
|
|
127
|
-
| `pumpfun`
|
|
128
|
-
| `openbook` | OpenBook V1, OpenBook V2
|
|
129
|
-
| `system`
|
|
130
|
-
| `token`
|
|
127
|
+
| Protocol | Programs Included |
|
|
128
|
+
| ---------- | --------------------------------------------------- |
|
|
129
|
+
| `jupiter` | Jupiter V4, Jupiter V6 |
|
|
130
|
+
| `raydium` | Raydium AMM V4, AMM V5, CLMM |
|
|
131
|
+
| `orca` | Orca Whirlpool, Orca V1 |
|
|
132
|
+
| `nft` | Token Metadata, Candy Machine V2/V3, Auction House |
|
|
133
|
+
| `pumpfun` | Pump.fun |
|
|
134
|
+
| `openbook` | OpenBook V1, OpenBook V2 |
|
|
135
|
+
| `system` | System Program (SOL transfers) |
|
|
136
|
+
| `token` | Token Program, Token 2022, Associated Token Program |
|
|
131
137
|
|
|
132
138
|
---
|
|
133
139
|
|
|
@@ -166,18 +172,18 @@ The `fee` value is in **microLamports per compute unit** — the exact unit that
|
|
|
166
172
|
|
|
167
173
|
```ts
|
|
168
174
|
init({
|
|
169
|
-
cluster:
|
|
170
|
-
rpcUrl:
|
|
171
|
-
cacheDurationMs: 7000,
|
|
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
178
|
});
|
|
173
179
|
```
|
|
174
180
|
|
|
175
181
|
### Cluster RPC defaults
|
|
176
182
|
|
|
177
|
-
| Cluster
|
|
178
|
-
|
|
183
|
+
| Cluster | Default RPC |
|
|
184
|
+
| -------------- | ------------------------------------- |
|
|
179
185
|
| `mainnet-beta` | `https://api.mainnet-beta.solana.com` |
|
|
180
|
-
| `devnet`
|
|
186
|
+
| `devnet` | `https://api.devnet.solana.com` |
|
|
181
187
|
|
|
182
188
|
Or configure via `.env`:
|
|
183
189
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fema-pf-calc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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
9
|
"require": "./dist/index.js",
|
|
10
|
+
"import": "./dist/index.js",
|
|
10
11
|
"types": "./dist/index.d.ts"
|
|
11
12
|
}
|
|
12
13
|
},
|