@streamflow/stream 10.0.0-alpha.p313.e531e2c → 10.0.0-alpha.p313.fe2295d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -33,14 +33,11 @@ var calculateUnlockedAmount = ({
33
33
  var isCliffCloseToDepositedAmount = (streamData) => {
34
34
  return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new BN3(1)));
35
35
  };
36
- var isPayment = (streamData) => {
37
- return streamData.canTopup;
38
- };
39
36
  var isVesting = (streamData) => {
40
- return !streamData.canTopup && !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
37
+ return !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
41
38
  };
42
39
  var isAligned = (stream) => {
43
- return "minPrice" in stream && "maxPrice" in stream && "minPercentage" in stream && "maxPercentage" in stream;
40
+ return stream.isAligned;
44
41
  };
45
42
  var isCreateAlignedStreamData = (obj) => {
46
43
  return "minPrice" in obj && "maxPrice" in obj && "minPercentage" in obj && "maxPercentage" in obj;
@@ -52,13 +49,10 @@ var isTokenLock = (streamData) => {
52
49
  return !streamData.canTopup && !streamData.automaticWithdrawal && !streamData.cancelableBySender && !streamData.cancelableByRecipient && !streamData.transferableBySender && (isCliffCloseToDepositedAmount(streamData) || isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage));
53
50
  };
54
51
  var buildStreamType = (streamData) => {
55
- if (isVesting(streamData)) {
56
- return "vesting" /* Vesting */;
57
- }
58
52
  if (isTokenLock(streamData)) {
59
53
  return "lock" /* Lock */;
60
54
  }
61
- return "payment" /* Payment */;
55
+ return "vesting" /* Vesting */;
62
56
  };
63
57
  var decodeEndTime = (endTime) => {
64
58
  if (endTime.gt(new BN3(MAX_SAFE_UNIX_TIME_VALUE))) {
@@ -75,7 +69,6 @@ var StreamDirection = /* @__PURE__ */ ((StreamDirection2) => {
75
69
  })(StreamDirection || {});
76
70
  var StreamType = /* @__PURE__ */ ((StreamType2) => {
77
71
  StreamType2["All"] = "all";
78
- StreamType2["Payment"] = "payment";
79
72
  StreamType2["Vesting"] = "vesting";
80
73
  StreamType2["Lock"] = "lock";
81
74
  return StreamType2;
@@ -232,25 +225,40 @@ var ALIGNED_UNLOCKS_PROGRAM_ID = {
232
225
  [ICluster.Testnet]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
233
226
  [ICluster.Local]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH"
234
227
  };
228
+ var PARTNER_ORACLE_PROGRAM_ID = {
229
+ [ICluster.Devnet]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3",
230
+ [ICluster.Mainnet]: "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa",
231
+ [ICluster.Testnet]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3",
232
+ [ICluster.Local]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3"
233
+ };
234
+ var FEE_ORACLE_PUBLIC_KEY = {
235
+ [ICluster.Devnet]: "Aa2JJfFzUN3V54DXUHRBJowFw416xfZHpPk9DaNy3iYs",
236
+ [ICluster.Mainnet]: "B743wFVk2pCYhV91cn287e1xY7f1vt4gdY48hhNiuQmT",
237
+ [ICluster.Testnet]: "Aa2JJfFzUN3V54DXUHRBJowFw416xfZHpPk9DaNy3iYs",
238
+ [ICluster.Local]: "Aa2JJfFzUN3V54DXUHRBJowFw416xfZHpPk9DaNy3iYs"
239
+ };
235
240
  var ALIGNED_COMPUTE_LIMIT = 3e5;
236
241
  var CONTRACT_DISCRIMINATOR = [172, 138, 115, 242, 121, 67, 183, 26];
237
242
  var TEST_ORACLE_DISCRIMINATOR = [198, 49, 63, 134, 232, 251, 168, 28];
238
243
  var CONTRACT_SEED = Buffer.from("contract", "utf-8");
239
244
  var ESCROW_SEED = Buffer.from("strm", "utf-8");
240
245
  var TEST_ORACLE_SEED = Buffer.from("test-oracle", "utf-8");
241
- var PARTNER_ORACLE_PROGRAM_ID = "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa";
242
246
  var STREAMFLOW_TREASURY_PUBLIC_KEY = new PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
243
- var WITHDRAWOR_PUBLIC_KEY = new PublicKey("wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u");
244
- var FEE_ORACLE_PUBLIC_KEY = new PublicKey("B743wFVk2pCYhV91cn287e1xY7f1vt4gdY48hhNiuQmT");
247
+ var WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
248
+ var WITHDRAWOR_PUBLIC_KEY = new PublicKey(WITHDRAWOR);
245
249
  var AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
246
250
  var FEES_METADATA_SEED = Buffer.from("strm_fees");
247
- var DEFAULT_STREAMFLOW_FEE = 0.99;
251
+ var DEFAULT_CREATION_FEE_SOL = 9e7;
252
+ var DEFAULT_AUTO_CLAIM_FEE_SOL = 19e7;
253
+ var DEFAULT_STREAMFLOW_FEE = 0.19;
248
254
  var AIRDROP_AMOUNT = 1;
249
255
  var PARTNER_SCHEMA = {
250
256
  struct: {
251
257
  pubkey: { array: { type: "u8", len: 32 } },
252
- partner_fee: "f32",
253
- strm_fee: "f32"
258
+ creation_fee: "u32",
259
+ auto_claim_fee: "u32",
260
+ token_fee_percent: "f32",
261
+ buffer: { array: { type: "u8", len: 16 } }
254
262
  }
255
263
  };
256
264
  var PARTNERS_SCHEMA = { array: { type: PARTNER_SCHEMA } };
@@ -2503,6 +2511,8 @@ var SolanaStreamClient = class {
2503
2511
  this.commitment = commitment;
2504
2512
  this.connection = new Connection(optionsOrClusterUrl, this.commitment);
2505
2513
  this.programId = programId !== "" ? new PublicKey(programId) : new PublicKey(PROGRAM_ID[cluster]);
2514
+ this.partnerOracleProgramId = new PublicKey(PARTNER_ORACLE_PROGRAM_ID[cluster]);
2515
+ this.feeOraclePublicKey = new PublicKey(FEE_ORACLE_PUBLIC_KEY[cluster]);
2506
2516
  this.schedulingParams = {
2507
2517
  sendThrottler: sendThrottler ?? buildSendThrottler(sendRate)
2508
2518
  };
@@ -2517,6 +2527,8 @@ var SolanaStreamClient = class {
2517
2527
  this.commitment = commitment2;
2518
2528
  this.connection = new Connection(clusterUrl, this.commitment);
2519
2529
  this.programId = programId2 !== "" ? new PublicKey(programId2) : new PublicKey(PROGRAM_ID[cluster2]);
2530
+ this.partnerOracleProgramId = new PublicKey(PARTNER_ORACLE_PROGRAM_ID[cluster2]);
2531
+ this.feeOraclePublicKey = new PublicKey(FEE_ORACLE_PUBLIC_KEY[cluster2]);
2520
2532
  const schedulingOptions = sendScheduler && "sendRate" in sendScheduler ? sendScheduler : void 0;
2521
2533
  const sendThrottler2 = !sendScheduler ? buildSendThrottler(1) : "sendRate" in sendScheduler ? buildSendThrottler(sendScheduler.sendRate ?? 1, sendScheduler.sendInterval) : sendScheduler;
2522
2534
  this.schedulingParams = {
@@ -2557,7 +2569,7 @@ var SolanaStreamClient = class {
2557
2569
  const { partner, amount, tokenProgramId } = data;
2558
2570
  const { isNative, sender, customInstructions } = extParams;
2559
2571
  assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2560
- const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2572
+ const partnerPublicKey = partner ? new PublicKey(partner) : sender.publicKey;
2561
2573
  const mintPublicKey = new PublicKey(data.tokenId);
2562
2574
  const ixs = await this.getCreateATAInstructions(
2563
2575
  [partnerPublicKey],
@@ -2645,7 +2657,7 @@ var SolanaStreamClient = class {
2645
2657
  return { ixs, txId: signature, metadataId };
2646
2658
  }
2647
2659
  async prepareCreateInstructions(streamParams, extParams) {
2648
- const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateStreamInstructions(streamParams, extParams);
2660
+ const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateLinearStreamInstructions(streamParams, extParams);
2649
2661
  return { ixs, metadata, metadataPubKey };
2650
2662
  }
2651
2663
  async prepareCreateAlignedUnlockInstructions(streamParams, extParams) {
@@ -2693,7 +2705,7 @@ var SolanaStreamClient = class {
2693
2705
  if (!tokenProgramId) {
2694
2706
  tokenProgramId = (await getMintAndProgram(this.connection, mintPublicKey)).tokenProgramId;
2695
2707
  }
2696
- const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2708
+ const partnerPublicKey = partner ? new PublicKey(partner) : sender.publicKey;
2697
2709
  const streamflowProgramPublicKey = new PublicKey(this.programId);
2698
2710
  const escrowPDA = deriveEscrowPDA(streamflowProgramPublicKey, metadataPubKey);
2699
2711
  const oracle = priceOracle ?? deriveTestOraclePDA(this.alignedProxyProgram.programId, mintPublicKey, sender.publicKey);
@@ -2740,7 +2752,7 @@ var SolanaStreamClient = class {
2740
2752
  partner: partnerPublicKey,
2741
2753
  recipient: recipientPublicKey,
2742
2754
  withdrawor: WITHDRAWOR_PUBLIC_KEY,
2743
- feeOracle: FEE_ORACLE_PUBLIC_KEY,
2755
+ feeOracle: this.feeOraclePublicKey,
2744
2756
  priceOracle: oracle,
2745
2757
  tokenProgram: tokenProgramId,
2746
2758
  streamflowProgram: this.programId
@@ -2755,7 +2767,7 @@ var SolanaStreamClient = class {
2755
2767
  * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2756
2768
  * @returns Create stream instructions
2757
2769
  */
2758
- async prepareCreateStreamInstructions({
2770
+ async prepareCreateLinearStreamInstructions({
2759
2771
  recipient,
2760
2772
  tokenId: mint,
2761
2773
  start,
@@ -2796,7 +2808,7 @@ var SolanaStreamClient = class {
2796
2808
  const senderTokens = await ata(mintPublicKey, sender.publicKey, tokenProgramId);
2797
2809
  const recipientTokens = await ata(mintPublicKey, recipientPublicKey, tokenProgramId);
2798
2810
  const streamflowTreasuryTokens = await ata(mintPublicKey, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
2799
- const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2811
+ const partnerPublicKey = partner ? new PublicKey(partner) : sender.publicKey;
2800
2812
  const partnerTokens = await ata(mintPublicKey, partnerPublicKey, tokenProgramId);
2801
2813
  ixs.push(
2802
2814
  await createStreamInstruction(
@@ -2831,7 +2843,7 @@ var SolanaStreamClient = class {
2831
2843
  partner: partnerPublicKey,
2832
2844
  partnerTokens,
2833
2845
  mint: new PublicKey(mint),
2834
- feeOracle: FEE_ORACLE_PUBLIC_KEY,
2846
+ feeOracle: this.feeOraclePublicKey,
2835
2847
  rent: SYSVAR_RENT_PUBKEY,
2836
2848
  timelockProgram: this.programId,
2837
2849
  tokenProgram: tokenProgramId,
@@ -2920,7 +2932,7 @@ var SolanaStreamClient = class {
2920
2932
  );
2921
2933
  const { tokenProgramId } = await getMintAndProgram(this.connection, mintPublicKey);
2922
2934
  const senderTokens = await ata(mintPublicKey, sender.publicKey, tokenProgramId);
2923
- const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2935
+ const partnerPublicKey = partner ? new PublicKey(partner) : sender.publicKey;
2924
2936
  const ixs = prepareBaseInstructions(this.connection, {
2925
2937
  computePrice,
2926
2938
  computeLimit
@@ -2958,7 +2970,7 @@ var SolanaStreamClient = class {
2958
2970
  metadata: metadataPubKey,
2959
2971
  escrowTokens,
2960
2972
  mint: new PublicKey(mint),
2961
- feeOracle: FEE_ORACLE_PUBLIC_KEY,
2973
+ feeOracle: this.feeOraclePublicKey,
2962
2974
  rent: SYSVAR_RENT_PUBKEY,
2963
2975
  timelockProgram: this.programId,
2964
2976
  tokenProgram: tokenProgramId,
@@ -2976,15 +2988,14 @@ var SolanaStreamClient = class {
2976
2988
  * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
2977
2989
  * @returns Create multiple transaction instructions
2978
2990
  */
2979
- async buildCreateMultipleTransactionInstructions(data, extParams) {
2991
+ async buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions = true) {
2980
2992
  const { recipients, ...streamParams } = data;
2981
2993
  const { sender, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
2982
2994
  assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2983
2995
  const metadatas = [];
2984
2996
  const metadataToRecipient = {};
2985
2997
  const instructionsBatch = [];
2986
- const metadataPubKeys = metadataPubKeysExt || [];
2987
- const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
2998
+ const partnerPublicKey = data.partner ? new PublicKey(data.partner) : sender.publicKey;
2988
2999
  const mintPublicKey = new PublicKey(data.tokenId);
2989
3000
  if (recipients.length === 0) {
2990
3001
  throw new Error("Recipients array is empty!");
@@ -2993,14 +3004,16 @@ var SolanaStreamClient = class {
2993
3004
  const recipientData = recipients[i];
2994
3005
  const createStreamData = { ...streamParams, ...recipientData };
2995
3006
  const createStreamExtParams = {
2996
- metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2997
- ...extParams
3007
+ ...extParams,
3008
+ metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
2998
3009
  };
2999
3010
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
3000
3011
  createStreamData,
3001
3012
  createStreamExtParams
3002
3013
  );
3003
- await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
3014
+ if (applyCustomAfterInstructions) {
3015
+ await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
3016
+ }
3004
3017
  metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
3005
3018
  metadatas.push(metadataPubKey.toBase58());
3006
3019
  instructionsBatch.push({
@@ -3048,9 +3061,9 @@ var SolanaStreamClient = class {
3048
3061
  * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
3049
3062
  * @returns Multiple transaction information
3050
3063
  */
3051
- async buildCreateMultipleTransactions(data, extParams) {
3064
+ async buildCreateMultipleTransactions(data, extParams, applyCustomAfterInstructions = true) {
3052
3065
  const { sender } = extParams;
3053
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
3066
+ const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions);
3054
3067
  const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
3055
3068
  const batch = [];
3056
3069
  for (const { ixs, metadata, recipient } of instructionsBatch) {
@@ -3081,7 +3094,7 @@ var SolanaStreamClient = class {
3081
3094
  if (!sender.publicKey) {
3082
3095
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
3083
3096
  }
3084
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
3097
+ const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
3085
3098
  const errors = [];
3086
3099
  const signatures = [];
3087
3100
  const metadataPubKeys = metadataPubKeysExt || [];
@@ -3146,7 +3159,7 @@ var SolanaStreamClient = class {
3146
3159
  if (!sender.publicKey) {
3147
3160
  throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
3148
3161
  }
3149
- const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
3162
+ const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
3150
3163
  const errors = [];
3151
3164
  const signatures = [];
3152
3165
  const batch = [];
@@ -3308,7 +3321,7 @@ var SolanaStreamClient = class {
3308
3321
  }
3309
3322
  const { sender: senderPublicKey } = decodeStream(account.data);
3310
3323
  const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
3311
- const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelStreamInstructions(cancelData, extParams);
3324
+ const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelLinearStream(cancelData, extParams);
3312
3325
  return ixs;
3313
3326
  }
3314
3327
  /**
@@ -3356,7 +3369,7 @@ var SolanaStreamClient = class {
3356
3369
  * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3357
3370
  * @returns Transaction instructions
3358
3371
  */
3359
- async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3372
+ async prepareCancelLinearStream({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3360
3373
  assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3361
3374
  const streamPublicKey = new PublicKey(id);
3362
3375
  const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
@@ -3660,20 +3673,41 @@ var SolanaStreamClient = class {
3660
3673
  const accounts = await this.connection.getProgramAccounts(this.programId, {
3661
3674
  filters
3662
3675
  });
3663
- const mapped = await Promise.all(
3664
- accounts.map(async ({ pubkey, account }) => {
3665
- const stream = decodeStream(account.data);
3666
- if (this.isAlignedUnlock(pubkey, stream.sender)) {
3667
- const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
3668
- deriveContractPDA(this.alignedProxyProgram.programId, pubkey)
3669
- );
3670
- invariant(alignedProxy, "Couldn't get aligned proxy account info");
3671
- return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
3672
- }
3673
- return { publicKey: pubkey, account: new Contract(stream) };
3674
- })
3675
- );
3676
- return mapped;
3676
+ const decoded = this.decodeStreamsFromAccounts(accounts);
3677
+ const alignedEntries = this.collectAlignedEntries(decoded);
3678
+ const alignedProxies = await this.fetchAlignedProxiesByEntries(alignedEntries);
3679
+ return this.mapDecodedToProgramAccounts(decoded, alignedEntries, alignedProxies);
3680
+ }
3681
+ decodeStreamsFromAccounts(accounts) {
3682
+ return accounts.map(({ pubkey, account }) => ({
3683
+ pubkey,
3684
+ stream: decodeStream(account.data)
3685
+ }));
3686
+ }
3687
+ collectAlignedEntries(decoded) {
3688
+ const entries = [];
3689
+ decoded.forEach(({ pubkey, stream }, index) => {
3690
+ if (this.isAlignedUnlock(pubkey, stream.sender)) {
3691
+ entries.push({ index, pda: deriveContractPDA(this.alignedProxyProgram.programId, pubkey) });
3692
+ }
3693
+ });
3694
+ return entries;
3695
+ }
3696
+ async fetchAlignedProxiesByEntries(aligned) {
3697
+ if (aligned.length === 0) return [];
3698
+ const res = await this.alignedProxyProgram.account.contract.fetchMultiple(aligned.map((a) => a.pda));
3699
+ return res;
3700
+ }
3701
+ mapDecodedToProgramAccounts(decoded, alignedEntries, alignedProxies) {
3702
+ return decoded.map(({ pubkey, stream }, idx) => {
3703
+ const alignedIdx = alignedEntries.findIndex((a) => a.index === idx);
3704
+ if (alignedIdx !== -1) {
3705
+ const alignedProxy = alignedProxies[alignedIdx];
3706
+ invariant(alignedProxy, "Couldn't get aligned proxy account info");
3707
+ return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
3708
+ }
3709
+ return { publicKey: pubkey, account: new Contract(stream) };
3710
+ });
3677
3711
  }
3678
3712
  /**
3679
3713
  * Attempts updating the stream auto withdrawal params and amount per period
@@ -3743,35 +3777,47 @@ var SolanaStreamClient = class {
3743
3777
  * @returns Fees
3744
3778
  */
3745
3779
  async getFees({ address }) {
3746
- const [metadataPubKey] = PublicKey.findProgramAddressSync(
3747
- [Buffer.from(FEES_METADATA_SEED)],
3748
- new PublicKey(PARTNER_ORACLE_PROGRAM_ID)
3749
- );
3750
- const data = await this.connection.getAccountInfo(metadataPubKey);
3780
+ const data = await this.connection.getAccountInfo(this.feeOraclePublicKey);
3751
3781
  if (!data) {
3752
3782
  return null;
3753
3783
  }
3754
3784
  const partners = borsh.deserialize(PARTNERS_SCHEMA, data.data);
3755
- const filteredPartners = partners.filter((item) => new PublicKey(item.pubkey).toString() === address);
3756
- if (filteredPartners.length === 0) {
3757
- return null;
3785
+ for (const partner of partners) {
3786
+ const partnerAddress = new PublicKey(partner.pubkey).toString();
3787
+ if (partnerAddress === address) {
3788
+ return {
3789
+ creationFeeSol: Number(partner.creation_fee),
3790
+ autoClaimFeeSol: Number(partner.auto_claim_fee),
3791
+ streamflowFee: Number(partner.token_fee_percent.toFixed(4)),
3792
+ partnerFee: 0
3793
+ };
3794
+ }
3758
3795
  }
3759
- return {
3760
- streamflowFee: Number(filteredPartners[0].strm_fee.toFixed(4)),
3761
- partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
3762
- };
3796
+ return null;
3763
3797
  }
3764
3798
  /**
3765
3799
  * Gets default streamflow fee
3766
3800
  * @returns Default streamflow fee
3767
3801
  */
3768
3802
  async getDefaultStreamflowFee() {
3769
- return DEFAULT_STREAMFLOW_FEE;
3803
+ return (await this.getDefaultFees()).streamflowFee;
3804
+ }
3805
+ /**
3806
+ * Get all defaults fees applied by the protocol.
3807
+ *
3808
+ * Protocol will use fees set for WITHDRAWOR as default if they are set.
3809
+ */
3810
+ async getDefaultFees() {
3811
+ return await this.getFees({ address: WITHDRAWOR }) || {
3812
+ creationFeeSol: DEFAULT_CREATION_FEE_SOL,
3813
+ autoClaimFeeSol: DEFAULT_AUTO_CLAIM_FEE_SOL,
3814
+ streamflowFee: DEFAULT_STREAMFLOW_FEE,
3815
+ partnerFee: 0
3816
+ };
3770
3817
  }
3771
3818
  /**
3772
3819
  * Returns total fee percent, streamflow fees + partner fees
3773
3820
  * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
3774
- * @param chainSpecificParams additional parameters required by chain client
3775
3821
  * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
3776
3822
  */
3777
3823
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -3798,6 +3844,21 @@ var SolanaStreamClient = class {
3798
3844
  const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
3799
3845
  return senderPublicKey.equals(pda);
3800
3846
  }
3847
+ async flatBuildCreateMultipleTransactionInstructions(data, extParams) {
3848
+ const dataArray = Array.isArray(data) ? data : [data];
3849
+ const results = await Promise.all(
3850
+ dataArray.map((item, index) => this.buildCreateMultipleTransactionInstructions(item, extParams, index === 0))
3851
+ );
3852
+ return {
3853
+ instructionsBatch: results.flatMap((r) => r.instructionsBatch),
3854
+ metadatas: results.flatMap((r) => r.metadatas),
3855
+ prepareInstructions: results.flatMap((r) => r.prepareInstructions),
3856
+ metadataToRecipient: results.reduce(
3857
+ (acc, r) => Object.assign(acc, r.metadataToRecipient),
3858
+ {}
3859
+ )
3860
+ };
3861
+ }
3801
3862
  /**
3802
3863
  * Utility function to generate metadata for a Contract or return existing Pubkey
3803
3864
  */
@@ -4257,6 +4318,6 @@ var timelockIDL_default = {
4257
4318
  ]
4258
4319
  };
4259
4320
 
4260
- 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 };
4321
+ 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_AUTO_CLAIM_FEE_SOL, DEFAULT_CREATION_FEE_SOL, 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, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, createStreamInstruction, createUncheckedStreamInstruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveTestOraclePDA, extractSolanaErrorCode, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL_default as timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction };
4261
4322
  //# sourceMappingURL=index.js.map
4262
4323
  //# sourceMappingURL=index.js.map