@streamflow/stream 12.1.1 → 12.2.1-alpha.p361.abedd84

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.
@@ -0,0 +1,1114 @@
1
+ import { SignerWalletAdapter } from '@solana/wallet-adapter-base';
2
+ import { PublicKey, AccountInfo, VersionedTransaction, Commitment, ConnectionConfig, Connection, Keypair, TransactionInstruction, TransactionSignature, BlockhashWithExpiryBlockHeight, Context } from '@solana/web3.js';
3
+ import { ICluster, ITransactionExt, IProgramAccount, ComputeLimitEstimate, ComputePriceEstimate } from '@streamflow/common';
4
+ import BN from 'bn.js';
5
+ import { IdlAccounts, Address, IdlTypes, Program } from '@coral-xyz/anchor';
6
+ import PQueue from 'p-queue';
7
+ import { StreamflowAlignedUnlocks } from './solana/descriptor/streamflow_aligned_unlocks.js';
8
+
9
+ interface IRecipient {
10
+ recipient: string;
11
+ amount: BN;
12
+ name: string;
13
+ cliffAmount: BN;
14
+ amountPerPeriod: BN;
15
+ nonce?: number;
16
+ }
17
+ interface IBaseStreamConfig {
18
+ period: number;
19
+ start: number;
20
+ cliff: number;
21
+ cancelableBySender: boolean;
22
+ cancelableByRecipient: boolean;
23
+ transferableBySender: boolean;
24
+ transferableByRecipient: boolean;
25
+ canTopup: boolean;
26
+ automaticWithdrawal?: boolean;
27
+ withdrawalFrequency?: number;
28
+ tokenId: string;
29
+ canPause?: boolean;
30
+ canUpdateRate?: boolean;
31
+ partner?: string;
32
+ partnerLink?: {
33
+ address: string;
34
+ isSigner: boolean;
35
+ };
36
+ tokenProgramId?: string | PublicKey;
37
+ }
38
+ type IAlignedStreamConfig = {
39
+ minPrice: number | BN;
40
+ maxPrice: number | BN;
41
+ minPercentage: number | BN;
42
+ maxPercentage: number | BN;
43
+ oracleType?: OracleTypeName;
44
+ priceOracle?: Address;
45
+ skipInitial?: boolean;
46
+ tickSize?: number;
47
+ expiryTime?: number;
48
+ expiryPercentage?: number | BN;
49
+ floorPrice?: number | BN;
50
+ };
51
+ type ICreateLinearStreamData = IBaseStreamConfig & IRecipient;
52
+ type ICreateAlignedStreamData = ICreateLinearStreamData & IAlignedStreamConfig;
53
+ type ICreateStreamData = ICreateLinearStreamData | ICreateAlignedStreamData;
54
+ type ICreateMultipleLinearStreamData = IBaseStreamConfig & {
55
+ recipients: IRecipient[];
56
+ };
57
+ type ICreateMultipleAlignedStreamData = ICreateMultipleLinearStreamData & IAlignedStreamConfig;
58
+ type ICreateMultipleStreamData = ICreateMultipleLinearStreamData | ICreateMultipleAlignedStreamData;
59
+ interface IInteractData {
60
+ id: string;
61
+ }
62
+ interface IWithdrawData extends IInteractData {
63
+ amount?: BN;
64
+ }
65
+ interface IUpdateData extends IInteractData {
66
+ enableAutomaticWithdrawal?: boolean;
67
+ withdrawFrequency?: BN;
68
+ amountPerPeriod?: BN;
69
+ transferableBySender?: boolean;
70
+ transferableByRecipient?: boolean;
71
+ cancelableBySender?: boolean;
72
+ }
73
+ type ICancelData = IInteractData;
74
+ type IRequestCancelData = IInteractData;
75
+ type IWithdrawCancelRequestData = IInteractData;
76
+ interface ITransferData extends IInteractData {
77
+ newRecipient: string;
78
+ }
79
+ interface ITopUpData extends IInteractData {
80
+ amount: BN;
81
+ }
82
+ type IGetOneData = IInteractData;
83
+ interface IGetFeesData {
84
+ address: string;
85
+ }
86
+ interface IGetAllData {
87
+ address: string;
88
+ type?: StreamType;
89
+ direction?: StreamDirection;
90
+ filters?: {
91
+ closed?: boolean;
92
+ };
93
+ }
94
+ interface ICreateMultiError {
95
+ recipient: string;
96
+ error: string;
97
+ contractErrorCode?: string;
98
+ }
99
+ type MetadataId = string;
100
+ interface ITransactionResult {
101
+ ixs: TransactionInstruction[];
102
+ txId: string;
103
+ }
104
+ /**
105
+ * Schema outlining vesting protocol fees.
106
+ */
107
+ interface IFees {
108
+ creationFeeSol?: number;
109
+ autoClaimFeeSol?: number;
110
+ streamflowFee: number;
111
+ partnerFee: number;
112
+ }
113
+ interface ICreateResult extends ITransactionResult {
114
+ metadataId: MetadataId;
115
+ }
116
+ interface IMultiTransactionResult {
117
+ txs: string[];
118
+ metadatas: MetadataId[];
119
+ metadataToRecipient: Record<MetadataId, IRecipient>;
120
+ errors: ICreateMultiError[];
121
+ }
122
+ type OracleTypeName = "none" | "pyth" | "switchboard" | "test";
123
+ declare enum StreamDirection {
124
+ Outgoing = "outgoing",
125
+ Incoming = "incoming",
126
+ All = "all"
127
+ }
128
+ declare enum StreamType {
129
+ All = "all",
130
+ Vesting = "vesting",
131
+ Lock = "lock"
132
+ }
133
+ interface LinearStream {
134
+ isAligned: boolean;
135
+ magic: number;
136
+ version: number;
137
+ createdAt: number;
138
+ withdrawnAmount: BN;
139
+ canceledAt: number;
140
+ end: number;
141
+ lastWithdrawnAt: number;
142
+ sender: string;
143
+ senderTokens: string;
144
+ recipient: string;
145
+ recipientTokens: string;
146
+ mint: string;
147
+ escrowTokens: string;
148
+ streamflowTreasury: string;
149
+ streamflowTreasuryTokens: string;
150
+ streamflowFeeTotal: BN;
151
+ streamflowFeeWithdrawn: BN;
152
+ streamflowFeePercent: number;
153
+ partnerFeeTotal: BN;
154
+ partnerFeeWithdrawn: BN;
155
+ partnerFeePercent: number;
156
+ partner: string;
157
+ partnerTokens: string;
158
+ start: number;
159
+ depositedAmount: BN;
160
+ period: number;
161
+ amountPerPeriod: BN;
162
+ cliff: number;
163
+ cliffAmount: BN;
164
+ cancelableBySender: boolean;
165
+ cancelableByRecipient: boolean;
166
+ automaticWithdrawal: boolean;
167
+ transferableBySender: boolean;
168
+ transferableByRecipient: boolean;
169
+ canTopup: boolean;
170
+ name: string;
171
+ withdrawalFrequency: number;
172
+ isPda: boolean;
173
+ nonce: number;
174
+ closed: boolean;
175
+ currentPauseStart: number;
176
+ pauseCumulative: BN;
177
+ lastRateChangeTime: number;
178
+ fundsUnlockedAtLastRateChange: BN;
179
+ oldMetadata: PublicKey;
180
+ payer: string;
181
+ bump: number;
182
+ feePartner: string;
183
+ cancelRequestTime: number;
184
+ type: StreamType;
185
+ unlocked(currentTimestamp: number): BN;
186
+ remaining(decimals: number): number;
187
+ }
188
+ type AlignedStreamData = {
189
+ minPrice: number;
190
+ maxPrice: number;
191
+ minPercentage: number;
192
+ maxPercentage: number;
193
+ oracleType: OracleTypeName;
194
+ priceOracle: string | undefined;
195
+ tickSize: number;
196
+ initialAmountPerPeriod: BN;
197
+ initialPrice: number;
198
+ lastPrice: number;
199
+ lastAmountUpdateTime: number;
200
+ initialNetAmount: BN;
201
+ expiryTime: number;
202
+ expiryPercentage: number;
203
+ floorPrice: number;
204
+ };
205
+ type AlignedStream = LinearStream & AlignedStreamData;
206
+ type Stream = LinearStream | AlignedStream;
207
+ /**
208
+ * Error codes raised by Solana protocol specifically
209
+ */
210
+ declare enum ContractErrorCode {
211
+ /** Accounts not writable */
212
+ AccountsNotWritable = "AccountsNotWritable",
213
+ /** Invalid Metadata */
214
+ InvalidMetadata = "InvalidMetadata",
215
+ /** Invalid metadata account */
216
+ InvalidMetadataAccount = "InvalidMetadataAccount",
217
+ /** Provided accounts don't match the ones in contract */
218
+ MetadataAccountMismatch = "MetadataAccountMismatch",
219
+ /** Invalid escrow account */
220
+ InvalidEscrowAccount = "InvalidEscrowAccount",
221
+ /** Provided account(s) is/are not valid associated token accounts */
222
+ NotAssociated = "NotAssociated",
223
+ /** Sender mint does not match accounts mint */
224
+ MintMismatch = "MintMismatch",
225
+ /** Recipient not transferable for account */
226
+ TransferNotAllowed = "TransferNotAllowed",
227
+ /** Contract closed */
228
+ ContractClosed = "ContractClosed",
229
+ /** Invalid Streamflow Treasury accounts supplied */
230
+ InvalidTreasury = "InvalidTreasury",
231
+ /** Given timestamps are invalid */
232
+ InvalidTimestamps = "InvalidTimestamps",
233
+ /** Invalid deposit configuration */
234
+ InvalidDepositConfiguration = "InvalidDepositConfiguration",
235
+ /** Amount cannot be zero */
236
+ AmountIsZero = "AmountIsZero",
237
+ /** Amount requested is larger than available */
238
+ AmountMoreThanAvailable = "AmountMoreThanAvailable",
239
+ /** Amount currently available is zero */
240
+ AmountAvailableIsZero = "AmountAvailableIsZero",
241
+ /** Arithmetic error */
242
+ ArithmeticError = "ArithmeticError",
243
+ /** Metadata account data must be 1104 bytes long */
244
+ InvalidMetadataSize = "InvalidMetadataSize",
245
+ /** Metadata state account must be initialized */
246
+ UninitializedMetadata = "UninitializedMetadata",
247
+ /** Authority does not have permission for this action */
248
+ Unauthorized = "Unauthorized",
249
+ /** Contract is not transferable to the original recipient */
250
+ SelfTransfer = "SelfTransfer",
251
+ /** Contract is already paused */
252
+ AlreadyPaused = "AlreadyPaused",
253
+ /** Contract is not paused */
254
+ NotPaused = "NotPaused",
255
+ /** Meta account is not rent exempt */
256
+ MetadataNotRentExempt = "MetadataNotRentExempt"
257
+ }
258
+ declare enum AlignedProxyErrorCode {
259
+ /** Authority does not have permission for this action */
260
+ Unauthorized = "Unauthorized",
261
+ /** Arithmetic error */
262
+ ArithmeticError = "ArithmeticError",
263
+ /** Mint has unsupported Token Extensions */
264
+ UnsupportedTokenExtensions = "UnsupportedTokenExtensions",
265
+ /** Provided period is too short, should be equal or more than 30 seconds */
266
+ PeriodTooShort = "PeriodTooShort",
267
+ /** Provided percentage tick size is invalid */
268
+ InvalidTickSize = "InvalidTickSize",
269
+ /** Provided percentage bounds are invalid */
270
+ InvalidPercentageBoundaries = "InvalidPercentageBoundaries",
271
+ /** Provided price bounds are invalid */
272
+ InvalidPriceBoundaries = "InvalidPriceBoundaries",
273
+ /** Unsupported price oracle */
274
+ UnsupportedOracle = "UnsupportedOracle",
275
+ /** Invalid oracle account */
276
+ InvalidOracleAccount = "InvalidOracleAccount",
277
+ /** Invalid oracle price */
278
+ InvalidOraclePrice = "InvalidOraclePrice",
279
+ /** Invalid Stream Metadata */
280
+ InvalidStreamMetadata = "InvalidStreamMetadata",
281
+ /** Release amount has already been updated in this period */
282
+ AmountAlreadyUpdated = "AmountAlreadyUpdated",
283
+ /** All funds are already unlocked */
284
+ AllFundsUnlocked = "AllFundsUnlocked"
285
+ }
286
+ /**
287
+ * @interface
288
+ */
289
+ interface TransactionSchedulingOptions {
290
+ /**
291
+ * concurrency rate for scheduling
292
+ */
293
+ sendRate: number;
294
+ /**
295
+ * time interval between consecutive sends
296
+ */
297
+ sendInterval?: number;
298
+ /**
299
+ * time interval before confirming the transaction
300
+ */
301
+ waitBeforeConfirming?: number;
302
+ }
303
+ /**
304
+ * @interface
305
+ */
306
+ interface StreamClientOptions {
307
+ clusterUrl: string;
308
+ cluster?: ICluster;
309
+ programId?: string;
310
+ commitment?: Commitment | ConnectionConfig;
311
+ sendRate?: number;
312
+ sendThrottler?: PQueue;
313
+ sendScheduler?: PQueue | TransactionSchedulingOptions;
314
+ }
315
+ /**
316
+ * StreamClient options that accept a pre-existing Connection instance.
317
+ * Useful when you already have a connection (e.g. shared across multiple clients)
318
+ * and want to avoid creating a duplicate one internally.
319
+ */
320
+ interface StreamClientOptionsWithConnection {
321
+ connection: Connection;
322
+ cluster: ICluster;
323
+ commitment?: Commitment | ConnectionConfig;
324
+ programId?: string;
325
+ sendScheduler?: PQueue | TransactionSchedulingOptions;
326
+ }
327
+ type AlignedUnlocksTypes = IdlTypes<StreamflowAlignedUnlocks>;
328
+ type AlignedUnlocksAccounts = IdlAccounts<StreamflowAlignedUnlocks>;
329
+ type AlignedUnlocksContract = AlignedUnlocksAccounts["contract"];
330
+ type OracleType = IdlTypes<StreamflowAlignedUnlocks>["oracleType"];
331
+ type TestOracle = AlignedUnlocksAccounts["testOracle"];
332
+ type CreateParams = AlignedUnlocksTypes["createParams"];
333
+ type ChangeOracleParams = AlignedUnlocksTypes["changeOracleParams"];
334
+ type CreateTestOracleParams = AlignedUnlocksTypes["createTestOracleParams"];
335
+ type UpdateTestOracleParams = AlignedUnlocksTypes["updateTestOracleParams"];
336
+ interface ISearchStreams {
337
+ mint?: string;
338
+ sender?: string;
339
+ recipient?: string;
340
+ closed?: boolean;
341
+ }
342
+ interface Account {
343
+ pubkey: PublicKey;
344
+ account: AccountInfo<Buffer>;
345
+ }
346
+ interface ICreateExt {
347
+ sender: SignerWalletAdapter | Keypair;
348
+ isNative?: boolean;
349
+ }
350
+ interface ITransactionExtWithInstructions extends ITransactionExt {
351
+ customInstructions?: {
352
+ after?: InstructionGenerator;
353
+ };
354
+ }
355
+ interface ICreateStreamExt extends ICreateExt, ITransactionExtWithInstructions {
356
+ metadataPubKeys?: PublicKey[];
357
+ partner?: string | null;
358
+ }
359
+ interface IPrepareCreateStreamExt extends Omit<ICreateStreamExt, "sender"> {
360
+ sender: {
361
+ publicKey: PublicKey | null;
362
+ };
363
+ }
364
+ interface IInteractStreamExt extends ITransactionExtWithInstructions {
365
+ invoker: SignerWalletAdapter | Keypair;
366
+ checkTokenAccounts?: boolean;
367
+ }
368
+ interface IPrepareStreamExt extends Omit<IInteractStreamExt, "invoker"> {
369
+ invoker: {
370
+ publicKey: PublicKey | null;
371
+ };
372
+ }
373
+ interface IPrepareTopUpstreamExt extends ITransactionExt {
374
+ invoker: {
375
+ publicKey: PublicKey | null;
376
+ };
377
+ isNative?: boolean;
378
+ }
379
+ interface ITopUpStreamExt extends IPrepareTopUpstreamExt {
380
+ invoker: SignerWalletAdapter | Keypair;
381
+ }
382
+ interface ICreateStreamInstructions {
383
+ ixs: TransactionInstruction[];
384
+ metadata: Keypair | undefined;
385
+ metadataPubKey: PublicKey;
386
+ }
387
+ declare class Contract implements LinearStream {
388
+ magic: number;
389
+ version: number;
390
+ createdAt: number;
391
+ withdrawnAmount: BN;
392
+ canceledAt: number;
393
+ end: number;
394
+ lastWithdrawnAt: number;
395
+ sender: string;
396
+ senderTokens: string;
397
+ recipient: string;
398
+ recipientTokens: string;
399
+ mint: string;
400
+ escrowTokens: string;
401
+ streamflowTreasury: string;
402
+ streamflowTreasuryTokens: string;
403
+ streamflowFeeTotal: BN;
404
+ streamflowFeeWithdrawn: BN;
405
+ streamflowFeePercent: number;
406
+ partnerFeeTotal: BN;
407
+ partnerFeeWithdrawn: BN;
408
+ partnerFeePercent: number;
409
+ partner: string;
410
+ partnerTokens: string;
411
+ start: number;
412
+ depositedAmount: BN;
413
+ period: number;
414
+ amountPerPeriod: BN;
415
+ cliff: number;
416
+ cliffAmount: BN;
417
+ cancelableBySender: boolean;
418
+ cancelableByRecipient: boolean;
419
+ automaticWithdrawal: boolean;
420
+ transferableBySender: boolean;
421
+ transferableByRecipient: boolean;
422
+ canTopup: boolean;
423
+ name: string;
424
+ withdrawalFrequency: number;
425
+ isPda: boolean;
426
+ nonce: number;
427
+ closed: boolean;
428
+ currentPauseStart: number;
429
+ pauseCumulative: BN;
430
+ lastRateChangeTime: number;
431
+ fundsUnlockedAtLastRateChange: BN;
432
+ oldMetadata: PublicKey;
433
+ payer: string;
434
+ bump: number;
435
+ feePartner: string;
436
+ cancelRequestTime: number;
437
+ type: StreamType;
438
+ isAligned: boolean;
439
+ constructor(stream: DecodedStream);
440
+ unlocked(currentTimestamp: number): BN;
441
+ remaining(decimals: number): number;
442
+ }
443
+ declare class AlignedContract extends Contract implements AlignedStream {
444
+ minPrice: number;
445
+ maxPrice: number;
446
+ minPercentage: number;
447
+ maxPercentage: number;
448
+ tickSize: number;
449
+ proxyAddress: string;
450
+ priceOracle: string | undefined;
451
+ oracleType: OracleTypeName;
452
+ initialAmountPerPeriod: BN;
453
+ initialPrice: number;
454
+ lastPrice: number;
455
+ lastAmountUpdateTime: number;
456
+ initialNetAmount: BN;
457
+ expiryTime: number;
458
+ expiryPercentage: number;
459
+ floorPrice: number;
460
+ constructor(stream: DecodedStream, alignedProxy: AlignedUnlocksContract);
461
+ }
462
+ interface DecodedStream {
463
+ magic: BN;
464
+ version: BN;
465
+ createdAt: BN;
466
+ withdrawnAmount: BN;
467
+ canceledAt: BN;
468
+ end: BN;
469
+ lastWithdrawnAt: BN;
470
+ sender: PublicKey;
471
+ senderTokens: PublicKey;
472
+ recipient: PublicKey;
473
+ recipientTokens: PublicKey;
474
+ mint: PublicKey;
475
+ escrowTokens: PublicKey;
476
+ streamflowTreasury: PublicKey;
477
+ streamflowTreasuryTokens: PublicKey;
478
+ streamflowFeeTotal: BN;
479
+ streamflowFeeWithdrawn: BN;
480
+ streamflowFeePercent: number;
481
+ partnerFeeTotal: BN;
482
+ partnerFeeWithdrawn: BN;
483
+ partnerFeePercent: number;
484
+ partner: PublicKey;
485
+ partnerTokens: PublicKey;
486
+ start: BN;
487
+ depositedAmount: BN;
488
+ period: BN;
489
+ amountPerPeriod: BN;
490
+ cliff: BN;
491
+ cliffAmount: BN;
492
+ cancelableBySender: boolean;
493
+ cancelableByRecipient: boolean;
494
+ automaticWithdrawal: boolean;
495
+ transferableBySender: boolean;
496
+ transferableByRecipient: boolean;
497
+ canTopup: boolean;
498
+ name: string;
499
+ withdrawFrequency: BN;
500
+ isPda: boolean;
501
+ nonce: number;
502
+ closed: boolean;
503
+ currentPauseStart: BN;
504
+ pauseCumulative: BN;
505
+ lastRateChangeTime: BN;
506
+ fundsUnlockedAtLastRateChange: BN;
507
+ oldMetadata: PublicKey;
508
+ payer: PublicKey;
509
+ bump: number;
510
+ feePartner: PublicKey;
511
+ cancelRequestTime: BN;
512
+ }
513
+ interface MetadataRecipientHashMap {
514
+ [metadataPubKey: string]: IRecipient;
515
+ }
516
+ interface BatchItem {
517
+ recipient: string;
518
+ tx: VersionedTransaction;
519
+ }
520
+ interface BatchItemSuccess extends BatchItem {
521
+ signature: string;
522
+ }
523
+ interface BatchItemError extends BatchItem {
524
+ error: string;
525
+ }
526
+ type BatchItemResult = BatchItemSuccess | BatchItemError;
527
+ type InstructionGenerator = TransactionInstruction[] | ((params: {
528
+ instructions: TransactionInstruction[];
529
+ metadata?: PublicKey;
530
+ }) => TransactionInstruction[] | Promise<TransactionInstruction[]>);
531
+
532
+ /**
533
+ * Solana Client creation options
534
+ * @property cluster {@link ICluster} cluster type
535
+ * @property clusterUrl cluster url
536
+ * @interface ClientCreationOptions
537
+ */
538
+ type ClientCreationOptions = Omit<StreamClientOptions, "sendRate" | "sendThrottler"> | StreamClientOptionsWithConnection;
539
+ declare class SolanaStreamClient {
540
+ private readonly connection;
541
+ private readonly programId;
542
+ private readonly partnerOracleProgramId;
543
+ private readonly feeOraclePublicKey;
544
+ private readonly commitment;
545
+ readonly alignedProxyProgram: Program<StreamflowAlignedUnlocks>;
546
+ private readonly schedulingParams;
547
+ private readonly apiClient;
548
+ /**
549
+ * Create Stream instance with flat arguments
550
+ */
551
+ constructor(clusterUrl: string, cluster?: ICluster, commitment?: Commitment | ConnectionConfig, programId?: string, sendRate?: number, sendThrottler?: PQueue);
552
+ /**
553
+ * Create Stream instance with options
554
+ */
555
+ constructor(options: ClientCreationOptions);
556
+ getConnection(): Connection;
557
+ getCommitment(): Commitment | undefined;
558
+ getProgramId(): string;
559
+ getAlignedProxyProgramId(): string;
560
+ /**
561
+ * Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
562
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
563
+ *
564
+ * For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
565
+ * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
566
+ *
567
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
568
+ * @param {Omit<ICreateStreamExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
569
+ * @returns Transaction instructions and metadata ID
570
+ */
571
+ buildCreateTransactionInstructions(data: ICreateStreamData, extParams: IPrepareCreateStreamExt): Promise<{
572
+ ixs: TransactionInstruction[];
573
+ metadataId: string;
574
+ metadata?: Keypair;
575
+ }>;
576
+ /**
577
+ * Builds a transaction for creating a new stream/vesting contract without signing or executing it.
578
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
579
+ *
580
+ * For native SOL (isNative: true), SOL wrapping instructions are automatically included in the correct order
581
+ * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
582
+ *
583
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
584
+ * @param {Omit<ICreateStreamExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
585
+ * @returns Transaction and metadata information
586
+ */
587
+ buildCreateTransaction(data: ICreateStreamData, extParams: IPrepareCreateStreamExt): Promise<{
588
+ tx: VersionedTransaction;
589
+ metadataId: string;
590
+ metadata?: Keypair;
591
+ hash: string;
592
+ context: any;
593
+ }>;
594
+ /**
595
+ * Creates a new stream/vesting contract.
596
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
597
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
598
+ * @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
599
+ * @returns Create result
600
+ */
601
+ create(data: ICreateStreamData, extParams: ICreateStreamExt): Promise<ICreateResult>;
602
+ prepareCreateInstructions(streamParams: ICreateStreamData, extParams: IPrepareCreateStreamExt): Promise<ICreateStreamInstructions>;
603
+ /**
604
+ * Builds instructions for creating an aligned unlock stream.
605
+ * For Token-2022 mints with a transfer hook, partner link and hook accounts are appended as remaining accounts.
606
+ */
607
+ prepareCreateAlignedUnlockInstructions(streamParams: ICreateAlignedStreamData, extParams: IPrepareCreateStreamExt): Promise<ICreateStreamInstructions>;
608
+ /**
609
+ * Creates a new stream/vesting contract.
610
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
611
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
612
+ * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
613
+ * @returns Create stream instructions
614
+ */
615
+ prepareCreateLinearStreamInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, partnerLink, tokenProgramId: streamTokenProgramId, nonce, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: IPrepareCreateStreamExt): Promise<ICreateStreamInstructions>;
616
+ /**
617
+ * Creates a new stream/vesting contract using unchecked instruction.
618
+ *
619
+ * Unchecked instruction differs from the regular in:
620
+ * - does not check for initialized associated token account (wallets with no control over their ATA should not be used
621
+ * as sender/recipient/partner or there are risks of funds being locked in the contract)
622
+ * - initialized contract PDA off chain
623
+ *
624
+ * If you are not sure if you should use create or create_unchecked, go for create to be safer.
625
+ * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
626
+ * @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
627
+ * @returns Create result
628
+ */
629
+ createUnchecked(data: ICreateStreamData, extParams: ICreateStreamExt): Promise<ICreateResult>;
630
+ /**
631
+ * Create Transaction instructions for `createUnchecked`
632
+ */
633
+ prepareCreateUncheckedInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canTopup, canUpdateRate, canPause, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, partnerLink, nonce, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: IPrepareCreateStreamExt): Promise<{
634
+ ixs: TransactionInstruction[];
635
+ metadata: Keypair | undefined;
636
+ metadataPubKey: PublicKey;
637
+ }>;
638
+ /**
639
+ * Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
640
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
641
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
642
+ * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
643
+ * @returns Create multiple transaction instructions
644
+ */
645
+ buildCreateMultipleTransactionInstructions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt, applyCustomAfterInstructions?: boolean): Promise<{
646
+ instructionsBatch: {
647
+ ixs: TransactionInstruction[];
648
+ metadata: Keypair | undefined;
649
+ recipient: string;
650
+ }[];
651
+ metadatas: string[];
652
+ metadataToRecipient: MetadataRecipientHashMap;
653
+ prepareInstructions: TransactionInstruction[];
654
+ }>;
655
+ /**
656
+ * Builds multiple transactions for creating stream/vesting contracts without signing or executing them.
657
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
658
+ *
659
+ * IMPORTANT: When using native SOL (isNative: true), you MUST execute the prepareTx FIRST and wait for confirmation
660
+ * before executing the stream creation transactions. Otherwise, stream creation will fail with "InvalidAccountData".
661
+ *
662
+ * @example
663
+ * ```typescript
664
+ * const result = await streamClient.buildCreateMultipleTransactions(data, { isNative: true, senderPublicKey });
665
+ *
666
+ * // CRITICAL: Execute prepareTx first if it exists
667
+ * if (result.prepareTx) {
668
+ * await connection.sendAndConfirmTransaction(result.prepareTx, [signer]);
669
+ * }
670
+ *
671
+ * // Only then execute stream creation transactions
672
+ * for (const item of result.transactions) {
673
+ * await connection.sendAndConfirmTransaction(item.tx, [signer]);
674
+ * }
675
+ * ```
676
+ *
677
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
678
+ * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
679
+ * @returns Multiple transaction information
680
+ */
681
+ buildCreateMultipleTransactions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt, applyCustomAfterInstructions?: boolean): Promise<{
682
+ transactions: BatchItem[];
683
+ metadatas: string[];
684
+ metadataToRecipient: MetadataRecipientHashMap;
685
+ hash: Readonly<{
686
+ blockhash: string;
687
+ lastValidBlockHeight: number;
688
+ }>;
689
+ context: any;
690
+ prepareTx?: VersionedTransaction;
691
+ }>;
692
+ /**
693
+ * Creates multiple stream/vesting contracts.
694
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
695
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
696
+ * @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
697
+ * @returns Multiple transaction information
698
+ */
699
+ createMultiple(data: ICreateMultipleStreamData[] | ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
700
+ /**
701
+ * Creates multiple stream/vesting contracts, and send all transactions sequentially.
702
+ * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
703
+ * In most cases, createMultiple should be used instead.
704
+ * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
705
+ * @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
706
+ * @returns Multiple transaction information
707
+ */
708
+ createMultipleSequential(data: ICreateMultipleStreamData[] | ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
709
+ /**
710
+ * Attempts withdrawing from the specified stream.
711
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
712
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
713
+ * @returns Transaction result
714
+ */
715
+ withdraw({ id, amount }: IWithdrawData, extParams: IInteractStreamExt): Promise<ITransactionResult>;
716
+ /**
717
+ * Creates Transaction Instructions for withdrawal
718
+ * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
719
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
720
+ * @returns Transaction instructions
721
+ */
722
+ prepareWithdrawInstructions({ id, amount }: IWithdrawData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
723
+ /**
724
+ * Attempts canceling the specified stream.
725
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
726
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
727
+ * @returns Transaction result
728
+ */
729
+ cancel(cancelData: ICancelData, extParams: IInteractStreamExt): Promise<ITransactionResult>;
730
+ /**
731
+ * Creates Transaction Instructions for cancel
732
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
733
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
734
+ * @returns Transaction instructions
735
+ */
736
+ prepareCancelInstructions(cancelData: ICancelData, extParams: IPrepareStreamExt): Promise<TransactionInstruction[]>;
737
+ /**
738
+ * Creates Transaction Instructions for cancel
739
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
740
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
741
+ * @returns Transaction instructions
742
+ */
743
+ prepareCancelAlignedUnlockInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
744
+ /**
745
+ * Creates Transaction Instructions for cancel
746
+ * @param {ICancelData} cancelData - Cancellation parameters including stream ID
747
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
748
+ * @returns Transaction instructions
749
+ */
750
+ prepareCancelLinearStream({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
751
+ /**
752
+ * Requests cancellation of a stream by the fee partner authority.
753
+ * @param {IRequestCancelData} data - Request cancel parameters including stream ID
754
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
755
+ * @returns Transaction result
756
+ */
757
+ requestCancel(data: IRequestCancelData, extParams: IInteractStreamExt): Promise<ITransactionResult>;
758
+ /**
759
+ * Creates Transaction Instructions for request_cancel
760
+ * @param {IRequestCancelData} data - Request cancel parameters including stream ID
761
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
762
+ * @returns Transaction instructions
763
+ */
764
+ prepareRequestCancelInstructions({ id }: IRequestCancelData, { invoker, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
765
+ /**
766
+ * Withdraws a previously submitted cancel request.
767
+ * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
768
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
769
+ * @returns Transaction result
770
+ */
771
+ withdrawCancelRequest(data: IWithdrawCancelRequestData, extParams: IInteractStreamExt): Promise<ITransactionResult>;
772
+ /**
773
+ * Creates Transaction Instructions for withdraw_cancel_request
774
+ * @param {IWithdrawCancelRequestData} data - Withdraw cancel request parameters including stream ID
775
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
776
+ * @returns Transaction instructions
777
+ */
778
+ prepareWithdrawCancelRequestInstructions({ id }: IWithdrawCancelRequestData, { invoker, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
779
+ /**
780
+ * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
781
+ * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
782
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
783
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
784
+ * @returns Transaction result
785
+ */
786
+ transfer({ id, newRecipient }: ITransferData, extParams: IInteractStreamExt): Promise<ITransactionResult>;
787
+ /**
788
+ * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
789
+ * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
790
+ * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
791
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
792
+ * @returns Transaction instructions
793
+ */
794
+ prepareTransferInstructions({ id, newRecipient }: ITransferData, { invoker, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
795
+ /**
796
+ * Tops up stream account with specified amount.
797
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
798
+ * @param {ITopUpStreamExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
799
+ * @returns Transaction result
800
+ */
801
+ topup({ id, amount }: ITopUpData, extParams: ITopUpStreamExt): Promise<ITransactionResult>;
802
+ /**
803
+ * Create Transaction instructions for topup
804
+ * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
805
+ * @param {ITopUpStreamExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
806
+ * @returns Transaction instructions
807
+ */
808
+ prepareTopupInstructions({ id, amount }: ITopUpData, { invoker, isNative, computePrice, computeLimit }: IPrepareTopUpstreamExt): Promise<TransactionInstruction[]>;
809
+ /**
810
+ * Fetch stream data by its id (address).
811
+ * @param {IGetOneData} getData - Query parameters containing the stream ID to fetch
812
+ * @returns Stream data
813
+ */
814
+ getOne({ id }: IGetOneData): Promise<Stream>;
815
+ private decodeStreamAccount;
816
+ /**
817
+ * Fetch all aligned outgoing streams/contracts by the provided public key.
818
+ * @param {string} sender - Sender public key
819
+ * @returns Record of stream data
820
+ */
821
+ private getOutgoingAlignedStreams;
822
+ private getIncomingAlignedStreams;
823
+ /**
824
+ * Fetch streams/contracts by providing direction.
825
+ * Streams are sorted by start time in ascending order.
826
+ * @param {IGetAllData} getData - Query parameters including address, stream type filter, and direction filter
827
+ * @returns Record of stream data
828
+ */
829
+ get({ address, type, direction, filters, }: IGetAllData): Promise<[string, Stream][]>;
830
+ /**
831
+ * Searches for streams/contracts by providing filters.
832
+ * @param {ISearchStreams} data - Search by mint, sender, recipient or closed status
833
+ * @returns Record of stream data
834
+ */
835
+ searchStreams(data: ISearchStreams): Promise<IProgramAccount<Stream>[]>;
836
+ private decodeStreamsFromAccounts;
837
+ private collectAlignedEntries;
838
+ private fetchAlignedProxiesByEntries;
839
+ private mapDecodedToProgramAccounts;
840
+ /**
841
+ * Attempts updating the stream auto withdrawal params and amount per period
842
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
843
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
844
+ * @returns Transaction result
845
+ */
846
+ update(data: IUpdateData, extParams: IInteractStreamExt): Promise<ITransactionResult>;
847
+ /**
848
+ * Create Transaction instructions for update
849
+ * @param {IUpdateData} data - Update parameters including stream ID and new settings
850
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
851
+ * @returns Transaction instructions
852
+ */
853
+ prepareUpdateInstructions(data: IUpdateData, { invoker, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
854
+ /**
855
+ * Gets fees for a given address
856
+ * @param {IGetFeesData} getData - Query parameters containing the partner address to check for custom fees
857
+ * @returns Fees
858
+ */
859
+ getFees({ address }: IGetFeesData): Promise<IFees | null>;
860
+ /**
861
+ * Gets default streamflow fee
862
+ * @returns Default streamflow fee
863
+ */
864
+ getDefaultStreamflowFee(): Promise<number>;
865
+ /**
866
+ * Get all defaults fees applied by the protocol.
867
+ *
868
+ * Protocol will use fees set for WITHDRAWOR as default if they are set.
869
+ */
870
+ getDefaultFees(): Promise<IFees>;
871
+ /**
872
+ * Returns total fee percent, streamflow fees + partner fees
873
+ * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
874
+ * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
875
+ */
876
+ getTotalFee(getFeesData: IGetFeesData): Promise<number>;
877
+ /**
878
+ * Extracts error code from an error
879
+ * @param {Error} err - Error
880
+ * @returns Error code
881
+ */
882
+ extractErrorCode(err: Error): string | null;
883
+ /**
884
+ * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA.
885
+ * For migrated streams, the PDA was derived from the old metadata key.
886
+ */
887
+ isAlignedUnlock(streamPublicKey: PublicKey, senderPublicKey: PublicKey): boolean;
888
+ private flatBuildCreateMultipleTransactionInstructions;
889
+ /**
890
+ * Gets closed streams for a given owner and direction
891
+ * @param owner - Owner address
892
+ * @param direction - Stream direction
893
+ * @returns Record of closed streams
894
+ */
895
+ getClosedStreams(owner: string, direction?: StreamDirection): Promise<Record<string, Stream>>;
896
+ /**
897
+ * Utility function to generate metadata for a Contract or return existing Pubkey
898
+ */
899
+ private getOrCreateStreamMetadata;
900
+ /**
901
+ * Returns the configured transfer hook program for a Token-2022 mint, if present.
902
+ */
903
+ private getTransferHookProgramId;
904
+ /**
905
+ * Appends transfer-hook extra metas for each potential token transfer performed by the instruction.
906
+ *
907
+ * Transfer hook may rely on additional accounts/PDAs - derivation path is configured on the transfer hook metadata account, so for each potential transfer we need to check whether these accounts are needed and add them.
908
+ */
909
+ private addTransferHookAccounts;
910
+ /**
911
+ * Returns insrtuctions for creating associated token accounts for the provided owners
912
+ */
913
+ private getCreateATAInstructions;
914
+ private applyCustomAfterInstructions;
915
+ }
916
+
917
+ type EnvBase = {
918
+ programId: PublicKey;
919
+ commitment?: Commitment;
920
+ client?: SolanaStreamClient;
921
+ };
922
+ type EnvWithConnection = EnvBase & {
923
+ connection: Connection;
924
+ cluster: ICluster;
925
+ };
926
+ type EnvWithRpcUrl = EnvBase & {
927
+ rpcUrl: string;
928
+ cluster?: ICluster;
929
+ };
930
+ type Env = EnvWithConnection | EnvWithRpcUrl;
931
+ type ExecutionEnv = Env & {
932
+ queue?: PQueue;
933
+ sendRate?: number;
934
+ throttler?: PQueue;
935
+ skipPreflight?: boolean;
936
+ };
937
+ interface InstructionResult {
938
+ instructions: TransactionInstruction[];
939
+ signers?: Keypair[];
940
+ metadataPubKey?: PublicKey;
941
+ }
942
+ interface CreateInstructionResult extends InstructionResult {
943
+ metadata?: Keypair;
944
+ }
945
+ interface BatchCreationItem {
946
+ instructions: TransactionInstruction[];
947
+ signers?: Keypair[];
948
+ recipient: string;
949
+ metadataPubKey: PublicKey;
950
+ }
951
+ interface BatchInstructionResult {
952
+ setupInstructions: TransactionInstruction[];
953
+ creationBatches: BatchCreationItem[];
954
+ }
955
+ interface BuildTransactionOptions {
956
+ feePayer?: PublicKey;
957
+ computeLimit?: number | ComputeLimitEstimate | "autoSimulate";
958
+ computePrice?: number | ComputePriceEstimate;
959
+ }
960
+ interface NativeOptions {
961
+ isNative?: boolean;
962
+ }
963
+ interface BuiltTransaction {
964
+ transaction: VersionedTransaction;
965
+ blockhashWithExpiryBlockHeight: BlockhashWithExpiryBlockHeight;
966
+ context: Context;
967
+ }
968
+ interface BatchExecuteResult {
969
+ signatures: TransactionSignature[];
970
+ errors: Error[];
971
+ }
972
+ type Invoker = Keypair | SignerWalletAdapter | {
973
+ publicKey: PublicKey;
974
+ };
975
+ type CreateFn = (params: ICreateStreamData, invoker: Invoker, env: Env & NativeOptions) => Promise<CreateInstructionResult>;
976
+ type WithdrawFn = (params: IWithdrawData, invoker: Invoker, env: Env) => Promise<InstructionResult>;
977
+ type TopupFn = (params: ITopUpData, invoker: Invoker, env: Env & NativeOptions) => Promise<InstructionResult>;
978
+ type CancelFn = (params: {
979
+ id: string;
980
+ }, invoker: Invoker, env: Env) => Promise<InstructionResult>;
981
+ type TransferFn = (params: ITransferData, invoker: Invoker, env: Env) => Promise<InstructionResult>;
982
+ type UpdateFn = (params: IUpdateData, invoker: Invoker, env: Env) => Promise<InstructionResult>;
983
+ type CreateBatchFn = (params: ICreateMultipleLinearStreamData | ICreateMultipleAlignedStreamData, invoker: Invoker, env: Env & NativeOptions) => Promise<BatchInstructionResult>;
984
+ type BuildTransactionFn = (instructions: TransactionInstruction[], options: BuildTransactionOptions, env: Env) => Promise<BuiltTransaction>;
985
+ type SignFn = (transaction: VersionedTransaction, signers: (SignerWalletAdapter | Keypair | {
986
+ publicKey: PublicKey;
987
+ })[]) => Promise<VersionedTransaction>;
988
+ type ExecuteFn = (builtTx: BuiltTransaction, env: ExecutionEnv) => Promise<TransactionSignature>;
989
+ type ExecuteBatchFn = (builtTransactions: BuiltTransaction[], env: ExecutionEnv) => Promise<BatchExecuteResult>;
990
+ type ExecuteBatchSequentialFn = (builtTransactions: BuiltTransaction[], env: ExecutionEnv) => Promise<BatchExecuteResult>;
991
+ declare function resolveConnection(env: Env): Connection;
992
+ declare function createClientFromEnv(env: Env): SolanaStreamClient;
993
+
994
+ declare function create(params: ICreateStreamData, invoker: Invoker, env: Env & NativeOptions): Promise<CreateInstructionResult>;
995
+
996
+ declare function withdraw(params: IWithdrawData, invoker: Invoker, env: Env): Promise<InstructionResult>;
997
+
998
+ declare function topup(params: ITopUpData, invoker: Invoker, env: Env & NativeOptions): Promise<InstructionResult>;
999
+
1000
+ declare function cancel(params: ICancelData, invoker: Invoker, env: Env): Promise<InstructionResult>;
1001
+
1002
+ /**
1003
+ * Prepare transfer instructions.
1004
+ * Note: prepareTransferInstructions embeds ComputeBudgetProgram.setComputeUnitLimit
1005
+ * (computeLimit defaults to 100001). Callers using buildTransaction() should leave
1006
+ * computeLimit undefined to avoid duplicating compute budget instructions.
1007
+ */
1008
+ declare function transfer(params: ITransferData, invoker: Invoker, env: Env): Promise<InstructionResult>;
1009
+
1010
+ declare function update(params: IUpdateData, invoker: Invoker, env: Env): Promise<InstructionResult>;
1011
+
1012
+ declare function createBatch(params: ICreateMultipleLinearStreamData | ICreateMultipleAlignedStreamData, invoker: Invoker, env: Env & NativeOptions): Promise<BatchInstructionResult>;
1013
+
1014
+ interface ICreateLockParams {
1015
+ recipient: string;
1016
+ tokenId: string;
1017
+ amount: BN;
1018
+ unlockDate: number;
1019
+ name: string;
1020
+ transferableByRecipient?: boolean;
1021
+ partner?: string;
1022
+ tokenProgramId?: string | PublicKey;
1023
+ }
1024
+ declare function buildLockParams(params: ICreateLockParams): ICreateLinearStreamData;
1025
+ declare function createLock(params: ICreateLockParams, invoker: Invoker, env: Env & NativeOptions): Promise<CreateInstructionResult>;
1026
+
1027
+ interface ILockBatchRecipient {
1028
+ recipient: string;
1029
+ amount: BN;
1030
+ name: string;
1031
+ }
1032
+ interface ICreateLockBatchParams {
1033
+ recipients: ILockBatchRecipient[];
1034
+ tokenId: string;
1035
+ unlockDate: number;
1036
+ transferableByRecipient?: boolean;
1037
+ partner?: string;
1038
+ tokenProgramId?: string | PublicKey;
1039
+ }
1040
+ declare function buildLockBatchParams(params: ICreateLockBatchParams): ICreateMultipleLinearStreamData;
1041
+ declare function createLockBatch(params: ICreateLockBatchParams, invoker: Invoker, env: Env & NativeOptions): Promise<BatchInstructionResult>;
1042
+
1043
+ interface ICreateVestingParams {
1044
+ recipient: string;
1045
+ tokenId: string;
1046
+ amount: BN;
1047
+ start: number;
1048
+ period: number;
1049
+ name: string;
1050
+ endDate?: number;
1051
+ duration?: number;
1052
+ cliffAmount?: BN;
1053
+ amountPerPeriod?: BN;
1054
+ cancelableBySender?: boolean;
1055
+ canTopup?: boolean;
1056
+ automaticWithdrawal?: boolean;
1057
+ withdrawalFrequency?: number;
1058
+ transferableBySender?: boolean;
1059
+ transferableByRecipient?: boolean;
1060
+ initialAllocation?: {
1061
+ amount: BN;
1062
+ };
1063
+ partner?: string;
1064
+ tokenProgramId?: string | PublicKey;
1065
+ }
1066
+ declare function resolveDuration(params: Pick<ICreateVestingParams, "start" | "endDate" | "duration">): number;
1067
+ declare function computeAmountPerPeriod(amount: BN, cliffAmount: BN, duration: number, period: number): BN;
1068
+ declare function buildVestingParams(params: ICreateVestingParams): ICreateLinearStreamData;
1069
+ declare function createVesting(params: ICreateVestingParams & {
1070
+ initialAllocation?: undefined;
1071
+ }, invoker: Invoker, env: Env & NativeOptions): Promise<CreateInstructionResult>;
1072
+ declare function createVesting(params: ICreateVestingParams & {
1073
+ initialAllocation: {
1074
+ amount: BN;
1075
+ };
1076
+ }, invoker: Invoker, env: Env & NativeOptions): Promise<BatchInstructionResult>;
1077
+
1078
+ interface IVestingBatchRecipient {
1079
+ recipient: string;
1080
+ amount: BN;
1081
+ name: string;
1082
+ cliffAmount?: BN;
1083
+ amountPerPeriod?: BN;
1084
+ }
1085
+ interface ICreateVestingBatchParams {
1086
+ recipients: IVestingBatchRecipient[];
1087
+ tokenId: string;
1088
+ start: number;
1089
+ period: number;
1090
+ endDate?: number;
1091
+ duration?: number;
1092
+ cancelableBySender?: boolean;
1093
+ automaticWithdrawal?: boolean;
1094
+ withdrawalFrequency?: number;
1095
+ transferableBySender?: boolean;
1096
+ transferableByRecipient?: boolean;
1097
+ partner?: string;
1098
+ tokenProgramId?: string | PublicKey;
1099
+ }
1100
+ declare function buildVestingBatchParams(params: ICreateVestingBatchParams): ICreateMultipleLinearStreamData;
1101
+ declare function createVestingBatch(params: ICreateVestingBatchParams, invoker: Invoker, env: Env & NativeOptions): Promise<BatchInstructionResult>;
1102
+
1103
+ declare function buildTransaction(instructions: TransactionInstruction[], options: BuildTransactionOptions, env: Env): Promise<BuiltTransaction>;
1104
+
1105
+ type SignerInput = SignerWalletAdapter | Keypair | {
1106
+ publicKey: PublicKey;
1107
+ };
1108
+ declare function sign(transaction: VersionedTransaction, signers: SignerInput[]): Promise<VersionedTransaction>;
1109
+
1110
+ declare function execute(builtTx: BuiltTransaction, env: ExecutionEnv): Promise<string>;
1111
+ declare function executeBatch(builtTransactions: BuiltTransaction[], env: ExecutionEnv): Promise<BatchExecuteResult>;
1112
+ declare function executeBatchSequential(builtTransactions: BuiltTransaction[], env: ExecutionEnv): Promise<BatchExecuteResult>;
1113
+
1114
+ export { type ICreateVestingParams as $, type AlignedStream as A, type BatchItem as B, type CancelFn as C, type DecodedStream as D, type CreateTestOracleParams as E, type Env as F, type ExecuteBatchFn as G, type ExecuteBatchSequentialFn as H, type IUpdateData as I, type ExecuteFn as J, type ExecutionEnv as K, type IAlignedStreamConfig as L, type IBaseStreamConfig as M, type ICancelData as N, type ICreateExt as O, type ICreateLinearStreamData as P, type ICreateLockBatchParams as Q, type ICreateLockParams as R, StreamType as S, type ICreateMultiError as T, type ICreateMultipleAlignedStreamData as U, type ICreateMultipleLinearStreamData as V, type ICreateMultipleStreamData as W, type ICreateResult as X, type ICreateStreamExt as Y, type ICreateStreamInstructions as Z, type ICreateVestingBatchParams as _, type BatchItemResult as a, update as a$, type IFees as a0, type IGetAllData as a1, type IGetFeesData as a2, type IGetOneData as a3, type IInteractData as a4, type IInteractStreamExt as a5, type ILockBatchRecipient as a6, type IMultiTransactionResult as a7, type IPrepareCreateStreamExt as a8, type IPrepareStreamExt as a9, type TransactionSchedulingOptions as aA, type TransferFn as aB, type UpdateFn as aC, type UpdateTestOracleParams as aD, type WithdrawFn as aE, buildLockBatchParams as aF, buildLockParams as aG, buildTransaction as aH, buildVestingBatchParams as aI, buildVestingParams as aJ, cancel as aK, computeAmountPerPeriod as aL, create as aM, createBatch as aN, createClientFromEnv as aO, createLock as aP, createLockBatch as aQ, createVesting as aR, createVestingBatch as aS, execute as aT, executeBatch as aU, executeBatchSequential as aV, resolveConnection as aW, resolveDuration as aX, sign as aY, topup as aZ, transfer as a_, type IPrepareTopUpstreamExt as aa, type IRecipient as ab, type IRequestCancelData as ac, type ITopUpData as ad, type ITopUpStreamExt as ae, type ITransactionExtWithInstructions as af, type ITransactionResult as ag, type ITransferData as ah, type IVestingBatchRecipient as ai, type IWithdrawCancelRequestData as aj, type IWithdrawData as ak, type InstructionGenerator as al, type InstructionResult as am, type Invoker as an, type LinearStream as ao, type MetadataRecipientHashMap as ap, type NativeOptions as aq, type OracleType as ar, type OracleTypeName as as, type SignFn as at, SolanaStreamClient as au, type StreamClientOptions as av, type StreamClientOptionsWithConnection as aw, StreamDirection as ax, type TestOracle as ay, type TopupFn as az, type Stream as b, withdraw as b0, type ICreateStreamData as c, type ICreateAlignedStreamData as d, type ISearchStreams as e, type Account as f, AlignedContract as g, AlignedProxyErrorCode as h, type AlignedStreamData as i, type AlignedUnlocksContract as j, type BatchCreationItem as k, type BatchExecuteResult as l, type BatchInstructionResult as m, type BatchItemError as n, type BatchItemSuccess as o, type BuildTransactionFn as p, type BuildTransactionOptions as q, type BuiltTransaction as r, type ChangeOracleParams as s, type ClientCreationOptions as t, Contract as u, ContractErrorCode as v, type CreateBatchFn as w, type CreateFn as x, type CreateInstructionResult as y, type CreateParams as z };