@craftec/flowcraft-sdk 0.1.9 → 0.1.11
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 +23 -243
- package/dist/client.d.ts +37 -42
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +110 -133
- package/dist/client.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -2
- package/dist/constants.js.map +1 -1
- package/dist/idl.json +378 -448
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +19 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +5 -5
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +14 -14
- package/dist/utils.js.map +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -8,57 +8,7 @@ SDK for Flowcraft subscription streaming protocol on Solana.
|
|
|
8
8
|
npm install @craftec/flowcraft-sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
Flowcraft is a subscription streaming protocol where payments vest linearly over time.
|
|
14
|
-
|
|
15
|
-
### Core Concepts
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
Pool (Creator)
|
|
19
|
-
└── Stream (per Subscriber)
|
|
20
|
-
└── Segments (sequential vesting periods)
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
- **Pool**: Created by content creators. Subscribers pay into the pool's vault.
|
|
24
|
-
- **Stream**: One per subscriber per pool. Tracks subscriber's payment history.
|
|
25
|
-
- **Segment**: A vesting period with amount, duration, and rate. Segments vest sequentially.
|
|
26
|
-
|
|
27
|
-
### Vesting Model
|
|
28
|
-
|
|
29
|
-
Segments vest **sequentially**, not in parallel:
|
|
30
|
-
|
|
31
|
-
```
|
|
32
|
-
Segment 0: $100 over 30 days [vesting...]
|
|
33
|
-
Segment 1: $50 over 15 days [queued]
|
|
34
|
-
Segment 2: $200 over 60 days [queued]
|
|
35
|
-
|
|
36
|
-
Timeline: [--- Seg 0 (30d) ---][- Seg 1 (15d) -][------ Seg 2 (60d) ------]
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Each segment has:
|
|
40
|
-
- `amount`: Total tokens to vest
|
|
41
|
-
- `ratePerSecond`: Vesting rate (amount * RATE_DECIMALS / duration)
|
|
42
|
-
- `vested`: Already vested amount (updated on-chain periodically)
|
|
43
|
-
- `cancelled`: Whether segment was cancelled (unvested refunded)
|
|
44
|
-
|
|
45
|
-
### Account Structure (PDAs)
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
// Config (global, one per program)
|
|
49
|
-
seeds = ["config"]
|
|
50
|
-
|
|
51
|
-
// Pool
|
|
52
|
-
seeds = ["pool", owner.pubkey, pool_name]
|
|
53
|
-
|
|
54
|
-
// Vault (token account owned by pool)
|
|
55
|
-
seeds = ["vault", pool.pubkey]
|
|
56
|
-
|
|
57
|
-
// Stream
|
|
58
|
-
seeds = ["stream", pool.pubkey, subscriber.pubkey]
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Quick Start
|
|
11
|
+
## Usage
|
|
62
12
|
|
|
63
13
|
```typescript
|
|
64
14
|
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
@@ -76,8 +26,8 @@ const { signature, pool, vault } = await client.createPool(payer, owner, {
|
|
|
76
26
|
mint: mintPubkey,
|
|
77
27
|
});
|
|
78
28
|
|
|
79
|
-
// Subscribe to a pool
|
|
80
|
-
const { signature, stream
|
|
29
|
+
// Subscribe to a pool
|
|
30
|
+
const { signature, stream } = await client.subscribe(subscriber, {
|
|
81
31
|
pool: poolPubkey,
|
|
82
32
|
tier: "monthly",
|
|
83
33
|
amount: 100_000_000, // in smallest units
|
|
@@ -86,18 +36,7 @@ const { signature, stream, segmentIndex } = await client.subscribe(subscriber, {
|
|
|
86
36
|
treasuryTokenAccount,
|
|
87
37
|
});
|
|
88
38
|
|
|
89
|
-
//
|
|
90
|
-
const { signature, segmentIndex } = await client.addSegment(payer, {
|
|
91
|
-
pool: poolPubkey,
|
|
92
|
-
stream: streamPubkey,
|
|
93
|
-
tier: "monthly",
|
|
94
|
-
amount: 100_000_000,
|
|
95
|
-
durationSeconds: 30 * 24 * 60 * 60,
|
|
96
|
-
payerTokenAccount,
|
|
97
|
-
treasuryTokenAccount,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Calculate real-time vested amount (off-chain)
|
|
39
|
+
// Calculate vested amount (off-chain)
|
|
101
40
|
const stats = await client.getPoolAggregateStats(poolPubkey);
|
|
102
41
|
console.log("Total Vested:", stats.totalVested.toString());
|
|
103
42
|
console.log("Claimable:", stats.totalClaimable.toString());
|
|
@@ -110,8 +49,10 @@ const { transactions, totalStreams } = await client.buildClaimAllTransactions(
|
|
|
110
49
|
20 // batch size
|
|
111
50
|
);
|
|
112
51
|
|
|
113
|
-
// Sign
|
|
52
|
+
// Sign all transactions at once
|
|
114
53
|
const signed = await wallet.signAllTransactions(transactions);
|
|
54
|
+
|
|
55
|
+
// Send in parallel
|
|
115
56
|
await Promise.all(signed.map(tx => connection.sendTransaction(tx)));
|
|
116
57
|
```
|
|
117
58
|
|
|
@@ -121,200 +62,39 @@ await Promise.all(signed.map(tx => connection.sendTransaction(tx)));
|
|
|
121
62
|
|
|
122
63
|
Main client class for interacting with the Flowcraft protocol.
|
|
123
64
|
|
|
124
|
-
#### Constructor
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
const client = new FlowcraftClient(
|
|
128
|
-
connection: Connection,
|
|
129
|
-
wallet: Wallet,
|
|
130
|
-
programId?: PublicKey, // defaults to PROGRAM_ID
|
|
131
|
-
idl?: Idl // defaults to bundled IDL
|
|
132
|
-
);
|
|
133
|
-
```
|
|
134
|
-
|
|
135
65
|
#### Pool Operations
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
| `fetchPool(pool)` | Fetch raw pool account data |
|
|
141
|
-
| `getPoolInfo(pool)` | Get pool with computed info |
|
|
142
|
-
| `getPoolAggregateStats(pool)` | Get aggregate vesting stats for all streams |
|
|
143
|
-
| `fetchStreamsByPool(pool)` | Fetch all streams for a pool |
|
|
66
|
+
- `createPool(payer, owner, params)` - Create a new subscription pool
|
|
67
|
+
- `fetchPool(pool)` - Fetch pool data
|
|
68
|
+
- `getPoolInfo(pool)` - Get pool with computed info
|
|
69
|
+
- `getPoolAggregateStats(pool)` - Get aggregate vesting stats for all streams
|
|
144
70
|
|
|
145
71
|
#### Subscription Operations
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
| `addSegment(payer, params)` | Add a new segment to existing stream |
|
|
151
|
-
| `upgradeSegment(caller, params)` | Upgrade/downgrade a segment's rate |
|
|
152
|
-
| `cancelSegment(subscriber, params)` | Cancel a segment (refunds unvested) |
|
|
72
|
+
- `subscribe(subscriber, params)` - Subscribe to a pool
|
|
73
|
+
- `addSegment(payer, params)` - Add a new segment to existing subscription
|
|
74
|
+
- `upgradeSegment(subscriber, params)` - Upgrade/downgrade a segment
|
|
75
|
+
- `cancelSegment(subscriber, params)` - Cancel a segment
|
|
153
76
|
|
|
154
77
|
#### Claiming
|
|
78
|
+
- `claim(owner, params)` - Claim from single stream
|
|
79
|
+
- `claimBatch(owner, params)` - Claim from multiple streams in one tx
|
|
80
|
+
- `buildClaimAllTransactions(...)` - Build batch claim txs for all streams
|
|
155
81
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
| `claimBatch(owner, params)` | Claim from multiple streams in one tx |
|
|
160
|
-
| `buildClaimAllTransactions(...)` | Build batch claim txs for all pool streams |
|
|
161
|
-
|
|
162
|
-
#### Stream Queries
|
|
163
|
-
|
|
164
|
-
| Method | Description |
|
|
165
|
-
|--------|-------------|
|
|
166
|
-
| `fetchStream(stream)` | Fetch raw stream account data |
|
|
167
|
-
| `getStreamInfo(stream)` | Get stream with on-chain vested values |
|
|
168
|
-
| `getStreamInfoRealTime(stream)` | Get stream with real-time vesting calculation |
|
|
169
|
-
| `getRealTimeClaimable(stream)` | Get current claimable amount |
|
|
170
|
-
|
|
171
|
-
### PDA Helpers
|
|
172
|
-
|
|
173
|
-
Derive program addresses:
|
|
174
|
-
|
|
175
|
-
```typescript
|
|
176
|
-
import { getConfigPda, getPoolPda, getVaultPda, getStreamPda } from "@craftec/flowcraft-sdk";
|
|
177
|
-
|
|
178
|
-
// Config PDA (global)
|
|
179
|
-
const [configPda, configBump] = getConfigPda(programId);
|
|
180
|
-
|
|
181
|
-
// Pool PDA
|
|
182
|
-
const [poolPda, poolBump] = getPoolPda(ownerPubkey, "pool-name", programId);
|
|
183
|
-
|
|
184
|
-
// Vault PDA (token account)
|
|
185
|
-
const [vaultPda, vaultBump] = getVaultPda(poolPubkey, programId);
|
|
186
|
-
|
|
187
|
-
// Stream PDA
|
|
188
|
-
const [streamPda, streamBump] = getStreamPda(poolPubkey, subscriberPubkey, programId);
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Vesting Utilities
|
|
192
|
-
|
|
193
|
-
Calculate vesting off-chain (real-time, without on-chain calls):
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
import { calculateStreamVesting, calculateSegmentVested } from "@craftec/flowcraft-sdk";
|
|
197
|
-
|
|
198
|
-
// Calculate entire stream's vesting state
|
|
199
|
-
const stream = await client.fetchStream(streamPubkey);
|
|
200
|
-
const vesting = calculateStreamVesting(stream);
|
|
201
|
-
console.log("Total Deposited:", vesting.totalDeposited.toString());
|
|
202
|
-
console.log("Total Vested:", vesting.totalVested.toString());
|
|
203
|
-
console.log("Claimable:", vesting.claimable.toString());
|
|
204
|
-
console.log("Is Expired:", vesting.isExpired);
|
|
205
|
-
|
|
206
|
-
// Calculate single segment's vested amount
|
|
207
|
-
const segmentVested = calculateSegmentVested(
|
|
208
|
-
segment, // { amount, vested, ratePerSecond, cancelled }
|
|
209
|
-
lastUpdateTime, // BN - stream.lastUpdateTime
|
|
210
|
-
currentTime // number - current unix timestamp
|
|
211
|
-
);
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### Upgrade/Downgrade
|
|
215
|
-
|
|
216
|
-
Tier changes are **cost-based**, not name-based. The protocol only cares about the price difference:
|
|
217
|
-
|
|
218
|
-
```typescript
|
|
219
|
-
// Upgrade: new_cost > unvested (user pays difference)
|
|
220
|
-
// Downgrade: new_cost < unvested (user gets refund)
|
|
221
|
-
|
|
222
|
-
await client.upgradeSegment(caller, {
|
|
223
|
-
pool: poolPubkey,
|
|
224
|
-
stream: streamPubkey,
|
|
225
|
-
subscriber: subscriberPubkey,
|
|
226
|
-
segmentIndex: 0,
|
|
227
|
-
newAmount: 200_000_000, // new total for remaining duration
|
|
228
|
-
newDuration: 30 * 24 * 60 * 60,
|
|
229
|
-
callerTokenAccount, // pays if upgrade
|
|
230
|
-
payerTokenAccount, // receives refund if downgrade
|
|
231
|
-
});
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
**Note:** Only the subscriber can downgrade (receive refund). Anyone can upgrade (pay more).
|
|
235
|
-
|
|
236
|
-
### Cancellation
|
|
237
|
-
|
|
238
|
-
Cancel a segment to stop vesting and refund unvested tokens:
|
|
239
|
-
|
|
240
|
-
```typescript
|
|
241
|
-
await client.cancelSegment(subscriber, {
|
|
242
|
-
pool: poolPubkey,
|
|
243
|
-
stream: streamPubkey,
|
|
244
|
-
segmentIndex: 0,
|
|
245
|
-
refundTokenAccount, // receives unvested tokens
|
|
246
|
-
});
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
- Vested amount stays claimable by pool owner
|
|
250
|
-
- Unvested amount refunded to original segment payer
|
|
251
|
-
- Cancelled segments are skipped in vesting calculation
|
|
82
|
+
#### Utilities
|
|
83
|
+
- `getStreamInfoRealTime(stream)` - Get stream with real-time vesting calculation
|
|
84
|
+
- `getRealTimeClaimable(stream)` - Get current claimable amount
|
|
252
85
|
|
|
253
86
|
## Constants
|
|
254
87
|
|
|
255
88
|
```typescript
|
|
256
|
-
import { PROGRAM_ID, RATE_DECIMALS
|
|
89
|
+
import { PROGRAM_ID, RATE_DECIMALS } from "@craftec/flowcraft-sdk";
|
|
257
90
|
|
|
258
91
|
// Program ID (devnet/mainnet)
|
|
259
92
|
console.log(PROGRAM_ID.toBase58());
|
|
260
|
-
// 3T8z77gRqyW6KZQBHf1ah2uKABh9vc5rSTaD595U2wm9
|
|
261
93
|
|
|
262
94
|
// Rate decimals for vesting calculation (10^9)
|
|
263
|
-
console.log(RATE_DECIMALS);
|
|
264
|
-
// 1000000000n
|
|
265
|
-
|
|
266
|
-
// Maximum segments per stream
|
|
267
|
-
console.log(MAX_SEGMENTS);
|
|
268
|
-
// 100
|
|
95
|
+
console.log(RATE_DECIMALS); // 1000000000
|
|
269
96
|
```
|
|
270
97
|
|
|
271
|
-
## Types
|
|
272
|
-
|
|
273
|
-
```typescript
|
|
274
|
-
import type {
|
|
275
|
-
Pool,
|
|
276
|
-
Stream,
|
|
277
|
-
Segment,
|
|
278
|
-
StreamInfo,
|
|
279
|
-
SegmentInfo,
|
|
280
|
-
PoolInfo,
|
|
281
|
-
PoolAggregateStats,
|
|
282
|
-
CreatePoolParams,
|
|
283
|
-
SubscribeParams,
|
|
284
|
-
AddSegmentParams,
|
|
285
|
-
UpgradeSegmentParams,
|
|
286
|
-
CancelSegmentParams,
|
|
287
|
-
ClaimParams,
|
|
288
|
-
} from "@craftec/flowcraft-sdk";
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
## Browser/Mobile Usage
|
|
292
|
-
|
|
293
|
-
The SDK uses `Keypair` for signing which works in Node.js. For browser/mobile, use the IDL directly with your wallet adapter:
|
|
294
|
-
|
|
295
|
-
```typescript
|
|
296
|
-
import { Program } from "@coral-xyz/anchor";
|
|
297
|
-
import { IDL, PROGRAM_ID } from "@craftec/flowcraft-sdk";
|
|
298
|
-
|
|
299
|
-
// Create program with your wallet adapter's provider
|
|
300
|
-
const program = new Program(IDL, PROGRAM_ID, provider);
|
|
301
|
-
|
|
302
|
-
// Build transaction
|
|
303
|
-
const tx = await program.methods
|
|
304
|
-
.subscribe(tier, amount, duration)
|
|
305
|
-
.accounts({
|
|
306
|
-
subscriber: wallet.publicKey,
|
|
307
|
-
pool: poolPubkey,
|
|
308
|
-
// ... other accounts
|
|
309
|
-
})
|
|
310
|
-
.transaction();
|
|
311
|
-
|
|
312
|
-
// Sign with wallet adapter
|
|
313
|
-
await walletAdapter.signAndSendTransaction(tx);
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
Use SDK utilities for PDA derivation and vesting calculations - they work everywhere.
|
|
317
|
-
|
|
318
98
|
## License
|
|
319
99
|
|
|
320
100
|
MIT
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Connection, PublicKey, Keypair } from "@solana/web3.js";
|
|
2
2
|
import { Program, AnchorProvider, Wallet, BN, Idl } from "@coral-xyz/anchor";
|
|
3
|
-
import { Config, Pool,
|
|
3
|
+
import { Config, Pool, Stream, PoolInfo, StreamInfo, PoolAggregateStats, StreamWithAddress, CreatePoolParams, SubscribeParams, AddSegmentParams, ClaimParams, CancelSegmentParams, UpgradeSegmentParams } from "./types";
|
|
4
4
|
export declare const IDL: Idl;
|
|
5
5
|
export declare class FlowcraftClient {
|
|
6
6
|
readonly program: Program;
|
|
@@ -16,9 +16,9 @@ export declare class FlowcraftClient {
|
|
|
16
16
|
*/
|
|
17
17
|
getPoolPda(owner: PublicKey, name: string): [PublicKey, number];
|
|
18
18
|
/**
|
|
19
|
-
* Get the
|
|
19
|
+
* Get the stream PDA for a pool and subscriber
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
getStreamPda(pool: PublicKey, subscriber: PublicKey): [PublicKey, number];
|
|
22
22
|
/**
|
|
23
23
|
* Get the vault PDA for a pool
|
|
24
24
|
*/
|
|
@@ -36,21 +36,21 @@ export declare class FlowcraftClient {
|
|
|
36
36
|
*/
|
|
37
37
|
fetchPoolByOwner(owner: PublicKey, name: string): Promise<Pool | null>;
|
|
38
38
|
/**
|
|
39
|
-
* Fetch a
|
|
39
|
+
* Fetch a stream by address
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
fetchStream(stream: PublicKey): Promise<Stream | null>;
|
|
42
42
|
/**
|
|
43
|
-
* Fetch a
|
|
43
|
+
* Fetch a stream by pool and subscriber
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
fetchStreamBySubscriber(pool: PublicKey, subscriber: PublicKey): Promise<Stream | null>;
|
|
46
46
|
/**
|
|
47
47
|
* Fetch pool with computed info
|
|
48
48
|
*/
|
|
49
49
|
getPoolInfo(pool: PublicKey): Promise<PoolInfo | null>;
|
|
50
50
|
/**
|
|
51
|
-
* Fetch
|
|
51
|
+
* Fetch stream with computed info
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
getStreamInfo(stream: PublicKey): Promise<StreamInfo | null>;
|
|
54
54
|
/**
|
|
55
55
|
* Initialize the protocol config (one-time setup)
|
|
56
56
|
*/
|
|
@@ -60,7 +60,7 @@ export declare class FlowcraftClient {
|
|
|
60
60
|
*/
|
|
61
61
|
updateConfig(admin: Keypair, newTreasury?: PublicKey, newFeeBps?: number, newAdmin?: PublicKey): Promise<string>;
|
|
62
62
|
/**
|
|
63
|
-
* Create a new pool
|
|
63
|
+
* Create a new subscription pool
|
|
64
64
|
* @param payer - Keypair that pays for rent (signs the transaction)
|
|
65
65
|
* @param owner - PublicKey of pool owner (can be any account, including PDA)
|
|
66
66
|
* @param params - Pool creation parameters
|
|
@@ -71,83 +71,78 @@ export declare class FlowcraftClient {
|
|
|
71
71
|
vault: PublicKey;
|
|
72
72
|
}>;
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* For new passes, segmentIndex is 0. For reactivated expired passes, segments are cleared so index is also 0.
|
|
74
|
+
* Subscribe to a pool (creates stream with first segment)
|
|
76
75
|
*/
|
|
77
|
-
|
|
76
|
+
subscribe(subscriber: Keypair, params: SubscribeParams): Promise<{
|
|
78
77
|
signature: string;
|
|
79
|
-
|
|
80
|
-
segmentIndex: number;
|
|
78
|
+
stream: PublicKey;
|
|
81
79
|
}>;
|
|
82
80
|
/**
|
|
83
|
-
* Add a new segment to an existing
|
|
81
|
+
* Add a new segment to an existing subscription
|
|
84
82
|
*/
|
|
85
|
-
addSegment(payer: Keypair, params: AddSegmentParams): Promise<
|
|
86
|
-
signature: string;
|
|
87
|
-
segmentIndex: number;
|
|
88
|
-
}>;
|
|
83
|
+
addSegment(payer: Keypair, params: AddSegmentParams): Promise<string>;
|
|
89
84
|
/**
|
|
90
85
|
* Claim vested tokens (pool owner only)
|
|
91
86
|
*/
|
|
92
87
|
claim(owner: Keypair, params: ClaimParams): Promise<string>;
|
|
93
88
|
/**
|
|
94
|
-
* Claim vested tokens from multiple
|
|
89
|
+
* Claim vested tokens from multiple streams in a single transaction
|
|
95
90
|
*/
|
|
96
91
|
claimBatch(owner: Keypair, params: {
|
|
97
92
|
pool: PublicKey;
|
|
98
|
-
|
|
93
|
+
streams: PublicKey[];
|
|
99
94
|
ownerTokenAccount: PublicKey;
|
|
100
95
|
}): Promise<string>;
|
|
101
96
|
/**
|
|
102
|
-
* Build batch claim transactions for all
|
|
97
|
+
* Build batch claim transactions for all streams in a pool
|
|
103
98
|
* Returns transactions ready to be signed with signAllTransactions
|
|
104
99
|
*/
|
|
105
100
|
buildClaimAllTransactions(owner: PublicKey, pool: PublicKey, ownerTokenAccount: PublicKey, batchSize?: number): Promise<{
|
|
106
101
|
transactions: any[];
|
|
107
|
-
|
|
102
|
+
totalStreams: number;
|
|
108
103
|
}>;
|
|
109
104
|
/**
|
|
110
|
-
* Cancel a segment (
|
|
105
|
+
* Cancel a segment (subscriber only)
|
|
111
106
|
*/
|
|
112
|
-
cancelSegment(
|
|
107
|
+
cancelSegment(subscriber: Keypair, params: CancelSegmentParams): Promise<string>;
|
|
113
108
|
/**
|
|
114
|
-
*
|
|
109
|
+
* Upgrade or downgrade a segment
|
|
115
110
|
*/
|
|
116
|
-
|
|
111
|
+
upgradeSegment(caller: Keypair, params: UpgradeSegmentParams): Promise<string>;
|
|
117
112
|
/**
|
|
118
113
|
* Check if a pool exists
|
|
119
114
|
*/
|
|
120
115
|
poolExists(owner: PublicKey, name: string): Promise<boolean>;
|
|
121
116
|
/**
|
|
122
|
-
* Check if a
|
|
117
|
+
* Check if a subscription stream exists
|
|
123
118
|
*/
|
|
124
|
-
|
|
119
|
+
subscriptionExists(pool: PublicKey, subscriber: PublicKey): Promise<boolean>;
|
|
125
120
|
/**
|
|
126
|
-
* Get claimable amount for a
|
|
121
|
+
* Get claimable amount for a stream
|
|
127
122
|
*/
|
|
128
|
-
getClaimable(
|
|
123
|
+
getClaimable(stream: PublicKey): Promise<BN>;
|
|
129
124
|
/**
|
|
130
|
-
* Check if
|
|
125
|
+
* Check if subscription is expired
|
|
131
126
|
*/
|
|
132
|
-
|
|
127
|
+
isSubscriptionExpired(stream: PublicKey): Promise<boolean>;
|
|
133
128
|
/**
|
|
134
|
-
* Fetch all
|
|
135
|
-
*
|
|
129
|
+
* Fetch all streams for a pool using getProgramAccounts
|
|
130
|
+
* Stream account layout: [8 discriminator][32 pool][32 subscriber]...
|
|
136
131
|
* Filter by pool pubkey at offset 8
|
|
137
132
|
*/
|
|
138
|
-
|
|
133
|
+
fetchStreamsByPool(pool: PublicKey): Promise<StreamWithAddress[]>;
|
|
139
134
|
/**
|
|
140
135
|
* Calculate real-time aggregate statistics for a pool
|
|
141
|
-
* Fetches all
|
|
136
|
+
* Fetches all streams and calculates vesting off-chain
|
|
142
137
|
*/
|
|
143
138
|
getPoolAggregateStats(pool: PublicKey): Promise<PoolAggregateStats>;
|
|
144
139
|
/**
|
|
145
|
-
* Get real-time claimable amount for a
|
|
140
|
+
* Get real-time claimable amount for a stream (calculated off-chain)
|
|
146
141
|
*/
|
|
147
|
-
getRealTimeClaimable(
|
|
142
|
+
getRealTimeClaimable(streamAddress: PublicKey): Promise<BN>;
|
|
148
143
|
/**
|
|
149
|
-
* Get detailed
|
|
144
|
+
* Get detailed stream info with real-time vesting calculation
|
|
150
145
|
*/
|
|
151
|
-
|
|
146
|
+
getStreamInfoRealTime(streamAddress: PublicKey): Promise<StreamInfo | null>;
|
|
152
147
|
}
|
|
153
148
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,OAAO,EAER,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,OAAO,EACP,cAAc,EACd,MAAM,EACN,EAAE,EACF,GAAG,EACJ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,MAAM,EACN,IAAI,EACJ,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,OAAO,EAER,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,OAAO,EACP,cAAc,EACd,MAAM,EACN,EAAE,EACF,GAAG,EACJ,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,MAAM,EACN,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,UAAU,EAEV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAYjB,eAAO,MAAM,GAAG,EAAE,GAAqB,CAAC;AAExC,qBAAa,eAAe;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;gB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