@streamflow/stream 10.0.0-alpha.p313.b8f5b98 → 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.
@@ -93,7 +93,12 @@ interface ITransactionResult {
93
93
  ixs: TransactionInstruction[];
94
94
  txId: string;
95
95
  }
96
+ /**
97
+ * Schema outlining vesting protocol fees.
98
+ */
96
99
  interface IFees {
100
+ creationFeeSol?: number;
101
+ autoClaimFeeSol?: number;
97
102
  streamflowFee: number;
98
103
  partnerFee: number;
99
104
  }
@@ -118,6 +123,7 @@ declare enum StreamType {
118
123
  Lock = "lock"
119
124
  }
120
125
  interface LinearStream {
126
+ isAligned: boolean;
121
127
  magic: number;
122
128
  version: number;
123
129
  createdAt: number;
@@ -390,7 +396,7 @@ declare class Contract implements LinearStream {
390
396
  lastRateChangeTime: number;
391
397
  fundsUnlockedAtLastRateChange: BN;
392
398
  type: StreamType;
393
- isAligned?: boolean;
399
+ isAligned: boolean;
394
400
  constructor(stream: DecodedStream);
395
401
  unlocked(currentTimestamp: number): BN;
396
402
  remaining(decimals: number): number;
@@ -487,6 +493,8 @@ type ClientCreationOptions = Omit<StreamClientOptions, "sendRate" | "sendThrottl
487
493
  declare class SolanaStreamClient {
488
494
  private readonly connection;
489
495
  private readonly programId;
496
+ private readonly partnerOracleProgramId;
497
+ private readonly feeOraclePublicKey;
490
498
  private readonly commitment;
491
499
  readonly alignedProxyProgram: Program<StreamflowAlignedUnlocks>;
492
500
  private readonly schedulingParams;
@@ -745,6 +753,10 @@ declare class SolanaStreamClient {
745
753
  * @returns Record of stream data
746
754
  */
747
755
  searchStreams(data: ISearchStreams): Promise<IProgramAccount<Stream>[]>;
756
+ private decodeStreamsFromAccounts;
757
+ private collectAlignedEntries;
758
+ private fetchAlignedProxiesByEntries;
759
+ private mapDecodedToProgramAccounts;
748
760
  /**
749
761
  * Attempts updating the stream auto withdrawal params and amount per period
750
762
  * @param {IUpdateData} data - Update parameters including stream ID and new settings
@@ -771,11 +783,16 @@ declare class SolanaStreamClient {
771
783
  */
772
784
  getDefaultStreamflowFee(): Promise<number>;
773
785
  /**
774
- * Returns total fee percent, streamflow fees + partner fees
775
- * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
776
- * @param chainSpecificParams additional parameters required by chain client
777
- * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
786
+ * Get all defaults fees applied by the protocol.
787
+ *
788
+ * Protocol will use fees set for WITHDRAWOR as default if they are set.
778
789
  */
790
+ getDefaultFees(): Promise<IFees>;
791
+ /**
792
+ * Returns total fee percent, streamflow fees + partner fees
793
+ * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
794
+ * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
795
+ */
779
796
  getTotalFee(getFeesData: IGetFeesData): Promise<number>;
780
797
  /**
781
798
  * Extracts error code from an error
@@ -1058,19 +1075,32 @@ declare const ALIGNED_UNLOCKS_PROGRAM_ID: {
1058
1075
  testnet: string;
1059
1076
  local: string;
1060
1077
  };
1078
+ declare const PARTNER_ORACLE_PROGRAM_ID: {
1079
+ devnet: string;
1080
+ mainnet: string;
1081
+ testnet: string;
1082
+ local: string;
1083
+ };
1084
+ declare const FEE_ORACLE_PUBLIC_KEY: {
1085
+ devnet: string;
1086
+ mainnet: string;
1087
+ testnet: string;
1088
+ local: string;
1089
+ };
1061
1090
  declare const ALIGNED_COMPUTE_LIMIT = 300000;
1062
1091
  declare const CONTRACT_DISCRIMINATOR: number[];
1063
1092
  declare const TEST_ORACLE_DISCRIMINATOR: number[];
1064
1093
  declare const CONTRACT_SEED: Buffer$1;
1065
1094
  declare const ESCROW_SEED: Buffer$1;
1066
1095
  declare const TEST_ORACLE_SEED: Buffer$1;
1067
- declare const PARTNER_ORACLE_PROGRAM_ID = "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa";
1068
1096
  declare const STREAMFLOW_TREASURY_PUBLIC_KEY: PublicKey;
1097
+ declare const WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
1069
1098
  declare const WITHDRAWOR_PUBLIC_KEY: PublicKey;
1070
- declare const FEE_ORACLE_PUBLIC_KEY: PublicKey;
1071
1099
  declare const AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
1072
1100
  declare const FEES_METADATA_SEED: Buffer$1;
1073
- declare const DEFAULT_STREAMFLOW_FEE = 0.99;
1101
+ declare const DEFAULT_CREATION_FEE_SOL = 90000000;
1102
+ declare const DEFAULT_AUTO_CLAIM_FEE_SOL = 190000000;
1103
+ declare const DEFAULT_STREAMFLOW_FEE = 0.19;
1074
1104
  declare const AIRDROP_AMOUNT = 1;
1075
1105
  declare const PARTNER_SCHEMA: {
1076
1106
  struct: {
@@ -1080,8 +1110,15 @@ declare const PARTNER_SCHEMA: {
1080
1110
  len: number;
1081
1111
  };
1082
1112
  };
1083
- partner_fee: string;
1084
- strm_fee: string;
1113
+ creation_fee: string;
1114
+ auto_claim_fee: string;
1115
+ token_fee_percent: string;
1116
+ buffer: {
1117
+ array: {
1118
+ type: string;
1119
+ len: number;
1120
+ };
1121
+ };
1085
1122
  };
1086
1123
  };
1087
1124
  declare const PARTNERS_SCHEMA: {
@@ -1094,8 +1131,15 @@ declare const PARTNERS_SCHEMA: {
1094
1131
  len: number;
1095
1132
  };
1096
1133
  };
1097
- partner_fee: string;
1098
- strm_fee: string;
1134
+ creation_fee: string;
1135
+ auto_claim_fee: string;
1136
+ token_fee_percent: string;
1137
+ buffer: {
1138
+ array: {
1139
+ type: string;
1140
+ len: number;
1141
+ };
1142
+ };
1099
1143
  };
1100
1144
  };
1101
1145
  };
@@ -1127,4 +1171,4 @@ declare const _default: {
1127
1171
  }[];
1128
1172
  };
1129
1173
 
1130
- export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, type Account, AlignedContract, AlignedProxyErrorCode, type AlignedStream, type AlignedStreamData, type AlignedUnlocksContract, type BatchItem, type BatchItemError, type BatchItemResult, type BatchItemSuccess, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, type ChangeOracleParams, type ClientCreationOptions, Contract, ContractErrorCode, type CreateParams, type CreateTestOracleParams, DEFAULT_STREAMFLOW_FEE, type DecodedStream, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, type IAlignedStreamConfig, type IBaseStreamConfig, type ICancelData, type ICreateAlignedStreamData, type ICreateExt, type ICreateLinearStreamData, type ICreateMultiError, type ICreateMultipleAlignedStreamData, type ICreateMultipleLinearStreamData, type ICreateMultipleStreamData, type ICreateResult, type ICreateStreamData, type ICreateStreamExt, type ICreateStreamInstructions, type IFees, type IGetAllData, type IGetFeesData, type IGetOneData, type IInteractData, type IInteractStreamExt, type IMultiTransactionResult, type IPrepareCreateStreamExt, type IPrepareStreamExt, type IRecipient, type ISearchStreams, type ITopUpData, type ITopUpStreamExt, type ITransactionExtWithInstructions, type ITransactionResult, type ITransferData, type IUpdateData, type IWithdrawData, type InstructionGenerator, type LinearStream, MAX_SAFE_UNIX_TIME_VALUE, type MetadataRecipientHashMap, ORIGINAL_CONTRACT_SENDER_OFFSET, type OracleType, type OracleTypeName, 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, type Stream, type StreamClientOptions, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, type TestOracle, type TransactionSchedulingOptions, type UpdateTestOracleParams, 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, _default as timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction };
1174
+ export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, type Account, AlignedContract, AlignedProxyErrorCode, type AlignedStream, type AlignedStreamData, type AlignedUnlocksContract, type BatchItem, type BatchItemError, type BatchItemResult, type BatchItemSuccess, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, type ChangeOracleParams, type ClientCreationOptions, Contract, ContractErrorCode, type CreateParams, type CreateTestOracleParams, DEFAULT_AUTO_CLAIM_FEE_SOL, DEFAULT_CREATION_FEE_SOL, DEFAULT_STREAMFLOW_FEE, type DecodedStream, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, type IAlignedStreamConfig, type IBaseStreamConfig, type ICancelData, type ICreateAlignedStreamData, type ICreateExt, type ICreateLinearStreamData, type ICreateMultiError, type ICreateMultipleAlignedStreamData, type ICreateMultipleLinearStreamData, type ICreateMultipleStreamData, type ICreateResult, type ICreateStreamData, type ICreateStreamExt, type ICreateStreamInstructions, type IFees, type IGetAllData, type IGetFeesData, type IGetOneData, type IInteractData, type IInteractStreamExt, type IMultiTransactionResult, type IPrepareCreateStreamExt, type IPrepareStreamExt, type IRecipient, type ISearchStreams, type ITopUpData, type ITopUpStreamExt, type ITransactionExtWithInstructions, type ITransactionResult, type ITransferData, type IUpdateData, type IWithdrawData, type InstructionGenerator, type LinearStream, MAX_SAFE_UNIX_TIME_VALUE, type MetadataRecipientHashMap, ORIGINAL_CONTRACT_SENDER_OFFSET, type OracleType, type OracleTypeName, 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, type Stream, type StreamClientOptions, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, type TestOracle, type TransactionSchedulingOptions, type UpdateTestOracleParams, 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, _default as timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction };
@@ -37,7 +37,7 @@ var isVesting = (streamData) => {
37
37
  return !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
38
38
  };
39
39
  var isAligned = (stream) => {
40
- return "minPrice" in stream && "maxPrice" in stream && "minPercentage" in stream && "maxPercentage" in stream;
40
+ return stream.isAligned;
41
41
  };
42
42
  var isCreateAlignedStreamData = (obj) => {
43
43
  return "minPrice" in obj && "maxPrice" in obj && "minPercentage" in obj && "maxPercentage" in obj;
@@ -225,25 +225,40 @@ var ALIGNED_UNLOCKS_PROGRAM_ID = {
225
225
  [ICluster.Testnet]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
226
226
  [ICluster.Local]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH"
227
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
+ };
228
240
  var ALIGNED_COMPUTE_LIMIT = 3e5;
229
241
  var CONTRACT_DISCRIMINATOR = [172, 138, 115, 242, 121, 67, 183, 26];
230
242
  var TEST_ORACLE_DISCRIMINATOR = [198, 49, 63, 134, 232, 251, 168, 28];
231
243
  var CONTRACT_SEED = Buffer.from("contract", "utf-8");
232
244
  var ESCROW_SEED = Buffer.from("strm", "utf-8");
233
245
  var TEST_ORACLE_SEED = Buffer.from("test-oracle", "utf-8");
234
- var PARTNER_ORACLE_PROGRAM_ID = "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa";
235
246
  var STREAMFLOW_TREASURY_PUBLIC_KEY = new PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
236
- var WITHDRAWOR_PUBLIC_KEY = new PublicKey("wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u");
237
- var FEE_ORACLE_PUBLIC_KEY = new PublicKey("B743wFVk2pCYhV91cn287e1xY7f1vt4gdY48hhNiuQmT");
247
+ var WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
248
+ var WITHDRAWOR_PUBLIC_KEY = new PublicKey(WITHDRAWOR);
238
249
  var AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
239
250
  var FEES_METADATA_SEED = Buffer.from("strm_fees");
240
- 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;
241
254
  var AIRDROP_AMOUNT = 1;
242
255
  var PARTNER_SCHEMA = {
243
256
  struct: {
244
257
  pubkey: { array: { type: "u8", len: 32 } },
245
- partner_fee: "f32",
246
- strm_fee: "f32"
258
+ creation_fee: "u32",
259
+ auto_claim_fee: "u32",
260
+ token_fee_percent: "f32",
261
+ buffer: { array: { type: "u8", len: 16 } }
247
262
  }
248
263
  };
249
264
  var PARTNERS_SCHEMA = { array: { type: PARTNER_SCHEMA } };
@@ -2496,6 +2511,8 @@ var SolanaStreamClient = class {
2496
2511
  this.commitment = commitment;
2497
2512
  this.connection = new Connection(optionsOrClusterUrl, this.commitment);
2498
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]);
2499
2516
  this.schedulingParams = {
2500
2517
  sendThrottler: sendThrottler ?? buildSendThrottler(sendRate)
2501
2518
  };
@@ -2510,6 +2527,8 @@ var SolanaStreamClient = class {
2510
2527
  this.commitment = commitment2;
2511
2528
  this.connection = new Connection(clusterUrl, this.commitment);
2512
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]);
2513
2532
  const schedulingOptions = sendScheduler && "sendRate" in sendScheduler ? sendScheduler : void 0;
2514
2533
  const sendThrottler2 = !sendScheduler ? buildSendThrottler(1) : "sendRate" in sendScheduler ? buildSendThrottler(sendScheduler.sendRate ?? 1, sendScheduler.sendInterval) : sendScheduler;
2515
2534
  this.schedulingParams = {
@@ -2550,7 +2569,7 @@ var SolanaStreamClient = class {
2550
2569
  const { partner, amount, tokenProgramId } = data;
2551
2570
  const { isNative, sender, customInstructions } = extParams;
2552
2571
  assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2553
- const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2572
+ const partnerPublicKey = partner ? new PublicKey(partner) : sender.publicKey;
2554
2573
  const mintPublicKey = new PublicKey(data.tokenId);
2555
2574
  const ixs = await this.getCreateATAInstructions(
2556
2575
  [partnerPublicKey],
@@ -2686,7 +2705,7 @@ var SolanaStreamClient = class {
2686
2705
  if (!tokenProgramId) {
2687
2706
  tokenProgramId = (await getMintAndProgram(this.connection, mintPublicKey)).tokenProgramId;
2688
2707
  }
2689
- const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2708
+ const partnerPublicKey = partner ? new PublicKey(partner) : sender.publicKey;
2690
2709
  const streamflowProgramPublicKey = new PublicKey(this.programId);
2691
2710
  const escrowPDA = deriveEscrowPDA(streamflowProgramPublicKey, metadataPubKey);
2692
2711
  const oracle = priceOracle ?? deriveTestOraclePDA(this.alignedProxyProgram.programId, mintPublicKey, sender.publicKey);
@@ -2733,7 +2752,7 @@ var SolanaStreamClient = class {
2733
2752
  partner: partnerPublicKey,
2734
2753
  recipient: recipientPublicKey,
2735
2754
  withdrawor: WITHDRAWOR_PUBLIC_KEY,
2736
- feeOracle: FEE_ORACLE_PUBLIC_KEY,
2755
+ feeOracle: this.feeOraclePublicKey,
2737
2756
  priceOracle: oracle,
2738
2757
  tokenProgram: tokenProgramId,
2739
2758
  streamflowProgram: this.programId
@@ -2789,7 +2808,7 @@ var SolanaStreamClient = class {
2789
2808
  const senderTokens = await ata(mintPublicKey, sender.publicKey, tokenProgramId);
2790
2809
  const recipientTokens = await ata(mintPublicKey, recipientPublicKey, tokenProgramId);
2791
2810
  const streamflowTreasuryTokens = await ata(mintPublicKey, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
2792
- const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2811
+ const partnerPublicKey = partner ? new PublicKey(partner) : sender.publicKey;
2793
2812
  const partnerTokens = await ata(mintPublicKey, partnerPublicKey, tokenProgramId);
2794
2813
  ixs.push(
2795
2814
  await createStreamInstruction(
@@ -2824,7 +2843,7 @@ var SolanaStreamClient = class {
2824
2843
  partner: partnerPublicKey,
2825
2844
  partnerTokens,
2826
2845
  mint: new PublicKey(mint),
2827
- feeOracle: FEE_ORACLE_PUBLIC_KEY,
2846
+ feeOracle: this.feeOraclePublicKey,
2828
2847
  rent: SYSVAR_RENT_PUBKEY,
2829
2848
  timelockProgram: this.programId,
2830
2849
  tokenProgram: tokenProgramId,
@@ -2913,7 +2932,7 @@ var SolanaStreamClient = class {
2913
2932
  );
2914
2933
  const { tokenProgramId } = await getMintAndProgram(this.connection, mintPublicKey);
2915
2934
  const senderTokens = await ata(mintPublicKey, sender.publicKey, tokenProgramId);
2916
- const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
2935
+ const partnerPublicKey = partner ? new PublicKey(partner) : sender.publicKey;
2917
2936
  const ixs = prepareBaseInstructions(this.connection, {
2918
2937
  computePrice,
2919
2938
  computeLimit
@@ -2951,7 +2970,7 @@ var SolanaStreamClient = class {
2951
2970
  metadata: metadataPubKey,
2952
2971
  escrowTokens,
2953
2972
  mint: new PublicKey(mint),
2954
- feeOracle: FEE_ORACLE_PUBLIC_KEY,
2973
+ feeOracle: this.feeOraclePublicKey,
2955
2974
  rent: SYSVAR_RENT_PUBKEY,
2956
2975
  timelockProgram: this.programId,
2957
2976
  tokenProgram: tokenProgramId,
@@ -2976,7 +2995,7 @@ var SolanaStreamClient = class {
2976
2995
  const metadatas = [];
2977
2996
  const metadataToRecipient = {};
2978
2997
  const instructionsBatch = [];
2979
- const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
2998
+ const partnerPublicKey = data.partner ? new PublicKey(data.partner) : sender.publicKey;
2980
2999
  const mintPublicKey = new PublicKey(data.tokenId);
2981
3000
  if (recipients.length === 0) {
2982
3001
  throw new Error("Recipients array is empty!");
@@ -3654,20 +3673,41 @@ var SolanaStreamClient = class {
3654
3673
  const accounts = await this.connection.getProgramAccounts(this.programId, {
3655
3674
  filters
3656
3675
  });
3657
- const mapped = await Promise.all(
3658
- accounts.map(async ({ pubkey, account }) => {
3659
- const stream = decodeStream(account.data);
3660
- if (this.isAlignedUnlock(pubkey, stream.sender)) {
3661
- const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
3662
- deriveContractPDA(this.alignedProxyProgram.programId, pubkey)
3663
- );
3664
- invariant(alignedProxy, "Couldn't get aligned proxy account info");
3665
- return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
3666
- }
3667
- return { publicKey: pubkey, account: new Contract(stream) };
3668
- })
3669
- );
3670
- 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
+ });
3671
3711
  }
3672
3712
  /**
3673
3713
  * Attempts updating the stream auto withdrawal params and amount per period
@@ -3737,37 +3777,49 @@ var SolanaStreamClient = class {
3737
3777
  * @returns Fees
3738
3778
  */
3739
3779
  async getFees({ address }) {
3740
- const [metadataPubKey] = PublicKey.findProgramAddressSync(
3741
- [Buffer.from(FEES_METADATA_SEED)],
3742
- new PublicKey(PARTNER_ORACLE_PROGRAM_ID)
3743
- );
3744
- const data = await this.connection.getAccountInfo(metadataPubKey);
3780
+ const data = await this.connection.getAccountInfo(this.feeOraclePublicKey);
3745
3781
  if (!data) {
3746
3782
  return null;
3747
3783
  }
3748
3784
  const partners = borsh.deserialize(PARTNERS_SCHEMA, data.data);
3749
- const filteredPartners = partners.filter((item) => new PublicKey(item.pubkey).toString() === address);
3750
- if (filteredPartners.length === 0) {
3751
- 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
+ }
3752
3795
  }
3753
- return {
3754
- streamflowFee: Number(filteredPartners[0].strm_fee.toFixed(4)),
3755
- partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
3756
- };
3796
+ return null;
3757
3797
  }
3758
3798
  /**
3759
3799
  * Gets default streamflow fee
3760
3800
  * @returns Default streamflow fee
3761
3801
  */
3762
3802
  async getDefaultStreamflowFee() {
3763
- return DEFAULT_STREAMFLOW_FEE;
3803
+ return (await this.getDefaultFees()).streamflowFee;
3764
3804
  }
3765
3805
  /**
3766
- * Returns total fee percent, streamflow fees + partner fees
3767
- * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
3768
- * @param chainSpecificParams additional parameters required by chain client
3769
- * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
3806
+ * Get all defaults fees applied by the protocol.
3807
+ *
3808
+ * Protocol will use fees set for WITHDRAWOR as default if they are set.
3770
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
+ };
3817
+ }
3818
+ /**
3819
+ * Returns total fee percent, streamflow fees + partner fees
3820
+ * @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
3821
+ * @returns fee as floating number, so if fee is 0.99%, it will return 0.99
3822
+ */
3771
3823
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3772
3824
  async getTotalFee(getFeesData) {
3773
3825
  const fees = await this.getFees(getFeesData);
@@ -4266,6 +4318,6 @@ var timelockIDL_default = {
4266
4318
  ]
4267
4319
  };
4268
4320
 
4269
- 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, 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 };
4270
4322
  //# sourceMappingURL=index.js.map
4271
4323
  //# sourceMappingURL=index.js.map