@zenx-labs/godl-supply 0.1.0 → 0.1.1

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 +102 -97
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @zenx-labs/godl-supply
2
2
 
3
- TypeScript SDK for interacting with the [GODL](https://godl.dev) on-chain program on Solana. Provides real-time WebSocket streaming, account fetching with caching, transaction building, and full type safety.
3
+ TypeScript SDK for interacting with the [GODL](https://godl.supply) on-chain program on Solana. Provides real-time WebSocket streaming, account fetching with caching, transaction building, and full type safety.
4
4
 
5
5
  ## Installation
6
6
 
@@ -11,30 +11,32 @@ npm install @zenx-labs/godl-supply
11
11
  ## Quick Start
12
12
 
13
13
  ```typescript
14
- import { GodlSupply } from '@zenx-labs/godl-supply'
14
+ import { GodlSupply } from "@zenx-labs/godl-supply";
15
15
 
16
16
  const sdk = new GodlSupply(signer, {
17
- rpcUrl: 'https://api.mainnet-beta.solana.com', // optional, defaults to public mainnet
18
- })
17
+ rpcUrl: "https://api.mainnet-beta.solana.com", // optional, defaults to public mainnet
18
+ });
19
19
 
20
20
  // Connect to real-time WebSocket stream
21
- await sdk.connect()
21
+ await sdk.connect();
22
22
 
23
23
  // Listen for events
24
- sdk.on('board', (board) => {
25
- console.log('Round:', board.roundId)
26
- })
24
+ sdk.on("board", (board) => {
25
+ console.log("Round:", board.roundId);
26
+ });
27
27
 
28
- sdk.on('treasury', (treasury) => {
29
- console.log('Balance:', treasury.balance)
30
- })
28
+ sdk.on("treasury", (treasury) => {
29
+ console.log("Balance:", treasury.balance);
30
+ });
31
31
 
32
32
  // Fetch account data (cached + RPC fallback)
33
- const board = await sdk.getBoard()
34
- const miner = await sdk.getMiner('68m3ocDFeJ1iQE9Pyu9Exn1HdpGcTgh12zpjWM7K8pKU')
33
+ const board = await sdk.getBoard();
34
+ const miner = await sdk.getMiner(
35
+ "68m3ocDFeJ1iQE9Pyu9Exn1HdpGcTgh12zpjWM7K8pKU",
36
+ );
35
37
 
36
38
  // Disconnect when done
37
- sdk.disconnect()
39
+ sdk.disconnect();
38
40
  ```
39
41
 
40
42
  ## Signer
@@ -42,25 +44,25 @@ sdk.disconnect()
42
44
  The SDK expects a `Signer` compatible with the [gill](https://github.com/solana-developers/gill) library:
43
45
 
44
46
  ```typescript
45
- import type { Signer } from '@zenx-labs/godl-supply'
47
+ import type { Signer } from "@zenx-labs/godl-supply";
46
48
 
47
49
  const signer: Signer = {
48
- address: address('YourPublicKey...'),
50
+ address: address("YourPublicKey..."),
49
51
  async signAndSendTransactions(transactions, config) {
50
52
  // Sign and submit transactions to the network
51
53
  },
52
- }
54
+ };
53
55
  ```
54
56
 
55
57
  ## Configuration
56
58
 
57
59
  ```typescript
58
60
  type GodlSupplyConfig = {
59
- rpcUrl?: string // Solana RPC endpoint (default: public mainnet)
60
- wsUrl?: string // GODL stream WebSocket URL (default: wss://stream.godl.dev/stream)
61
- streamApiUrl?: string // GODL stream REST API URL (default: https://stream.godl.dev)
62
- commitment?: 'confirmed' | 'finalized' | 'processed' // default: 'confirmed'
63
- }
61
+ rpcUrl?: string; // Solana RPC endpoint (default: public mainnet)
62
+ wsUrl?: string; // GODL stream WebSocket URL (default: wss://stream.godl.dev/stream)
63
+ streamApiUrl?: string; // GODL stream REST API URL (default: https://stream.godl.dev)
64
+ commitment?: "confirmed" | "finalized" | "processed"; // default: 'confirmed'
65
+ };
64
66
  ```
65
67
 
66
68
  ## API Reference
@@ -68,9 +70,9 @@ type GodlSupplyConfig = {
68
70
  ### Lifecycle
69
71
 
70
72
  ```typescript
71
- await sdk.connect() // Connect to WebSocket stream and sync initial state
72
- sdk.disconnect() // Disconnect and clear cache
73
- sdk.isConnected // boolean
73
+ await sdk.connect(); // Connect to WebSocket stream and sync initial state
74
+ sdk.disconnect(); // Disconnect and clear cache
75
+ sdk.isConnected; // boolean
74
76
  ```
75
77
 
76
78
  ### Events
@@ -79,42 +81,44 @@ The SDK emits typed events via WebSocket. Subscribe with `on()` and unsubscribe
79
81
 
80
82
  ```typescript
81
83
  // Subscribe
82
- const unsub = sdk.on('board', (board) => { /* ... */ })
84
+ const unsub = sdk.on("board", (board) => {
85
+ /* ... */
86
+ });
83
87
 
84
88
  // Unsubscribe
85
- unsub()
89
+ unsub();
86
90
  // or
87
- sdk.off('board', handler)
91
+ sdk.off("board", handler);
88
92
  ```
89
93
 
90
94
  #### Available Events
91
95
 
92
- | Event | Data Type | Description |
93
- |------------------|-----------------|------------------------------------------|
94
- | `board` | `Board` | Current board state (round info, slots) |
95
- | `round` | `Round` | Round deployment data and results |
96
- | `resetEvent` | `ResetEvent` | Round reset with winners and payouts |
97
- | `treasury` | `Treasury` | Treasury balances and reward factors |
98
- | `miner` | `Miner` | Your miner account updates |
99
- | `automation` | `Automation` | Your autominer account updates |
100
- | `slotData` | `SlotData` | Slot synchronization data |
101
- | `solMotherlode` | `SolMotherlode` | SOL motherlode amount |
102
- | `poolMember` | `PoolMember` | Your pool membership data |
103
- | `poolRound` | `PoolRound` | Pool round deployment data |
104
- | `slotTick` | `bigint` | Emitted every ~400ms with current slot |
105
- | `connected` | `boolean` | WebSocket connection state changes |
106
- | `error` | `Error` | WebSocket errors |
96
+ | Event | Data Type | Description |
97
+ | --------------- | --------------- | --------------------------------------- |
98
+ | `board` | `Board` | Current board state (round info, slots) |
99
+ | `round` | `Round` | Round deployment data and results |
100
+ | `resetEvent` | `ResetEvent` | Round reset with winners and payouts |
101
+ | `treasury` | `Treasury` | Treasury balances and reward factors |
102
+ | `miner` | `Miner` | Your miner account updates |
103
+ | `automation` | `Automation` | Your autominer account updates |
104
+ | `slotData` | `SlotData` | Slot synchronization data |
105
+ | `solMotherlode` | `SolMotherlode` | SOL motherlode amount |
106
+ | `poolMember` | `PoolMember` | Your pool membership data |
107
+ | `poolRound` | `PoolRound` | Pool round deployment data |
108
+ | `slotTick` | `bigint` | Emitted every ~400ms with current slot |
109
+ | `connected` | `boolean` | WebSocket connection state changes |
110
+ | `error` | `Error` | WebSocket errors |
107
111
 
108
112
  ### Slot Tracking
109
113
 
110
114
  The SDK maintains a local slot counter that increments every ~400ms after the initial sync from the WebSocket.
111
115
 
112
116
  ```typescript
113
- const currentSlot = sdk.getSlot()
117
+ const currentSlot = sdk.getSlot();
114
118
 
115
119
  const unsub = sdk.onSlotTick((slot) => {
116
- console.log('Slot:', slot)
117
- })
120
+ console.log("Slot:", slot);
121
+ });
118
122
  ```
119
123
 
120
124
  ### Account Getters
@@ -123,43 +127,44 @@ All account getters use a two-tier strategy: check the in-memory cache first (15
123
127
 
124
128
  ```typescript
125
129
  // Global state
126
- const board = await sdk.getBoard()
127
- const treasury = await sdk.getTreasury()
128
- const config = await sdk.getConfig()
130
+ const board = await sdk.getBoard();
131
+ const treasury = await sdk.getTreasury();
132
+ const config = await sdk.getConfig();
129
133
 
130
134
  // Per-user accounts (defaults to signer if no authority provided)
131
- const miner = await sdk.getMiner()
132
- const miner2 = await sdk.getMiner('SomeOtherPublicKey...')
133
- const automation = await sdk.getAutomation() // returns null if not set up
134
- const stake = await sdk.getStake()
135
- const stakeV2 = await sdk.getStakeV2(0n) // by stake ID
136
- const allStakes = await sdk.getStakeV2Accounts() // all StakeV2 accounts
135
+ const miner = await sdk.getMiner();
136
+ const miner2 = await sdk.getMiner("SomeOtherPublicKey...");
137
+ const automation = await sdk.getAutomation(); // returns null if not set up
138
+ const stake = await sdk.getStake();
139
+ const stakeV2 = await sdk.getStakeV2(0n); // by stake ID
140
+ const allStakes = await sdk.getStakeV2Accounts(); // all StakeV2 accounts
137
141
 
138
142
  // Round data
139
- const round = await sdk.getRound(42n) // returns null if not found
140
- const poolRound = await sdk.getPoolRound(42n)
143
+ const round = await sdk.getRound(42n); // returns null if not found
144
+ const poolRound = await sdk.getPoolRound(42n);
141
145
 
142
146
  // Pool and referral
143
- const poolMember = await sdk.getPoolMember() // returns null if not a member
144
- const referrer = await sdk.getReferrer() // returns null if not a referrer
147
+ const poolMember = await sdk.getPoolMember(); // returns null if not a member
148
+ const referrer = await sdk.getReferrer(); // returns null if not a referrer
145
149
  ```
146
150
 
147
151
  ### Mining
148
152
 
149
153
  ```typescript
150
154
  // Deploy to the board
155
+ // amount is lamports PER SQUARE — total SOL spent = amount × squares.length
151
156
  const sig = await sdk.deploy({
152
- amount: 100,
157
+ amount: 100, // 100 lamports per square (500 lamports total for 5 squares)
153
158
  squares: [0, 5, 12, 18, 24],
154
- varAddress: address('...'),
155
- isPooled: false, // optional, default: false
156
- })
159
+ varAddress: address("..."),
160
+ isPooled: false, // optional, default: false
161
+ });
157
162
 
158
163
  // Claim rewards
159
164
  const sig = await sdk.claim({
160
165
  claimSol: true,
161
166
  claimGodl: true,
162
- })
167
+ });
163
168
  ```
164
169
 
165
170
  ### Autominer
@@ -172,37 +177,37 @@ const sig = await sdk.setupAutominer({
172
177
  squares: [0, 5, 12, 18, 24],
173
178
  strategy: 1,
174
179
  numRounds: 10,
175
- claimAndFund: false, // optional
176
- isPooled: false, // optional
177
- })
180
+ claimAndFund: false, // optional
181
+ isPooled: false, // optional
182
+ });
178
183
 
179
184
  // Fund autominer
180
- const sig = await sdk.fundAutomation(1_000_000)
185
+ const sig = await sdk.fundAutomation(1_000_000);
181
186
 
182
187
  // Stop autominer
183
- const sig = await sdk.stopAutominer()
188
+ const sig = await sdk.stopAutominer();
184
189
  ```
185
190
 
186
191
  ### Staking
187
192
 
188
193
  ```typescript
189
194
  // V1 Staking
190
- const sig = await sdk.stakeDeposit(1_000_000n)
191
- const sig = await sdk.stakeWithdraw(500_000n)
192
- const sig = await sdk.stakeClaimYield(100_000n)
195
+ const sig = await sdk.stakeDeposit(1_000_000n);
196
+ const sig = await sdk.stakeWithdraw(500_000n);
197
+ const sig = await sdk.stakeClaimYield(100_000n);
193
198
 
194
199
  // V2 Staking (with lock duration and multiplier)
195
- const sig = await sdk.stakeV2Deposit(0n, 1_000_000n, 30n) // id, amount, lockDuration
196
- const sig = await sdk.stakeV2Withdraw(0n, 500_000n)
197
- const sig = await sdk.stakeV2ClaimYield(0n, 100_000n)
198
- const sig = await sdk.stakeV2CompoundYield(0n)
200
+ const sig = await sdk.stakeV2Deposit(0n, 1_000_000n, 30n); // id, amount, lockDuration
201
+ const sig = await sdk.stakeV2Withdraw(0n, 500_000n);
202
+ const sig = await sdk.stakeV2ClaimYield(0n, 100_000n);
203
+ const sig = await sdk.stakeV2CompoundYield(0n);
199
204
 
200
205
  // Set executor for V2 stake
201
- const sig = await sdk.setStakeExecutor(0n, address('executor...'))
206
+ const sig = await sdk.setStakeExecutor(0n, address("executor..."));
202
207
 
203
208
  // NFT boost
204
- const sig = await sdk.stakeNft(0n, address('nftAsset...'))
205
- const sig = await sdk.unstakeNft(0n, address('nftAsset...'))
209
+ const sig = await sdk.stakeNft(0n, address("nftAsset..."));
210
+ const sig = await sdk.unstakeNft(0n, address("nftAsset..."));
206
211
  ```
207
212
 
208
213
  ## Low-Level Instruction Builders
@@ -228,7 +233,7 @@ import {
228
233
  getSetStakeExecutorV2Instruction,
229
234
  getStakeNftInstruction,
230
235
  getUnstakeNftInstruction,
231
- } from '@zenx-labs/godl-supply'
236
+ } from "@zenx-labs/godl-supply";
232
237
  ```
233
238
 
234
239
  ## PDA Derivation
@@ -247,13 +252,13 @@ import {
247
252
  getStakeV2Pda,
248
253
  getPoolRoundPda,
249
254
  getPoolMemberPda,
250
- getGodlAta, // returns Promise<Address>
251
- } from '@zenx-labs/godl-supply'
255
+ getGodlAta, // returns Promise<Address>
256
+ } from "@zenx-labs/godl-supply";
252
257
 
253
- const [boardKey, bump] = getBoardPda()
254
- const [minerKey, bump] = getMinerPda(publicKey)
255
- const [stakeKey, bump] = getStakeV2Pda(publicKey, 0n)
256
- const ata = await getGodlAta(address('owner...'))
258
+ const [boardKey, bump] = getBoardPda();
259
+ const [minerKey, bump] = getMinerPda(publicKey);
260
+ const [stakeKey, bump] = getStakeV2Pda(publicKey, 0n);
261
+ const ata = await getGodlAta(address("owner..."));
257
262
  ```
258
263
 
259
264
  ## Advanced Usage
@@ -261,27 +266,27 @@ const ata = await getGodlAta(address('owner...'))
261
266
  The SDK exports internal components for custom integrations:
262
267
 
263
268
  ```typescript
264
- import { HotCache, SlotTracker, AccountFetcher } from '@zenx-labs/godl-supply'
269
+ import { HotCache, SlotTracker, AccountFetcher } from "@zenx-labs/godl-supply";
265
270
 
266
271
  // Custom cache with 5s TTL
267
- const cache = new HotCache(5_000)
272
+ const cache = new HotCache(5_000);
268
273
 
269
274
  // Direct account fetching without the full client
270
- const fetcher = new AccountFetcher(rpc, cache, 'https://stream.godl.dev')
271
- const initData = await fetcher.fetchInitData()
275
+ const fetcher = new AccountFetcher(rpc, cache, "https://stream.godl.dev");
276
+ const initData = await fetcher.fetchInitData();
272
277
  ```
273
278
 
274
279
  ## Constants
275
280
 
276
281
  ```typescript
277
282
  import {
278
- GODL_PROGRAM_ID, // Program public key
279
- GODL_MINT, // GODL token mint address
280
- ENTROPY_PROGRAM_ADDRESS, // Entropy program for randomness
281
- EXECUTOR_ADDRESS, // Autominer executor
282
- AUTOMATION_FEE, // Fee per automation round (30,000 lamports)
283
- NFT_BOOST_COLLECTION, // NFT collection for stake boosts
284
- } from '@zenx-labs/godl-supply'
283
+ GODL_PROGRAM_ID, // Program public key
284
+ GODL_MINT, // GODL token mint address
285
+ ENTROPY_PROGRAM_ADDRESS, // Entropy program for randomness
286
+ EXECUTOR_ADDRESS, // Autominer executor
287
+ AUTOMATION_FEE, // Fee per automation round (30,000 lamports)
288
+ NFT_BOOST_COLLECTION, // NFT collection for stake boosts
289
+ } from "@zenx-labs/godl-supply";
285
290
  ```
286
291
 
287
292
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenx-labs/godl-supply",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "TypeScript SDK for interacting with the GODL on-chain program",
5
5
  "license": "ISC",
6
6
  "author": "bootapollo",
@@ -23,7 +23,8 @@
23
23
  "build": "tsc",
24
24
  "dev": "tsc --watch",
25
25
  "test": "vitest run",
26
- "test:watch": "vitest"
26
+ "test:watch": "vitest",
27
+ "sniper": "npx tsx tests/ev-sniper.test.ts"
27
28
  },
28
29
  "dependencies": {
29
30
  "@msgpack/msgpack": "^3.1.2",