@streamflow/stream 10.0.0-alpha.p313.fe3720a → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +146 -1
- package/dist/cjs/index.cjs +123 -52
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/solana/index.cjs +123 -52
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +59 -14
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +121 -53
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +59 -14
- package/dist/esm/solana/index.js +121 -53
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -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
|
|
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;
|
|
@@ -583,7 +591,7 @@ declare class SolanaStreamClient {
|
|
|
583
591
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
584
592
|
* @returns Create multiple transaction instructions
|
|
585
593
|
*/
|
|
586
|
-
buildCreateMultipleTransactionInstructions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt): Promise<{
|
|
594
|
+
buildCreateMultipleTransactionInstructions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt, applyCustomAfterInstructions?: boolean): Promise<{
|
|
587
595
|
instructionsBatch: {
|
|
588
596
|
ixs: TransactionInstruction[];
|
|
589
597
|
metadata: Keypair | undefined;
|
|
@@ -619,7 +627,7 @@ declare class SolanaStreamClient {
|
|
|
619
627
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
620
628
|
* @returns Multiple transaction information
|
|
621
629
|
*/
|
|
622
|
-
buildCreateMultipleTransactions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt): Promise<{
|
|
630
|
+
buildCreateMultipleTransactions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt, applyCustomAfterInstructions?: boolean): Promise<{
|
|
623
631
|
transactions: BatchItem[];
|
|
624
632
|
metadatas: string[];
|
|
625
633
|
metadataToRecipient: MetadataRecipientHashMap;
|
|
@@ -637,7 +645,7 @@ declare class SolanaStreamClient {
|
|
|
637
645
|
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
638
646
|
* @returns Multiple transaction information
|
|
639
647
|
*/
|
|
640
|
-
createMultiple(data: ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
648
|
+
createMultiple(data: ICreateMultipleStreamData[] | ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
641
649
|
/**
|
|
642
650
|
* Creates multiple stream/vesting contracts, and send all transactions sequentially.
|
|
643
651
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
@@ -646,7 +654,7 @@ declare class SolanaStreamClient {
|
|
|
646
654
|
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
647
655
|
* @returns Multiple transaction information
|
|
648
656
|
*/
|
|
649
|
-
createMultipleSequential(data: ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
657
|
+
createMultipleSequential(data: ICreateMultipleStreamData[] | ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
650
658
|
/**
|
|
651
659
|
* Attempts withdrawing from the specified stream.
|
|
652
660
|
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
@@ -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
|
|
@@ -770,10 +782,15 @@ declare class SolanaStreamClient {
|
|
|
770
782
|
* @returns Default streamflow fee
|
|
771
783
|
*/
|
|
772
784
|
getDefaultStreamflowFee(): Promise<number>;
|
|
785
|
+
/**
|
|
786
|
+
* Get all defaults fees applied by the protocol.
|
|
787
|
+
*
|
|
788
|
+
* Protocol will use fees set for WITHDRAWOR as default if they are set.
|
|
789
|
+
*/
|
|
790
|
+
getDefaultFees(): Promise<IFees>;
|
|
773
791
|
/**
|
|
774
792
|
* Returns total fee percent, streamflow fees + partner fees
|
|
775
793
|
* @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
794
|
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
778
795
|
*/
|
|
779
796
|
getTotalFee(getFeesData: IGetFeesData): Promise<number>;
|
|
@@ -787,6 +804,7 @@ declare class SolanaStreamClient {
|
|
|
787
804
|
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
788
805
|
*/
|
|
789
806
|
isAlignedUnlock(streamPublicKey: PublicKey, senderPublicKey: PublicKey): boolean;
|
|
807
|
+
private flatBuildCreateMultipleTransactionInstructions;
|
|
790
808
|
/**
|
|
791
809
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
792
810
|
*/
|
|
@@ -1057,19 +1075,32 @@ declare const ALIGNED_UNLOCKS_PROGRAM_ID: {
|
|
|
1057
1075
|
testnet: string;
|
|
1058
1076
|
local: string;
|
|
1059
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
|
+
};
|
|
1060
1090
|
declare const ALIGNED_COMPUTE_LIMIT = 300000;
|
|
1061
1091
|
declare const CONTRACT_DISCRIMINATOR: number[];
|
|
1062
1092
|
declare const TEST_ORACLE_DISCRIMINATOR: number[];
|
|
1063
1093
|
declare const CONTRACT_SEED: Buffer$1;
|
|
1064
1094
|
declare const ESCROW_SEED: Buffer$1;
|
|
1065
1095
|
declare const TEST_ORACLE_SEED: Buffer$1;
|
|
1066
|
-
declare const PARTNER_ORACLE_PROGRAM_ID = "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa";
|
|
1067
1096
|
declare const STREAMFLOW_TREASURY_PUBLIC_KEY: PublicKey;
|
|
1097
|
+
declare const WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
|
|
1068
1098
|
declare const WITHDRAWOR_PUBLIC_KEY: PublicKey;
|
|
1069
|
-
declare const FEE_ORACLE_PUBLIC_KEY: PublicKey;
|
|
1070
1099
|
declare const AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
|
|
1071
1100
|
declare const FEES_METADATA_SEED: Buffer$1;
|
|
1072
|
-
declare const
|
|
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;
|
|
1073
1104
|
declare const AIRDROP_AMOUNT = 1;
|
|
1074
1105
|
declare const PARTNER_SCHEMA: {
|
|
1075
1106
|
struct: {
|
|
@@ -1079,8 +1110,15 @@ declare const PARTNER_SCHEMA: {
|
|
|
1079
1110
|
len: number;
|
|
1080
1111
|
};
|
|
1081
1112
|
};
|
|
1082
|
-
|
|
1083
|
-
|
|
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
|
+
};
|
|
1084
1122
|
};
|
|
1085
1123
|
};
|
|
1086
1124
|
declare const PARTNERS_SCHEMA: {
|
|
@@ -1093,8 +1131,15 @@ declare const PARTNERS_SCHEMA: {
|
|
|
1093
1131
|
len: number;
|
|
1094
1132
|
};
|
|
1095
1133
|
};
|
|
1096
|
-
|
|
1097
|
-
|
|
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
|
+
};
|
|
1098
1143
|
};
|
|
1099
1144
|
};
|
|
1100
1145
|
};
|
|
@@ -1126,4 +1171,4 @@ declare const _default: {
|
|
|
1126
1171
|
}[];
|
|
1127
1172
|
};
|
|
1128
1173
|
|
|
1129
|
-
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 };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, Account, AlignedContract, AlignedProxyErrorCode, AlignedStream, AlignedStreamData, AlignedUnlocksContract, BatchItem, BatchItemError, BatchItemResult, BatchItemSuccess, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, ChangeOracleParams, ClientCreationOptions, Contract, ContractErrorCode, CreateParams, CreateTestOracleParams, DEFAULT_STREAMFLOW_FEE, DecodedStream, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, IAlignedStreamConfig, IBaseStreamConfig, ICancelData, ICreateAlignedStreamData, ICreateExt, ICreateLinearStreamData, ICreateMultiError, ICreateMultipleAlignedStreamData, ICreateMultipleLinearStreamData, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, ICreateStreamExt, ICreateStreamInstructions, IFees, IGetAllData, IGetFeesData, IGetOneData, IInteractData, IInteractStreamExt, IMultiTransactionResult, IPrepareCreateStreamExt, IPrepareStreamExt, IRecipient, ISearchStreams, ITopUpData, ITopUpStreamExt, ITransactionExtWithInstructions, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, InstructionGenerator, LinearStream, MAX_SAFE_UNIX_TIME_VALUE, MetadataRecipientHashMap, ORIGINAL_CONTRACT_SENDER_OFFSET, OracleType, 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, Stream, StreamClientOptions, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, TestOracle, TransactionSchedulingOptions, 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, timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction } from './solana/index.js';
|
|
1
|
+
export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, Account, AlignedContract, AlignedProxyErrorCode, AlignedStream, AlignedStreamData, AlignedUnlocksContract, BatchItem, BatchItemError, BatchItemResult, BatchItemSuccess, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, ChangeOracleParams, ClientCreationOptions, Contract, ContractErrorCode, CreateParams, CreateTestOracleParams, DEFAULT_AUTO_CLAIM_FEE_SOL, DEFAULT_CREATION_FEE_SOL, DEFAULT_STREAMFLOW_FEE, DecodedStream, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, IAlignedStreamConfig, IBaseStreamConfig, ICancelData, ICreateAlignedStreamData, ICreateExt, ICreateLinearStreamData, ICreateMultiError, ICreateMultipleAlignedStreamData, ICreateMultipleLinearStreamData, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, ICreateStreamExt, ICreateStreamInstructions, IFees, IGetAllData, IGetFeesData, IGetOneData, IInteractData, IInteractStreamExt, IMultiTransactionResult, IPrepareCreateStreamExt, IPrepareStreamExt, IRecipient, ISearchStreams, ITopUpData, ITopUpStreamExt, ITransactionExtWithInstructions, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, InstructionGenerator, LinearStream, MAX_SAFE_UNIX_TIME_VALUE, MetadataRecipientHashMap, ORIGINAL_CONTRACT_SENDER_OFFSET, OracleType, 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, Stream, StreamClientOptions, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, TestOracle, TransactionSchedulingOptions, 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, timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction } from './solana/index.js';
|
|
2
2
|
export { ContractError, ICluster, getBN, getNumberFromBN } from '@streamflow/common';
|
|
3
3
|
import 'p-queue';
|
|
4
4
|
import '@solana/web3.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -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
|
|
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
|
|
237
|
-
var
|
|
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
|
|
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
|
-
|
|
246
|
-
|
|
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) :
|
|
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) :
|
|
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:
|
|
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) :
|
|
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:
|
|
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) :
|
|
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:
|
|
2973
|
+
feeOracle: this.feeOraclePublicKey,
|
|
2955
2974
|
rent: SYSVAR_RENT_PUBKEY,
|
|
2956
2975
|
timelockProgram: this.programId,
|
|
2957
2976
|
tokenProgram: tokenProgramId,
|
|
@@ -2969,15 +2988,14 @@ var SolanaStreamClient = class {
|
|
|
2969
2988
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2970
2989
|
* @returns Create multiple transaction instructions
|
|
2971
2990
|
*/
|
|
2972
|
-
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
2991
|
+
async buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions = true) {
|
|
2973
2992
|
const { recipients, ...streamParams } = data;
|
|
2974
2993
|
const { sender, metadataPubKeys: metadataPubKeysExt, isNative, customInstructions } = extParams;
|
|
2975
2994
|
assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2976
2995
|
const metadatas = [];
|
|
2977
2996
|
const metadataToRecipient = {};
|
|
2978
2997
|
const instructionsBatch = [];
|
|
2979
|
-
const
|
|
2980
|
-
const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
2998
|
+
const partnerPublicKey = data.partner ? new PublicKey(data.partner) : sender.publicKey;
|
|
2981
2999
|
const mintPublicKey = new PublicKey(data.tokenId);
|
|
2982
3000
|
if (recipients.length === 0) {
|
|
2983
3001
|
throw new Error("Recipients array is empty!");
|
|
@@ -2986,14 +3004,16 @@ var SolanaStreamClient = class {
|
|
|
2986
3004
|
const recipientData = recipients[i];
|
|
2987
3005
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
2988
3006
|
const createStreamExtParams = {
|
|
2989
|
-
|
|
2990
|
-
|
|
3007
|
+
...extParams,
|
|
3008
|
+
metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
|
|
2991
3009
|
};
|
|
2992
3010
|
const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
|
|
2993
3011
|
createStreamData,
|
|
2994
3012
|
createStreamExtParams
|
|
2995
3013
|
);
|
|
2996
|
-
|
|
3014
|
+
if (applyCustomAfterInstructions) {
|
|
3015
|
+
await this.applyCustomAfterInstructions(ixs, customInstructions, metadataPubKey);
|
|
3016
|
+
}
|
|
2997
3017
|
metadataToRecipient[metadataPubKey.toBase58()] = recipientData;
|
|
2998
3018
|
metadatas.push(metadataPubKey.toBase58());
|
|
2999
3019
|
instructionsBatch.push({
|
|
@@ -3041,9 +3061,9 @@ var SolanaStreamClient = class {
|
|
|
3041
3061
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
3042
3062
|
* @returns Multiple transaction information
|
|
3043
3063
|
*/
|
|
3044
|
-
async buildCreateMultipleTransactions(data, extParams) {
|
|
3064
|
+
async buildCreateMultipleTransactions(data, extParams, applyCustomAfterInstructions = true) {
|
|
3045
3065
|
const { sender } = extParams;
|
|
3046
|
-
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams);
|
|
3066
|
+
const { instructionsBatch, metadatas, metadataToRecipient, prepareInstructions } = await this.buildCreateMultipleTransactionInstructions(data, extParams, applyCustomAfterInstructions);
|
|
3047
3067
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
3048
3068
|
const batch = [];
|
|
3049
3069
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
@@ -3074,7 +3094,7 @@ var SolanaStreamClient = class {
|
|
|
3074
3094
|
if (!sender.publicKey) {
|
|
3075
3095
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3076
3096
|
}
|
|
3077
|
-
const { instructionsBatch, metadatas,
|
|
3097
|
+
const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
|
|
3078
3098
|
const errors = [];
|
|
3079
3099
|
const signatures = [];
|
|
3080
3100
|
const metadataPubKeys = metadataPubKeysExt || [];
|
|
@@ -3139,7 +3159,7 @@ var SolanaStreamClient = class {
|
|
|
3139
3159
|
if (!sender.publicKey) {
|
|
3140
3160
|
throw new Error("Sender's PublicKey is not available, check passed wallet adapter!");
|
|
3141
3161
|
}
|
|
3142
|
-
const { instructionsBatch, metadatas,
|
|
3162
|
+
const { instructionsBatch, metadatas, prepareInstructions, metadataToRecipient } = await this.flatBuildCreateMultipleTransactionInstructions(data, extParams);
|
|
3143
3163
|
const errors = [];
|
|
3144
3164
|
const signatures = [];
|
|
3145
3165
|
const batch = [];
|
|
@@ -3653,20 +3673,41 @@ var SolanaStreamClient = class {
|
|
|
3653
3673
|
const accounts = await this.connection.getProgramAccounts(this.programId, {
|
|
3654
3674
|
filters
|
|
3655
3675
|
});
|
|
3656
|
-
const
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
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
|
+
});
|
|
3670
3711
|
}
|
|
3671
3712
|
/**
|
|
3672
3713
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
@@ -3736,35 +3777,47 @@ var SolanaStreamClient = class {
|
|
|
3736
3777
|
* @returns Fees
|
|
3737
3778
|
*/
|
|
3738
3779
|
async getFees({ address }) {
|
|
3739
|
-
const
|
|
3740
|
-
[Buffer.from(FEES_METADATA_SEED)],
|
|
3741
|
-
new PublicKey(PARTNER_ORACLE_PROGRAM_ID)
|
|
3742
|
-
);
|
|
3743
|
-
const data = await this.connection.getAccountInfo(metadataPubKey);
|
|
3780
|
+
const data = await this.connection.getAccountInfo(this.feeOraclePublicKey);
|
|
3744
3781
|
if (!data) {
|
|
3745
3782
|
return null;
|
|
3746
3783
|
}
|
|
3747
3784
|
const partners = borsh.deserialize(PARTNERS_SCHEMA, data.data);
|
|
3748
|
-
const
|
|
3749
|
-
|
|
3750
|
-
|
|
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
|
+
}
|
|
3751
3795
|
}
|
|
3752
|
-
return
|
|
3753
|
-
streamflowFee: Number(filteredPartners[0].strm_fee.toFixed(4)),
|
|
3754
|
-
partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
|
|
3755
|
-
};
|
|
3796
|
+
return null;
|
|
3756
3797
|
}
|
|
3757
3798
|
/**
|
|
3758
3799
|
* Gets default streamflow fee
|
|
3759
3800
|
* @returns Default streamflow fee
|
|
3760
3801
|
*/
|
|
3761
3802
|
async getDefaultStreamflowFee() {
|
|
3762
|
-
return
|
|
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
|
+
};
|
|
3763
3817
|
}
|
|
3764
3818
|
/**
|
|
3765
3819
|
* Returns total fee percent, streamflow fees + partner fees
|
|
3766
3820
|
* @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
|
|
3767
|
-
* @param chainSpecificParams additional parameters required by chain client
|
|
3768
3821
|
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
3769
3822
|
*/
|
|
3770
3823
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -3791,6 +3844,21 @@ var SolanaStreamClient = class {
|
|
|
3791
3844
|
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
3792
3845
|
return senderPublicKey.equals(pda);
|
|
3793
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
|
+
}
|
|
3794
3862
|
/**
|
|
3795
3863
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
3796
3864
|
*/
|
|
@@ -4250,6 +4318,6 @@ var timelockIDL_default = {
|
|
|
4250
4318
|
]
|
|
4251
4319
|
};
|
|
4252
4320
|
|
|
4253
|
-
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 };
|
|
4254
4322
|
//# sourceMappingURL=index.js.map
|
|
4255
4323
|
//# sourceMappingURL=index.js.map
|