@streamflow/stream 9.0.4 → 10.0.0-alpha.p313.18b7be3

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 (42) hide show
  1. package/README.md +6 -62
  2. package/dist/cjs/index.cjs +421 -3786
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/index.d.cts +3 -186
  5. package/dist/cjs/solana/index.cjs +376 -301
  6. package/dist/cjs/solana/index.cjs.map +1 -1
  7. package/dist/cjs/solana/index.d.cts +1134 -17
  8. package/dist/esm/index.d.ts +3 -186
  9. package/dist/esm/index.js +239 -3617
  10. package/dist/esm/index.js.map +1 -1
  11. package/dist/esm/solana/index.d.ts +1134 -17
  12. package/dist/esm/solana/index.js +257 -232
  13. package/dist/esm/solana/index.js.map +1 -1
  14. package/package.json +4 -43
  15. package/dist/cjs/BaseStreamClient-DOyJqO7R.d.cts +0 -551
  16. package/dist/cjs/aptos/index.cjs +0 -456
  17. package/dist/cjs/aptos/index.cjs.map +0 -1
  18. package/dist/cjs/aptos/index.d.cts +0 -14
  19. package/dist/cjs/evm/index.cjs +0 -1915
  20. package/dist/cjs/evm/index.cjs.map +0 -1
  21. package/dist/cjs/evm/index.d.cts +0 -13
  22. package/dist/cjs/index-BMZATAYa.d.cts +0 -213
  23. package/dist/cjs/index-BgGtpOPg.d.cts +0 -850
  24. package/dist/cjs/index-DYIamO0j.d.cts +0 -203
  25. package/dist/cjs/index-Y0HH2ugY.d.cts +0 -136
  26. package/dist/cjs/sui/index.cjs +0 -1021
  27. package/dist/cjs/sui/index.cjs.map +0 -1
  28. package/dist/cjs/sui/index.d.cts +0 -13
  29. package/dist/esm/BaseStreamClient-DOyJqO7R.d.ts +0 -551
  30. package/dist/esm/aptos/index.d.ts +0 -14
  31. package/dist/esm/aptos/index.js +0 -443
  32. package/dist/esm/aptos/index.js.map +0 -1
  33. package/dist/esm/evm/index.d.ts +0 -13
  34. package/dist/esm/evm/index.js +0 -1902
  35. package/dist/esm/evm/index.js.map +0 -1
  36. package/dist/esm/index-D54wSYym.d.ts +0 -203
  37. package/dist/esm/index-Dp5DXxr-.d.ts +0 -850
  38. package/dist/esm/index-DrzqsoIB.d.ts +0 -136
  39. package/dist/esm/index-elpYUBph.d.ts +0 -213
  40. package/dist/esm/sui/index.d.ts +0 -13
  41. package/dist/esm/sui/index.js +0 -1011
  42. package/dist/esm/sui/index.js.map +0 -1
@@ -1,24 +1,16 @@
1
- import BN4 from 'bn.js';
1
+ import BN3 from 'bn.js';
2
2
  import bs58 from 'bs58';
3
3
  import { Buffer } from 'buffer';
4
4
  import { NATIVE_MINT, ASSOCIATED_TOKEN_PROGRAM_ID } from '@solana/spl-token';
5
5
  import { PublicKey, TransactionInstruction, Connection, Keypair, SYSVAR_RENT_PUBKEY, SystemProgram, TransactionMessage, VersionedTransaction } from '@solana/web3.js';
6
- import { isSignerKeypair, isSignerWallet, executeTransaction, buildSendThrottler, prepareWrappedAccount, prepareTransaction, signAndExecuteTransaction, getMintAndProgram, prepareBaseInstructions, ata, createVersionedTransaction, executeMultipleTransactions, getMultipleAccountsInfoBatched, getProgramAccounts, checkOrCreateAtaBatch } from '@streamflow/common/solana';
6
+ import { ICluster, getNumberFromBN, isSignerKeypair, isSignerWallet, executeTransaction, ContractError, buildSendThrottler, assertHasPublicKey, prepareWrappedAccount, prepareTransaction, signAndExecuteTransaction, invariant, getMintAndProgram, prepareBaseInstructions, getBN, ata, createVersionedTransaction, executeMultipleTransactions, getMultipleAccountsInfoBatched, getProgramAccounts, checkOrCreateAtaBatch } from '@streamflow/common';
7
+ export { ContractError, ICluster, getBN, getNumberFromBN } from '@streamflow/common';
7
8
  import * as borsh from 'borsh';
8
9
  import { Program } from '@coral-xyz/anchor';
9
- import { ICluster, assertHasPublicKey, invariant, getBN } from '@streamflow/common';
10
- export { ContractError, IChain, ICluster } from '@streamflow/common';
11
10
  import * as BufferLayout from '@solana/buffer-layout';
12
11
 
13
- var __defProp = Object.defineProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
12
+ // solana/StreamClient.ts
18
13
  var MAX_SAFE_UNIX_TIME_VALUE = 864e10;
19
- var WITHDRAW_AVAILABLE_AMOUNT = new BN4("18446744073709551615");
20
-
21
- // common/contractUtils.ts
22
14
  var calculateUnlockedAmount = ({
23
15
  depositedAmount,
24
16
  cliff,
@@ -31,19 +23,25 @@ var calculateUnlockedAmount = ({
31
23
  fundsUnlockedAtLastRateChange
32
24
  }) => {
33
25
  const deposited = depositedAmount;
34
- if (currentTimestamp < cliff) return new BN4(0);
26
+ if (currentTimestamp < cliff) return new BN3(0);
35
27
  if (currentTimestamp > end) return deposited;
36
28
  const savedUnlockedFunds = lastRateChangeTime === 0 ? cliffAmount : fundsUnlockedAtLastRateChange;
37
29
  const savedUnlockedFundsTime = lastRateChangeTime === 0 ? cliff : lastRateChangeTime;
38
- const streamed = new BN4(Math.floor((currentTimestamp - savedUnlockedFundsTime) / period)).mul(amountPerPeriod).add(savedUnlockedFunds);
30
+ const streamed = new BN3(Math.floor((currentTimestamp - savedUnlockedFundsTime) / period)).mul(amountPerPeriod).add(savedUnlockedFunds);
39
31
  return streamed.lt(deposited) ? streamed : deposited;
40
32
  };
41
33
  var isCliffCloseToDepositedAmount = (streamData) => {
42
- return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new BN4(1)));
34
+ return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new BN3(1)));
35
+ };
36
+ var isPayment = (streamData) => {
37
+ return streamData.canTopup;
43
38
  };
44
39
  var isVesting = (streamData) => {
45
40
  return !streamData.canTopup && !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
46
41
  };
42
+ var isAligned = (stream) => {
43
+ return "minPrice" in stream && "maxPrice" in stream && "minPercentage" in stream && "maxPercentage" in stream;
44
+ };
47
45
  var isCreateAlignedStreamData = (obj) => {
48
46
  return "minPrice" in obj && "maxPrice" in obj && "minPercentage" in obj && "maxPercentage" in obj;
49
47
  };
@@ -63,60 +61,158 @@ var buildStreamType = (streamData) => {
63
61
  return "payment" /* Payment */;
64
62
  };
65
63
  var decodeEndTime = (endTime) => {
66
- if (endTime.gt(new BN4(MAX_SAFE_UNIX_TIME_VALUE))) {
64
+ if (endTime.gt(new BN3(MAX_SAFE_UNIX_TIME_VALUE))) {
67
65
  return MAX_SAFE_UNIX_TIME_VALUE;
68
66
  }
69
67
  return endTime.toNumber();
70
68
  };
71
- var FEE_PRECISION = 4;
72
- var FEE_NORMALIZER = 10 ** FEE_PRECISION;
73
- var FEE_MULTIPLIER = new BN4(10 ** 6);
74
- var getNumberFromBN = (value, decimals) => value.gt(new BN4(2 ** 53 - 1)) ? value.div(new BN4(10 ** decimals)).toNumber() : value.toNumber() / 10 ** decimals;
75
- var calculateTotalAmountToDeposit = (depositedAmount, totalFee) => {
76
- const totalFeeNormalized = new BN4(totalFee * FEE_NORMALIZER);
77
- return depositedAmount.mul(totalFeeNormalized.add(FEE_MULTIPLIER)).div(FEE_MULTIPLIER);
69
+ var ALIGNED_PRECISION_FACTOR_POW = 9;
70
+ var StreamDirection = /* @__PURE__ */ ((StreamDirection2) => {
71
+ StreamDirection2["Outgoing"] = "outgoing";
72
+ StreamDirection2["Incoming"] = "incoming";
73
+ StreamDirection2["All"] = "all";
74
+ return StreamDirection2;
75
+ })(StreamDirection || {});
76
+ var StreamType = /* @__PURE__ */ ((StreamType2) => {
77
+ StreamType2["All"] = "all";
78
+ StreamType2["Payment"] = "payment";
79
+ StreamType2["Vesting"] = "vesting";
80
+ StreamType2["Lock"] = "lock";
81
+ return StreamType2;
82
+ })(StreamType || {});
83
+ var ContractErrorCode = /* @__PURE__ */ ((ContractErrorCode2) => {
84
+ ContractErrorCode2["AccountsNotWritable"] = "AccountsNotWritable";
85
+ ContractErrorCode2["InvalidMetadata"] = "InvalidMetadata";
86
+ ContractErrorCode2["InvalidMetadataAccount"] = "InvalidMetadataAccount";
87
+ ContractErrorCode2["MetadataAccountMismatch"] = "MetadataAccountMismatch";
88
+ ContractErrorCode2["InvalidEscrowAccount"] = "InvalidEscrowAccount";
89
+ ContractErrorCode2["NotAssociated"] = "NotAssociated";
90
+ ContractErrorCode2["MintMismatch"] = "MintMismatch";
91
+ ContractErrorCode2["TransferNotAllowed"] = "TransferNotAllowed";
92
+ ContractErrorCode2["ContractClosed"] = "ContractClosed";
93
+ ContractErrorCode2["InvalidTreasury"] = "InvalidTreasury";
94
+ ContractErrorCode2["InvalidTimestamps"] = "InvalidTimestamps";
95
+ ContractErrorCode2["InvalidDepositConfiguration"] = "InvalidDepositConfiguration";
96
+ ContractErrorCode2["AmountIsZero"] = "AmountIsZero";
97
+ ContractErrorCode2["AmountMoreThanAvailable"] = "AmountMoreThanAvailable";
98
+ ContractErrorCode2["AmountAvailableIsZero"] = "AmountAvailableIsZero";
99
+ ContractErrorCode2["ArithmeticError"] = "ArithmeticError";
100
+ ContractErrorCode2["InvalidMetadataSize"] = "InvalidMetadataSize";
101
+ ContractErrorCode2["UninitializedMetadata"] = "UninitializedMetadata";
102
+ ContractErrorCode2["Unauthorized"] = "Unauthorized";
103
+ ContractErrorCode2["SelfTransfer"] = "SelfTransfer";
104
+ ContractErrorCode2["AlreadyPaused"] = "AlreadyPaused";
105
+ ContractErrorCode2["NotPaused"] = "NotPaused";
106
+ ContractErrorCode2["MetadataNotRentExempt"] = "MetadataNotRentExempt";
107
+ return ContractErrorCode2;
108
+ })(ContractErrorCode || {});
109
+ var AlignedProxyErrorCode = /* @__PURE__ */ ((AlignedProxyErrorCode2) => {
110
+ AlignedProxyErrorCode2["Unauthorized"] = "Unauthorized";
111
+ AlignedProxyErrorCode2["ArithmeticError"] = "ArithmeticError";
112
+ AlignedProxyErrorCode2["UnsupportedTokenExtensions"] = "UnsupportedTokenExtensions";
113
+ AlignedProxyErrorCode2["PeriodTooShort"] = "PeriodTooShort";
114
+ AlignedProxyErrorCode2["InvalidTickSize"] = "InvalidTickSize";
115
+ AlignedProxyErrorCode2["InvalidPercentageBoundaries"] = "InvalidPercentageBoundaries";
116
+ AlignedProxyErrorCode2["InvalidPriceBoundaries"] = "InvalidPriceBoundaries";
117
+ AlignedProxyErrorCode2["UnsupportedOracle"] = "UnsupportedOracle";
118
+ AlignedProxyErrorCode2["InvalidOracleAccount"] = "InvalidOracleAccount";
119
+ AlignedProxyErrorCode2["InvalidOraclePrice"] = "InvalidOraclePrice";
120
+ AlignedProxyErrorCode2["InvalidStreamMetadata"] = "InvalidStreamMetadata";
121
+ AlignedProxyErrorCode2["AmountAlreadyUpdated"] = "AmountAlreadyUpdated";
122
+ AlignedProxyErrorCode2["AllFundsUnlocked"] = "AllFundsUnlocked";
123
+ return AlignedProxyErrorCode2;
124
+ })(AlignedProxyErrorCode || {});
125
+ var Contract = class {
126
+ constructor(stream) {
127
+ this.magic = stream.magic.toNumber();
128
+ this.version = stream.version.toNumber();
129
+ this.createdAt = stream.createdAt.toNumber();
130
+ this.withdrawnAmount = stream.withdrawnAmount;
131
+ this.canceledAt = stream.canceledAt.toNumber();
132
+ this.end = decodeEndTime(stream.end);
133
+ this.lastWithdrawnAt = stream.lastWithdrawnAt.toNumber();
134
+ this.sender = stream.sender.toBase58();
135
+ this.senderTokens = stream.senderTokens.toBase58();
136
+ this.recipient = stream.recipient.toBase58();
137
+ this.recipientTokens = stream.recipientTokens.toBase58();
138
+ this.mint = stream.mint.toBase58();
139
+ this.escrowTokens = stream.escrowTokens.toBase58();
140
+ this.streamflowTreasury = stream.streamflowTreasury.toBase58();
141
+ this.streamflowTreasuryTokens = stream.streamflowTreasuryTokens.toBase58();
142
+ this.streamflowFeeTotal = stream.streamflowFeeTotal;
143
+ this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
144
+ this.streamflowFeePercent = stream.streamflowFeePercent;
145
+ this.partnerFeeTotal = stream.partnerFeeTotal;
146
+ this.partnerFeeWithdrawn = stream.partnerFeeWithdrawn;
147
+ this.partnerFeePercent = stream.partnerFeePercent;
148
+ this.partner = stream.partner.toBase58();
149
+ this.partnerTokens = stream.partnerTokens?.toBase58();
150
+ this.start = stream.start.toNumber();
151
+ this.depositedAmount = stream.depositedAmount;
152
+ this.period = stream.period.toNumber();
153
+ this.amountPerPeriod = stream.amountPerPeriod;
154
+ this.cliff = stream.cliff.toNumber();
155
+ this.cliffAmount = stream.cliffAmount;
156
+ this.cancelableBySender = stream.cancelableBySender;
157
+ this.cancelableByRecipient = stream.cancelableByRecipient;
158
+ this.automaticWithdrawal = stream.automaticWithdrawal;
159
+ this.transferableBySender = stream.transferableBySender;
160
+ this.transferableByRecipient = stream.transferableByRecipient;
161
+ this.canTopup = stream.canTopup;
162
+ this.name = stream.name;
163
+ this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
164
+ this.closed = stream.closed;
165
+ this.currentPauseStart = stream.currentPauseStart.toNumber();
166
+ this.pauseCumulative = stream.pauseCumulative;
167
+ this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
168
+ this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
169
+ this.type = buildStreamType(this);
170
+ this.isAligned = false;
171
+ }
172
+ unlocked(currentTimestamp) {
173
+ return calculateUnlockedAmount({
174
+ ...this,
175
+ currentTimestamp
176
+ });
177
+ }
178
+ remaining(decimals) {
179
+ return getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
180
+ }
181
+ };
182
+ var AlignedContract = class extends Contract {
183
+ constructor(stream, alignedProxy) {
184
+ super(stream);
185
+ this.minPrice = getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW);
186
+ this.maxPrice = getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW);
187
+ this.minPercentage = getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW);
188
+ this.maxPercentage = getNumberFromBN(alignedProxy.maxPercentage, ALIGNED_PRECISION_FACTOR_POW);
189
+ this.oracleType = Object.keys(alignedProxy.priceOracleType).find((key) => !!key) || "none";
190
+ this.tickSize = alignedProxy.tickSize.toNumber();
191
+ this.priceOracle = this.oracleType === "none" ? void 0 : alignedProxy.priceOracle.toBase58();
192
+ this.sender = alignedProxy.sender.toBase58();
193
+ this.canceledAt = alignedProxy.streamCanceledTime.toNumber();
194
+ this.proxyAddress = stream.sender.toBase58();
195
+ this.initialAmountPerPeriod = alignedProxy.initialAmountPerPeriod;
196
+ this.initialPrice = getNumberFromBN(alignedProxy.initialPrice, ALIGNED_PRECISION_FACTOR_POW);
197
+ this.lastPrice = getNumberFromBN(alignedProxy.lastPrice, ALIGNED_PRECISION_FACTOR_POW);
198
+ this.lastAmountUpdateTime = alignedProxy.lastAmountUpdateTime.toNumber();
199
+ this.initialNetAmount = alignedProxy.initialNetAmount;
200
+ this.expiryTime = alignedProxy.expiryTime.toNumber();
201
+ this.expiryPercentage = getNumberFromBN(alignedProxy.expiryPercentage, ALIGNED_PRECISION_FACTOR_POW);
202
+ this.floorPrice = getNumberFromBN(alignedProxy.floorPrice, ALIGNED_PRECISION_FACTOR_POW);
203
+ this.type = buildStreamType(this);
204
+ this.isAligned = true;
205
+ }
78
206
  };
79
-
80
- // solana/constants.ts
81
- var constants_exports = {};
82
- __export(constants_exports, {
83
- AIRDROP_AMOUNT: () => AIRDROP_AMOUNT,
84
- AIRDROP_TEST_TOKEN: () => AIRDROP_TEST_TOKEN,
85
- ALIGNED_COMPUTE_LIMIT: () => ALIGNED_COMPUTE_LIMIT,
86
- ALIGNED_PRECISION_FACTOR_POW: () => ALIGNED_PRECISION_FACTOR_POW,
87
- ALIGNED_UNLOCKS_PROGRAM_ID: () => ALIGNED_UNLOCKS_PROGRAM_ID,
88
- CONTRACT_DISCRIMINATOR: () => CONTRACT_DISCRIMINATOR,
89
- CONTRACT_SEED: () => CONTRACT_SEED,
90
- CREATE_PARAMS_PADDING: () => CREATE_PARAMS_PADDING,
91
- DEFAULT_STREAMFLOW_FEE: () => DEFAULT_STREAMFLOW_FEE,
92
- ESCROW_SEED: () => ESCROW_SEED,
93
- FEES_METADATA_SEED: () => FEES_METADATA_SEED,
94
- FEE_ORACLE_PUBLIC_KEY: () => FEE_ORACLE_PUBLIC_KEY,
95
- ORIGINAL_CONTRACT_SENDER_OFFSET: () => ORIGINAL_CONTRACT_SENDER_OFFSET,
96
- PARTNERS_SCHEMA: () => PARTNERS_SCHEMA,
97
- PARTNER_ORACLE_PROGRAM_ID: () => PARTNER_ORACLE_PROGRAM_ID,
98
- PARTNER_SCHEMA: () => PARTNER_SCHEMA,
99
- PROGRAM_ID: () => PROGRAM_ID,
100
- SOLANA_ERROR_MAP: () => SOLANA_ERROR_MAP,
101
- SOLANA_ERROR_MATCH_REGEX: () => SOLANA_ERROR_MATCH_REGEX,
102
- STREAMFLOW_TREASURY_PUBLIC_KEY: () => STREAMFLOW_TREASURY_PUBLIC_KEY,
103
- STREAM_STRUCT_OFFSETS: () => STREAM_STRUCT_OFFSETS,
104
- STREAM_STRUCT_OFFSET_CLOSED: () => STREAM_STRUCT_OFFSET_CLOSED,
105
- STREAM_STRUCT_OFFSET_MINT: () => STREAM_STRUCT_OFFSET_MINT,
106
- STREAM_STRUCT_OFFSET_RECIPIENT: () => STREAM_STRUCT_OFFSET_RECIPIENT,
107
- STREAM_STRUCT_OFFSET_SENDER: () => STREAM_STRUCT_OFFSET_SENDER,
108
- TEST_ORACLE_DISCRIMINATOR: () => TEST_ORACLE_DISCRIMINATOR,
109
- TEST_ORACLE_SEED: () => TEST_ORACLE_SEED,
110
- TX_FINALITY_CONFIRMED: () => TX_FINALITY_CONFIRMED,
111
- WITHDRAWOR_PUBLIC_KEY: () => WITHDRAWOR_PUBLIC_KEY
112
- });
113
207
  var TX_FINALITY_CONFIRMED = "confirmed";
114
208
  var ORIGINAL_CONTRACT_SENDER_OFFSET = 9;
115
209
  var STREAM_STRUCT_OFFSET_SENDER = 49;
116
210
  var STREAM_STRUCT_OFFSET_RECIPIENT = 113;
117
211
  var STREAM_STRUCT_OFFSET_MINT = 177;
118
212
  var STREAM_STRUCT_OFFSET_CLOSED = 671;
119
- var ALIGNED_PRECISION_FACTOR_POW = 9;
213
+ var MAX_SAFE_UNIX_TIME_VALUE2 = 864e10;
214
+ var WITHDRAW_AVAILABLE_AMOUNT = new BN3("18446744073709551615");
215
+ var ALIGNED_PRECISION_FACTOR_POW2 = 9;
120
216
  var STREAM_STRUCT_OFFSETS = {
121
217
  mint: STREAM_STRUCT_OFFSET_MINT,
122
218
  recipient: STREAM_STRUCT_OFFSET_RECIPIENT,
@@ -197,88 +293,8 @@ var SOLANA_ERROR_MAP = {
197
293
  6011: "AmountAlreadyUpdated" /* AmountAlreadyUpdated */,
198
294
  6012: "AllFundsUnlocked" /* AllFundsUnlocked */
199
295
  };
200
- var Contract = class {
201
- constructor(stream) {
202
- this.magic = stream.magic.toNumber();
203
- this.version = stream.version.toNumber();
204
- this.createdAt = stream.createdAt.toNumber();
205
- this.withdrawnAmount = stream.withdrawnAmount;
206
- this.canceledAt = stream.canceledAt.toNumber();
207
- this.end = decodeEndTime(stream.end);
208
- this.lastWithdrawnAt = stream.lastWithdrawnAt.toNumber();
209
- this.sender = stream.sender.toBase58();
210
- this.senderTokens = stream.senderTokens.toBase58();
211
- this.recipient = stream.recipient.toBase58();
212
- this.recipientTokens = stream.recipientTokens.toBase58();
213
- this.mint = stream.mint.toBase58();
214
- this.escrowTokens = stream.escrowTokens.toBase58();
215
- this.streamflowTreasury = stream.streamflowTreasury.toBase58();
216
- this.streamflowTreasuryTokens = stream.streamflowTreasuryTokens.toBase58();
217
- this.streamflowFeeTotal = stream.streamflowFeeTotal;
218
- this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
219
- this.streamflowFeePercent = stream.streamflowFeePercent;
220
- this.partnerFeeTotal = stream.partnerFeeTotal;
221
- this.partnerFeeWithdrawn = stream.partnerFeeWithdrawn;
222
- this.partnerFeePercent = stream.partnerFeePercent;
223
- this.partner = stream.partner.toBase58();
224
- this.partnerTokens = stream.partnerTokens?.toBase58();
225
- this.start = stream.start.toNumber();
226
- this.depositedAmount = stream.depositedAmount;
227
- this.period = stream.period.toNumber();
228
- this.amountPerPeriod = stream.amountPerPeriod;
229
- this.cliff = stream.cliff.toNumber();
230
- this.cliffAmount = stream.cliffAmount;
231
- this.cancelableBySender = stream.cancelableBySender;
232
- this.cancelableByRecipient = stream.cancelableByRecipient;
233
- this.automaticWithdrawal = stream.automaticWithdrawal;
234
- this.transferableBySender = stream.transferableBySender;
235
- this.transferableByRecipient = stream.transferableByRecipient;
236
- this.canTopup = stream.canTopup;
237
- this.name = stream.name;
238
- this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
239
- this.closed = stream.closed;
240
- this.currentPauseStart = stream.currentPauseStart.toNumber();
241
- this.pauseCumulative = stream.pauseCumulative;
242
- this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
243
- this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
244
- this.type = buildStreamType(this);
245
- this.isAligned = false;
246
- }
247
- unlocked(currentTimestamp) {
248
- return calculateUnlockedAmount({
249
- ...this,
250
- currentTimestamp
251
- });
252
- }
253
- remaining(decimals) {
254
- return getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
255
- }
256
- };
257
- var AlignedContract = class extends Contract {
258
- constructor(stream, alignedProxy) {
259
- super(stream);
260
- this.minPrice = getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW);
261
- this.maxPrice = getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW);
262
- this.minPercentage = getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW);
263
- this.maxPercentage = getNumberFromBN(alignedProxy.maxPercentage, ALIGNED_PRECISION_FACTOR_POW);
264
- this.oracleType = Object.keys(alignedProxy.priceOracleType).find((key) => !!key) || "none";
265
- this.tickSize = alignedProxy.tickSize.toNumber();
266
- this.priceOracle = this.oracleType === "none" ? void 0 : alignedProxy.priceOracle.toBase58();
267
- this.sender = alignedProxy.sender.toBase58();
268
- this.canceledAt = alignedProxy.streamCanceledTime.toNumber();
269
- this.proxyAddress = stream.sender.toBase58();
270
- this.initialAmountPerPeriod = alignedProxy.initialAmountPerPeriod;
271
- this.initialPrice = getNumberFromBN(alignedProxy.initialPrice, ALIGNED_PRECISION_FACTOR_POW);
272
- this.lastPrice = getNumberFromBN(alignedProxy.lastPrice, ALIGNED_PRECISION_FACTOR_POW);
273
- this.lastAmountUpdateTime = alignedProxy.lastAmountUpdateTime.toNumber();
274
- this.initialNetAmount = alignedProxy.initialNetAmount;
275
- this.expiryTime = alignedProxy.expiryTime.toNumber();
276
- this.expiryPercentage = getNumberFromBN(alignedProxy.expiryPercentage, ALIGNED_PRECISION_FACTOR_POW);
277
- this.floorPrice = getNumberFromBN(alignedProxy.floorPrice, ALIGNED_PRECISION_FACTOR_POW);
278
- this.type = buildStreamType(this);
279
- this.isAligned = true;
280
- }
281
- };
296
+
297
+ // solana/layout.ts
282
298
  var streamLayout = BufferLayout.struct([
283
299
  BufferLayout.blob(8, "magic"),
284
300
  BufferLayout.blob(1, "version"),
@@ -438,20 +454,25 @@ var encodeUpdateStream = (values, data) => {
438
454
  var topupStreamLayout = BufferLayout.struct([
439
455
  BufferLayout.blob(8, "amount")
440
456
  ]);
441
-
442
- // solana/lib/utils.ts
457
+ var FEE_PRECISION = 4;
458
+ var FEE_NORMALIZER = 10 ** FEE_PRECISION;
459
+ var FEE_MULTIPLIER = new BN3(10 ** 6);
443
460
  var decoder = new TextDecoder("utf-8");
444
461
  var LE = "le";
462
+ var calculateTotalAmountToDeposit = (depositedAmount, totalFee) => {
463
+ const totalFeeNormalized = new BN3(totalFee * FEE_NORMALIZER);
464
+ return depositedAmount.mul(totalFeeNormalized.add(FEE_MULTIPLIER)).div(FEE_MULTIPLIER);
465
+ };
445
466
  var decodeStream = (buf) => {
446
467
  const raw = streamLayout.decode(buf);
447
468
  return {
448
- magic: new BN4(raw.magic, LE),
449
- version: new BN4(raw.version, LE),
450
- createdAt: new BN4(raw.created_at, LE),
451
- withdrawnAmount: new BN4(raw.withdrawn_amount, LE),
452
- canceledAt: new BN4(raw.canceled_at, LE),
453
- end: new BN4(raw.end_time, LE),
454
- lastWithdrawnAt: new BN4(raw.last_withdrawn_at, LE),
469
+ magic: new BN3(raw.magic, LE),
470
+ version: new BN3(raw.version, LE),
471
+ createdAt: new BN3(raw.created_at, LE),
472
+ withdrawnAmount: new BN3(raw.withdrawn_amount, LE),
473
+ canceledAt: new BN3(raw.canceled_at, LE),
474
+ end: new BN3(raw.end_time, LE),
475
+ lastWithdrawnAt: new BN3(raw.last_withdrawn_at, LE),
455
476
  sender: new PublicKey(raw.sender),
456
477
  senderTokens: new PublicKey(raw.sender_tokens),
457
478
  recipient: new PublicKey(raw.recipient),
@@ -460,20 +481,20 @@ var decodeStream = (buf) => {
460
481
  escrowTokens: new PublicKey(raw.escrow_tokens),
461
482
  streamflowTreasury: new PublicKey(raw.streamflow_treasury),
462
483
  streamflowTreasuryTokens: new PublicKey(raw.streamflow_treasury_tokens),
463
- streamflowFeeTotal: new BN4(raw.streamflow_fee_total, LE),
464
- streamflowFeeWithdrawn: new BN4(raw.streamflow_fee_withdrawn, LE),
484
+ streamflowFeeTotal: new BN3(raw.streamflow_fee_total, LE),
485
+ streamflowFeeWithdrawn: new BN3(raw.streamflow_fee_withdrawn, LE),
465
486
  streamflowFeePercent: raw.streamflow_fee_percent,
466
- partnerFeeTotal: new BN4(raw.partner_fee_total, LE),
467
- partnerFeeWithdrawn: new BN4(raw.partner_fee_withdrawn, LE),
487
+ partnerFeeTotal: new BN3(raw.partner_fee_total, LE),
488
+ partnerFeeWithdrawn: new BN3(raw.partner_fee_withdrawn, LE),
468
489
  partnerFeePercent: raw.partner_fee_percent,
469
490
  partner: new PublicKey(raw.partner),
470
491
  partnerTokens: new PublicKey(raw.partner_tokens),
471
- start: new BN4(raw.start_time, LE),
472
- depositedAmount: new BN4(raw.net_amount_deposited, LE),
473
- period: new BN4(raw.period, LE),
474
- amountPerPeriod: new BN4(raw.amount_per_period, LE),
475
- cliff: new BN4(raw.cliff, LE),
476
- cliffAmount: new BN4(raw.cliff_amount, LE),
492
+ start: new BN3(raw.start_time, LE),
493
+ depositedAmount: new BN3(raw.net_amount_deposited, LE),
494
+ period: new BN3(raw.period, LE),
495
+ amountPerPeriod: new BN3(raw.amount_per_period, LE),
496
+ cliff: new BN3(raw.cliff, LE),
497
+ cliffAmount: new BN3(raw.cliff_amount, LE),
477
498
  cancelableBySender: Boolean(raw.cancelable_by_sender),
478
499
  cancelableByRecipient: Boolean(raw.cancelable_by_recipient),
479
500
  automaticWithdrawal: Boolean(raw.automatic_withdrawal),
@@ -481,12 +502,12 @@ var decodeStream = (buf) => {
481
502
  transferableByRecipient: Boolean(raw.transferable_by_recipient),
482
503
  canTopup: Boolean(raw.can_topup),
483
504
  name: decoder.decode(raw.stream_name),
484
- withdrawFrequency: new BN4(raw.withdraw_frequency, LE),
505
+ withdrawFrequency: new BN3(raw.withdraw_frequency, LE),
485
506
  closed: Boolean(raw.closed),
486
- currentPauseStart: new BN4(raw.current_pause_start, LE),
487
- pauseCumulative: new BN4(raw.pause_cumulative, LE),
488
- lastRateChangeTime: new BN4(raw.last_rate_change_time, LE),
489
- fundsUnlockedAtLastRateChange: new BN4(raw.funds_unlocked_at_last_rate_change, LE)
507
+ currentPauseStart: new BN3(raw.current_pause_start, LE),
508
+ pauseCumulative: new BN3(raw.pause_cumulative, LE),
509
+ lastRateChangeTime: new BN3(raw.last_rate_change_time, LE),
510
+ fundsUnlockedAtLastRateChange: new BN3(raw.funds_unlocked_at_last_rate_change, LE)
490
511
  };
491
512
  };
492
513
  async function signAllTransactionWithRecipients(sender, items) {
@@ -518,6 +539,19 @@ async function sendAndConfirmStreamRawTransaction(connection, batchItem, confirm
518
539
  };
519
540
  }
520
541
  }
542
+ async function handleContractError(func, callback) {
543
+ try {
544
+ return await func();
545
+ } catch (err) {
546
+ if (err instanceof Error) {
547
+ if (callback) {
548
+ throw new ContractError(err, callback(err));
549
+ }
550
+ throw new ContractError(err);
551
+ }
552
+ throw err;
553
+ }
554
+ }
521
555
  function extractSolanaErrorCode(errorText, logs) {
522
556
  let match = SOLANA_ERROR_MATCH_REGEX.exec(errorText);
523
557
  if (!match && logs) {
@@ -847,28 +881,6 @@ var topupStreamInstruction = async (amount, programId, {
847
881
  });
848
882
  };
849
883
 
850
- // common/BaseStreamClient.ts
851
- var BaseStreamClient = class {
852
- /**
853
- * Returns total fee percent, streamflow fees + partner fees
854
- * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
855
- * @param chainSpecificParams additional parameters required by chain client
856
- * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
857
- */
858
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
859
- async getTotalFee(getFeesData, chainSpecificParams) {
860
- const fees = await this.getFees(getFeesData, chainSpecificParams);
861
- if (fees) {
862
- return fees.partnerFee + fees.streamflowFee;
863
- }
864
- return this.getDefaultStreamflowFee(chainSpecificParams);
865
- }
866
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
867
- extractErrorCode(err) {
868
- return null;
869
- }
870
- };
871
-
872
884
  // solana/descriptor/idl/streamflow_aligned_unlocks.json
873
885
  var streamflow_aligned_unlocks_default = {
874
886
  address: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
@@ -2382,12 +2394,11 @@ var deriveTestOraclePDA = (programId, mint, creator) => {
2382
2394
  // solana/StreamClient.ts
2383
2395
  var METADATA_ACC_SIZE = 1104;
2384
2396
  var ALIGNED_METADATA_ACC_SIZE = 320;
2385
- var SolanaStreamClient = class extends BaseStreamClient {
2397
+ var SolanaStreamClient = class {
2386
2398
  /**
2387
2399
  * Create Stream instance
2388
2400
  */
2389
2401
  constructor(optionsOrClusterUrl, cluster = ICluster.Mainnet, commitment = "confirmed", programId = "", sendRate = 1, sendThrottler) {
2390
- super();
2391
2402
  if (typeof optionsOrClusterUrl === "string") {
2392
2403
  this.commitment = commitment;
2393
2404
  this.connection = new Connection(optionsOrClusterUrl, this.commitment);
@@ -2439,7 +2450,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2439
2450
  * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
2440
2451
  *
2441
2452
  * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2442
- * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2453
+ * @param {Omit<ICreateStreamExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2443
2454
  * @returns Transaction instructions and metadata ID
2444
2455
  */
2445
2456
  async buildCreateTransactionInstructions(data, extParams) {
@@ -2486,7 +2497,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2486
2497
  * (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
2487
2498
  *
2488
2499
  * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2489
- * @param {Omit<ICreateStreamSolanaExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2500
+ * @param {Omit<ICreateStreamExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2490
2501
  * @returns Transaction and metadata information
2491
2502
  */
2492
2503
  async buildCreateTransaction(data, extParams) {
@@ -2507,7 +2518,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2507
2518
  * Creates a new stream/vesting contract.
2508
2519
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2509
2520
  * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2510
- * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
2521
+ * @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
2511
2522
  * @returns Create result
2512
2523
  */
2513
2524
  async create(data, extParams) {
@@ -2595,11 +2606,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
2595
2606
  const encodedUIntArray = new TextEncoder().encode(streamName);
2596
2607
  const streamNameArray = Array.from(encodedUIntArray);
2597
2608
  const createIx = await this.alignedProxyProgram.methods.create({
2598
- startTime: new BN4(start),
2609
+ startTime: new BN3(start),
2599
2610
  netAmountDeposited: depositedAmount,
2600
- period: new BN4(period),
2611
+ period: new BN3(period),
2601
2612
  amountPerPeriod,
2602
- cliff: new BN4(cliff),
2613
+ cliff: new BN3(cliff),
2603
2614
  cliffAmount,
2604
2615
  transferableBySender,
2605
2616
  transferableByRecipient,
@@ -2608,15 +2619,15 @@ var SolanaStreamClient = class extends BaseStreamClient {
2608
2619
  canTopup,
2609
2620
  oracleType: !!oracleType ? { [oracleType]: {} } : { none: {} },
2610
2621
  streamName: streamNameArray,
2611
- minPrice: typeof minPrice === "number" ? getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW) : minPrice,
2612
- maxPrice: typeof maxPrice === "number" ? getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW) : maxPrice,
2613
- minPercentage: typeof minPercentage === "number" ? getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW) : minPercentage,
2614
- maxPercentage: typeof maxPercentage === "number" ? getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW) : maxPercentage,
2615
- tickSize: new BN4(tickSize || 1),
2622
+ minPrice: typeof minPrice === "number" ? getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW2) : minPrice,
2623
+ maxPrice: typeof maxPrice === "number" ? getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW2) : maxPrice,
2624
+ minPercentage: typeof minPercentage === "number" ? getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW2) : minPercentage,
2625
+ maxPercentage: typeof maxPercentage === "number" ? getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW2) : maxPercentage,
2626
+ tickSize: new BN3(tickSize || 1),
2616
2627
  skipInitial: skipInitial ?? false,
2617
- expiryTime: new BN4(expiryTime ?? 0),
2618
- expiryPercentage: typeof expiryPercentage === "number" ? getBN(expiryPercentage, ALIGNED_PRECISION_FACTOR_POW) : expiryPercentage ?? new BN4(0),
2619
- floorPrice: typeof floorPrice === "number" ? getBN(floorPrice, ALIGNED_PRECISION_FACTOR_POW) : floorPrice ?? new BN4(0)
2628
+ expiryTime: new BN3(expiryTime ?? 0),
2629
+ expiryPercentage: typeof expiryPercentage === "number" ? getBN(expiryPercentage, ALIGNED_PRECISION_FACTOR_POW2) : expiryPercentage ?? new BN3(0),
2630
+ floorPrice: typeof floorPrice === "number" ? getBN(floorPrice, ALIGNED_PRECISION_FACTOR_POW2) : floorPrice ?? new BN3(0)
2620
2631
  }).accountsPartial({
2621
2632
  payer: sender.publicKey,
2622
2633
  sender: sender.publicKey,
@@ -2638,7 +2649,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2638
2649
  * Creates a new stream/vesting contract.
2639
2650
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2640
2651
  * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2641
- * @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2652
+ * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2642
2653
  * @returns Create stream instructions
2643
2654
  */
2644
2655
  async prepareCreateStreamInstructions({
@@ -2687,12 +2698,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
2687
2698
  ixs.push(
2688
2699
  await createStreamInstruction(
2689
2700
  {
2690
- start: new BN4(start),
2701
+ start: new BN3(start),
2691
2702
  depositedAmount,
2692
- period: new BN4(period),
2703
+ period: new BN3(period),
2693
2704
  amountPerPeriod,
2694
- cliff: new BN4(cliff),
2695
- cliffAmount: new BN4(cliffAmount),
2705
+ cliff: new BN3(cliff),
2706
+ cliffAmount: new BN3(cliffAmount),
2696
2707
  cancelableBySender,
2697
2708
  cancelableByRecipient,
2698
2709
  automaticWithdrawal,
@@ -2702,7 +2713,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2702
2713
  canUpdateRate: !!canUpdateRate,
2703
2714
  canPause: !!canPause,
2704
2715
  name,
2705
- withdrawFrequency: new BN4(automaticWithdrawal ? withdrawalFrequency : period)
2716
+ withdrawFrequency: new BN3(automaticWithdrawal ? withdrawalFrequency : period)
2706
2717
  },
2707
2718
  this.programId,
2708
2719
  {
@@ -2739,7 +2750,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2739
2750
  *
2740
2751
  * If you are not sure if you should use create or create_unchecked, go for create to be safer.
2741
2752
  * @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
2742
- * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2753
+ * @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2743
2754
  * @returns Create result
2744
2755
  */
2745
2756
  async createUnchecked(data, extParams) {
@@ -2821,12 +2832,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
2821
2832
  }
2822
2833
  const createInstruction = await createUncheckedStreamInstruction(
2823
2834
  {
2824
- start: new BN4(start),
2835
+ start: new BN3(start),
2825
2836
  depositedAmount,
2826
- period: new BN4(period),
2837
+ period: new BN3(period),
2827
2838
  amountPerPeriod,
2828
- cliff: new BN4(cliff),
2829
- cliffAmount: new BN4(cliffAmount),
2839
+ cliff: new BN3(cliff),
2840
+ cliffAmount: new BN3(cliffAmount),
2830
2841
  cancelableBySender,
2831
2842
  cancelableByRecipient,
2832
2843
  automaticWithdrawal,
@@ -2836,7 +2847,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2836
2847
  canUpdateRate: !!canUpdateRate,
2837
2848
  canPause: !!canPause,
2838
2849
  name,
2839
- withdrawFrequency: new BN4(automaticWithdrawal ? withdrawalFrequency : period),
2850
+ withdrawFrequency: new BN3(automaticWithdrawal ? withdrawalFrequency : period),
2840
2851
  recipient: recipientPublicKey,
2841
2852
  partner: partnerPublicKey
2842
2853
  },
@@ -2862,7 +2873,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2862
2873
  * Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
2863
2874
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2864
2875
  * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2865
- * @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2876
+ * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2866
2877
  * @returns Create multiple transaction instructions
2867
2878
  */
2868
2879
  async buildCreateMultipleTransactionInstructions(data, extParams) {
@@ -2905,7 +2916,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2905
2916
  true
2906
2917
  );
2907
2918
  if (isNative) {
2908
- const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4(0));
2919
+ const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN3(0));
2909
2920
  const nativeInstructions = await prepareWrappedAccount(
2910
2921
  this.connection,
2911
2922
  sender.publicKey,
@@ -2943,7 +2954,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2943
2954
  * ```
2944
2955
  *
2945
2956
  * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2946
- * @param {IPrepareCreateStreamSolanaExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2957
+ * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2947
2958
  * @returns Multiple transaction information
2948
2959
  */
2949
2960
  async buildCreateMultipleTransactions(data, extParams) {
@@ -2971,7 +2982,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2971
2982
  * Creates multiple stream/vesting contracts.
2972
2983
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
2973
2984
  * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
2974
- * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2985
+ * @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2975
2986
  * @returns Multiple transaction information
2976
2987
  */
2977
2988
  async createMultiple(data, extParams) {
@@ -3036,7 +3047,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3036
3047
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
3037
3048
  * In most cases, createMultiple should be used instead.
3038
3049
  * @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
3039
- * @param {ICreateStreamSolanaExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
3050
+ * @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
3040
3051
  * @returns Multiple transaction information
3041
3052
  */
3042
3053
  async createMultipleSequential(data, extParams) {
@@ -3102,7 +3113,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3102
3113
  /**
3103
3114
  * Attempts withdrawing from the specified stream.
3104
3115
  * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3105
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3116
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3106
3117
  * @returns Transaction result
3107
3118
  */
3108
3119
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
@@ -3131,7 +3142,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3131
3142
  /**
3132
3143
  * Creates Transaction Instructions for withdrawal
3133
3144
  * @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
3134
- * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
3145
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
3135
3146
  * @returns Transaction instructions
3136
3147
  */
3137
3148
  async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
@@ -3176,7 +3187,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3176
3187
  /**
3177
3188
  * Attempts canceling the specified stream.
3178
3189
  * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3179
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3190
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3180
3191
  * @returns Transaction result
3181
3192
  */
3182
3193
  async cancel(cancelData, extParams) {
@@ -3198,7 +3209,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3198
3209
  /**
3199
3210
  * Creates Transaction Instructions for cancel
3200
3211
  * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3201
- * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
3212
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
3202
3213
  * @returns Transaction instructions
3203
3214
  */
3204
3215
  async prepareCancelInstructions(cancelData, extParams) {
@@ -3215,7 +3226,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3215
3226
  /**
3216
3227
  * Creates Transaction Instructions for cancel
3217
3228
  * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3218
- * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3229
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3219
3230
  * @returns Transaction instructions
3220
3231
  */
3221
3232
  async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
@@ -3254,7 +3265,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3254
3265
  /**
3255
3266
  * Creates Transaction Instructions for cancel
3256
3267
  * @param {ICancelData} cancelData - Cancellation parameters including stream ID
3257
- * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3268
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3258
3269
  * @returns Transaction instructions
3259
3270
  */
3260
3271
  async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
@@ -3302,7 +3313,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3302
3313
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3303
3314
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3304
3315
  * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3305
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3316
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
3306
3317
  * @returns Transaction result
3307
3318
  */
3308
3319
  async transfer({ id, newRecipient }, extParams) {
@@ -3325,7 +3336,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3325
3336
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
3326
3337
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
3327
3338
  * @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
3328
- * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3339
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
3329
3340
  * @returns Transaction instructions
3330
3341
  */
3331
3342
  async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
@@ -3359,7 +3370,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3359
3370
  /**
3360
3371
  * Tops up stream account with specified amount.
3361
3372
  * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
3362
- * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3373
+ * @param {ITopUpStreamExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3363
3374
  * @returns Transaction result
3364
3375
  */
3365
3376
  async topup({ id, amount }, extParams) {
@@ -3381,7 +3392,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3381
3392
  /**
3382
3393
  * Create Transaction instructions for topup
3383
3394
  * @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
3384
- * @param {ITopUpStreamSolanaExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3395
+ * @param {ITopUpStreamExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
3385
3396
  * @returns Transaction instructions
3386
3397
  */
3387
3398
  async prepareTopupInstructions({ id, amount }, { invoker, isNative, computePrice, computeLimit }) {
@@ -3579,7 +3590,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3579
3590
  /**
3580
3591
  * Attempts updating the stream auto withdrawal params and amount per period
3581
3592
  * @param {IUpdateData} data - Update parameters including stream ID and new settings
3582
- * @param {IInteractStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3593
+ * @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
3583
3594
  * @returns Transaction result
3584
3595
  */
3585
3596
  async update(data, extParams) {
@@ -3607,7 +3618,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3607
3618
  /**
3608
3619
  * Create Transaction instructions for update
3609
3620
  * @param {IUpdateData} data - Update parameters including stream ID and new settings
3610
- * @param {IPrepareStreamSolanaExt} extParams - Transaction configuration including invoker wallet and compute settings
3621
+ * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
3611
3622
  * @returns Transaction instructions
3612
3623
  */
3613
3624
  async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
@@ -3660,6 +3671,20 @@ var SolanaStreamClient = class extends BaseStreamClient {
3660
3671
  async getDefaultStreamflowFee() {
3661
3672
  return DEFAULT_STREAMFLOW_FEE;
3662
3673
  }
3674
+ /**
3675
+ * Returns total fee percent, streamflow fees + partner fees
3676
+ * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
3677
+ * @param chainSpecificParams additional parameters required by chain client
3678
+ * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
3679
+ */
3680
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3681
+ async getTotalFee(getFeesData) {
3682
+ const fees = await this.getFees(getFeesData);
3683
+ if (fees) {
3684
+ return fees.partnerFee + fees.streamflowFee;
3685
+ }
3686
+ return this.getDefaultStreamflowFee();
3687
+ }
3663
3688
  /**
3664
3689
  * Extracts error code from an error
3665
3690
  * @param {Error} err - Error
@@ -4135,6 +4160,6 @@ var timelockIDL_default = {
4135
4160
  ]
4136
4161
  };
4137
4162
 
4138
- export { AlignedContract, Contract, SolanaStreamClient, cancelStreamInstruction, constants_exports as constants, createStreamInstruction, createUncheckedStreamInstruction, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveTestOraclePDA, extractSolanaErrorCode, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL_default as timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction };
4163
+ export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW2 as ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, AlignedContract, AlignedProxyErrorCode, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, Contract, ContractErrorCode, DEFAULT_STREAMFLOW_FEE, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, MAX_SAFE_UNIX_TIME_VALUE2 as MAX_SAFE_UNIX_TIME_VALUE, ORIGINAL_CONTRACT_SENDER_OFFSET, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX, STREAMFLOW_TREASURY_PUBLIC_KEY, STREAM_STRUCT_OFFSETS, STREAM_STRUCT_OFFSET_CLOSED, STREAM_STRUCT_OFFSET_MINT, STREAM_STRUCT_OFFSET_RECIPIENT, STREAM_STRUCT_OFFSET_SENDER, SolanaStreamClient, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, createStreamInstruction, createUncheckedStreamInstruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveTestOraclePDA, extractSolanaErrorCode, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isPayment, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL_default as timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction };
4139
4164
  //# sourceMappingURL=index.js.map
4140
4165
  //# sourceMappingURL=index.js.map