revm-sdk 0.1.0 → 0.2.0

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 +173 -0
  2. package/package.json +12 -3
package/README.md ADDED
@@ -0,0 +1,173 @@
1
+ # revm-sdk
2
+
3
+ TypeScript SDK for the REVM Ant Colony Optimization routing protocol on Solana.
4
+
5
+ Routes transactions through optimal validator paths using bio-inspired ACO algorithms, minimizing latency and MEV exposure.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install revm-sdk @solana/web3.js
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```typescript
16
+ import { RevmClient } from 'revm-sdk';
17
+ import { Connection, Keypair, Transaction, SystemProgram, LAMPORTS_PER_SOL } from '@solana/web3.js';
18
+
19
+ const client = new RevmClient({
20
+ rpcUrl: 'https://api.mainnet-beta.solana.com',
21
+ });
22
+
23
+ await client.initialize();
24
+
25
+ // Build your transaction
26
+ const tx = new Transaction().add(
27
+ SystemProgram.transfer({
28
+ fromPubkey: sender.publicKey,
29
+ toPubkey: receiver,
30
+ lamports: 0.01 * LAMPORTS_PER_SOL,
31
+ })
32
+ );
33
+
34
+ // Send with ACO-optimized routing
35
+ const result = await client.sendTransaction(
36
+ { transaction: tx },
37
+ { strategy: 'leader-lookahead' }
38
+ );
39
+
40
+ console.log(`Signature: ${result.signature}`);
41
+ console.log(`Latency: ${result.sendLatencyMs.toFixed(1)}ms`);
42
+ console.log(`Hops: ${result.hopCount}`);
43
+ console.log(`Target: ${result.targetValidator}`);
44
+ ```
45
+
46
+ ## Routing Strategies
47
+
48
+ | Strategy | Description |
49
+ |----------|-------------|
50
+ | `leader-lookahead` | Routes to the best of current + upcoming slot leaders (default) |
51
+ | `leader-only` | Routes directly to the current slot leader |
52
+ | `stake-weighted` | Routes to the highest-stake validator with the best ACO path |
53
+ | `full-colony` | Runs full colony optimization across all validators |
54
+
55
+ ```typescript
56
+ // Leader lookahead with 4 slots ahead
57
+ const result = await client.sendTransaction(
58
+ { transaction: tx },
59
+ { strategy: 'leader-lookahead', slotsAhead: 4 }
60
+ );
61
+
62
+ // Stake-weighted routing, top 10 validators
63
+ const result = await client.sendTransaction(
64
+ { transaction: tx },
65
+ { strategy: 'stake-weighted', topN: 10 }
66
+ );
67
+ ```
68
+
69
+ ## ACO Configuration
70
+
71
+ ```typescript
72
+ const client = new RevmClient({
73
+ rpcUrl: 'https://api.mainnet-beta.solana.com',
74
+ acoConfig: {
75
+ alpha: 1.2, // Pheromone influence
76
+ beta: 3.0, // Latency heuristic influence
77
+ evaporationRate: 0.25, // Pheromone decay per iteration
78
+ antCount: 32, // Ants per iteration
79
+ maxIterations: 50, // Max ACO iterations
80
+ },
81
+ });
82
+ ```
83
+
84
+ ## API Reference
85
+
86
+ ### RevmClient
87
+
88
+ #### `new RevmClient(config: RevmClientConfig)`
89
+
90
+ Creates a new REVM client instance.
91
+
92
+ #### `client.initialize(): Promise<void>`
93
+
94
+ Fetches validator data and builds the ACO routing topology. Must be called before sending transactions.
95
+
96
+ #### `client.sendTransaction(payload, options?): Promise<SendResult>`
97
+
98
+ Sends a transaction using ACO-optimized routing.
99
+
100
+ **Payload:**
101
+ - `transaction` — `Transaction | VersionedTransaction`
102
+ - `skipPreflight?` — Skip preflight simulation (default: `false`)
103
+ - `maxRetries?` — Max send retries (default: `3`)
104
+
105
+ **Options:**
106
+ - `strategy?` — Routing strategy (default: `'leader-lookahead'`)
107
+ - `slotsAhead?` — Slots to look ahead for leaders (default: `2`)
108
+ - `topN?` — Top N validators for stake-weighted (default: `5`)
109
+
110
+ **Returns `SendResult`:**
111
+ - `signature` — Transaction signature
112
+ - `targetValidator` — Selected validator pubkey
113
+ - `sendLatencyMs` — Send latency in milliseconds
114
+ - `hopCount` — Number of hops in the route
115
+ - `slot` — Current slot
116
+ - `confirmed` — Confirmation status
117
+
118
+ #### `client.confirmTransaction(signature, timeout?): Promise<boolean>`
119
+
120
+ Waits for transaction confirmation.
121
+
122
+ #### `client.getMetrics(): ColonyMetrics`
123
+
124
+ Returns routing performance metrics.
125
+
126
+ #### `client.getValidators(): ValidatorNode[]`
127
+
128
+ Returns the current validator topology.
129
+
130
+ ### AcoRouter
131
+
132
+ Standalone ACO router for custom routing logic.
133
+
134
+ ```typescript
135
+ import { AcoRouter } from 'revm-sdk';
136
+
137
+ const router = new AcoRouter(10, {
138
+ alpha: 1.2,
139
+ beta: 3.0,
140
+ evaporationRate: 0.25,
141
+ antCount: 32,
142
+ maxIterations: 50,
143
+ });
144
+
145
+ router.setEdge(0, 1, 5.0); // node 0 -> node 1, 5ms latency
146
+ router.setEdge(0, 2, 8.0);
147
+ router.setEdge(1, 3, 3.0);
148
+ router.setEdge(2, 3, 2.0);
149
+
150
+ const result = router.route(0, 3);
151
+ // { path: [0, 2, 3], cost: 10.0, hopCount: 2, iterationsUsed: 15 }
152
+ ```
153
+
154
+ ## Companion Crate
155
+
156
+ The core ACO engine is written in Rust for maximum performance:
157
+
158
+ ```bash
159
+ cargo add revm-core
160
+ ```
161
+
162
+ See [revm-core on crates.io](https://crates.io/crates/revm-core) for the Rust implementation.
163
+
164
+ ## Links
165
+
166
+ - [Website](https://revm.io)
167
+ - [Whitepaper](https://revm.io/whitepaper)
168
+ - [GitHub](https://github.com/revmdotio/revm-core)
169
+ - [crates.io](https://crates.io/crates/revm-core)
170
+
171
+ ## License
172
+
173
+ MIT
package/package.json CHANGED
@@ -1,16 +1,25 @@
1
1
  {
2
2
  "name": "revm-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "TypeScript SDK for REVM ACO routing protocol on Solana",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "files": ["dist"],
7
+ "files": [
8
+ "dist"
9
+ ],
8
10
  "scripts": {
9
11
  "build": "tsc",
10
12
  "test": "jest",
11
13
  "prepublishOnly": "npm run build"
12
14
  },
13
- "keywords": ["solana", "routing", "aco", "transaction", "optimization", "ant-colony"],
15
+ "keywords": [
16
+ "solana",
17
+ "routing",
18
+ "aco",
19
+ "transaction",
20
+ "optimization",
21
+ "ant-colony"
22
+ ],
14
23
  "license": "MIT",
15
24
  "repository": {
16
25
  "type": "git",