@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/README.md +148 -3
- package/dist/cjs/index.cjs +129 -66
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/solana/index.cjs +129 -66
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +61 -21
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +127 -66
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +61 -21
- package/dist/esm/solana/index.js +127 -66
- 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
|
}
|
|
@@ -114,11 +119,11 @@ declare enum StreamDirection {
|
|
|
114
119
|
}
|
|
115
120
|
declare enum StreamType {
|
|
116
121
|
All = "all",
|
|
117
|
-
Payment = "payment",
|
|
118
122
|
Vesting = "vesting",
|
|
119
123
|
Lock = "lock"
|
|
120
124
|
}
|
|
121
125
|
interface LinearStream {
|
|
126
|
+
isAligned: boolean;
|
|
122
127
|
magic: number;
|
|
123
128
|
version: number;
|
|
124
129
|
createdAt: number;
|
|
@@ -391,7 +396,7 @@ declare class Contract implements LinearStream {
|
|
|
391
396
|
lastRateChangeTime: number;
|
|
392
397
|
fundsUnlockedAtLastRateChange: BN;
|
|
393
398
|
type: StreamType;
|
|
394
|
-
isAligned
|
|
399
|
+
isAligned: boolean;
|
|
395
400
|
constructor(stream: DecodedStream);
|
|
396
401
|
unlocked(currentTimestamp: number): BN;
|
|
397
402
|
remaining(decimals: number): number;
|
|
@@ -488,6 +493,8 @@ type ClientCreationOptions = Omit<StreamClientOptions, "sendRate" | "sendThrottl
|
|
|
488
493
|
declare class SolanaStreamClient {
|
|
489
494
|
private readonly connection;
|
|
490
495
|
private readonly programId;
|
|
496
|
+
private readonly partnerOracleProgramId;
|
|
497
|
+
private readonly feeOraclePublicKey;
|
|
491
498
|
private readonly commitment;
|
|
492
499
|
readonly alignedProxyProgram: Program<StreamflowAlignedUnlocks>;
|
|
493
500
|
private readonly schedulingParams;
|
|
@@ -554,7 +561,7 @@ declare class SolanaStreamClient {
|
|
|
554
561
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
555
562
|
* @returns Create stream instructions
|
|
556
563
|
*/
|
|
557
|
-
|
|
564
|
+
prepareCreateLinearStreamInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, tokenProgramId: streamTokenProgramId, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: IPrepareCreateStreamExt): Promise<ICreateStreamInstructions>;
|
|
558
565
|
/**
|
|
559
566
|
* Creates a new stream/vesting contract using unchecked instruction.
|
|
560
567
|
*
|
|
@@ -584,7 +591,7 @@ declare class SolanaStreamClient {
|
|
|
584
591
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
585
592
|
* @returns Create multiple transaction instructions
|
|
586
593
|
*/
|
|
587
|
-
buildCreateMultipleTransactionInstructions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt): Promise<{
|
|
594
|
+
buildCreateMultipleTransactionInstructions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt, applyCustomAfterInstructions?: boolean): Promise<{
|
|
588
595
|
instructionsBatch: {
|
|
589
596
|
ixs: TransactionInstruction[];
|
|
590
597
|
metadata: Keypair | undefined;
|
|
@@ -620,7 +627,7 @@ declare class SolanaStreamClient {
|
|
|
620
627
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
621
628
|
* @returns Multiple transaction information
|
|
622
629
|
*/
|
|
623
|
-
buildCreateMultipleTransactions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt): Promise<{
|
|
630
|
+
buildCreateMultipleTransactions(data: ICreateMultipleStreamData, extParams: IPrepareCreateStreamExt, applyCustomAfterInstructions?: boolean): Promise<{
|
|
624
631
|
transactions: BatchItem[];
|
|
625
632
|
metadatas: string[];
|
|
626
633
|
metadataToRecipient: MetadataRecipientHashMap;
|
|
@@ -638,7 +645,7 @@ declare class SolanaStreamClient {
|
|
|
638
645
|
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
639
646
|
* @returns Multiple transaction information
|
|
640
647
|
*/
|
|
641
|
-
createMultiple(data: ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
648
|
+
createMultiple(data: ICreateMultipleStreamData[] | ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
642
649
|
/**
|
|
643
650
|
* Creates multiple stream/vesting contracts, and send all transactions sequentially.
|
|
644
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).
|
|
@@ -647,7 +654,7 @@ declare class SolanaStreamClient {
|
|
|
647
654
|
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
648
655
|
* @returns Multiple transaction information
|
|
649
656
|
*/
|
|
650
|
-
createMultipleSequential(data: ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
657
|
+
createMultipleSequential(data: ICreateMultipleStreamData[] | ICreateMultipleStreamData, extParams: ICreateStreamExt): Promise<IMultiTransactionResult>;
|
|
651
658
|
/**
|
|
652
659
|
* Attempts withdrawing from the specified stream.
|
|
653
660
|
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
@@ -689,7 +696,7 @@ declare class SolanaStreamClient {
|
|
|
689
696
|
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
690
697
|
* @returns Transaction instructions
|
|
691
698
|
*/
|
|
692
|
-
|
|
699
|
+
prepareCancelLinearStream({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
|
|
693
700
|
/**
|
|
694
701
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
695
702
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
@@ -746,6 +753,10 @@ declare class SolanaStreamClient {
|
|
|
746
753
|
* @returns Record of stream data
|
|
747
754
|
*/
|
|
748
755
|
searchStreams(data: ISearchStreams): Promise<IProgramAccount<Stream>[]>;
|
|
756
|
+
private decodeStreamsFromAccounts;
|
|
757
|
+
private collectAlignedEntries;
|
|
758
|
+
private fetchAlignedProxiesByEntries;
|
|
759
|
+
private mapDecodedToProgramAccounts;
|
|
749
760
|
/**
|
|
750
761
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
751
762
|
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
@@ -771,10 +782,15 @@ declare class SolanaStreamClient {
|
|
|
771
782
|
* @returns Default streamflow fee
|
|
772
783
|
*/
|
|
773
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>;
|
|
774
791
|
/**
|
|
775
792
|
* Returns total fee percent, streamflow fees + partner fees
|
|
776
793
|
* @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
|
|
777
|
-
* @param chainSpecificParams additional parameters required by chain client
|
|
778
794
|
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
779
795
|
*/
|
|
780
796
|
getTotalFee(getFeesData: IGetFeesData): Promise<number>;
|
|
@@ -788,6 +804,7 @@ declare class SolanaStreamClient {
|
|
|
788
804
|
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
789
805
|
*/
|
|
790
806
|
isAlignedUnlock(streamPublicKey: PublicKey, senderPublicKey: PublicKey): boolean;
|
|
807
|
+
private flatBuildCreateMultipleTransactionInstructions;
|
|
791
808
|
/**
|
|
792
809
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
793
810
|
*/
|
|
@@ -994,11 +1011,7 @@ declare const isCliffCloseToDepositedAmount: (streamData: {
|
|
|
994
1011
|
depositedAmount: BN;
|
|
995
1012
|
cliffAmount: BN;
|
|
996
1013
|
}) => boolean;
|
|
997
|
-
declare const isPayment: (streamData: {
|
|
998
|
-
canTopup: boolean;
|
|
999
|
-
}) => boolean;
|
|
1000
1014
|
declare const isVesting: (streamData: {
|
|
1001
|
-
canTopup: boolean;
|
|
1002
1015
|
depositedAmount: BN;
|
|
1003
1016
|
cliffAmount: BN;
|
|
1004
1017
|
minPrice?: number;
|
|
@@ -1062,19 +1075,32 @@ declare const ALIGNED_UNLOCKS_PROGRAM_ID: {
|
|
|
1062
1075
|
testnet: string;
|
|
1063
1076
|
local: string;
|
|
1064
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
|
+
};
|
|
1065
1090
|
declare const ALIGNED_COMPUTE_LIMIT = 300000;
|
|
1066
1091
|
declare const CONTRACT_DISCRIMINATOR: number[];
|
|
1067
1092
|
declare const TEST_ORACLE_DISCRIMINATOR: number[];
|
|
1068
1093
|
declare const CONTRACT_SEED: Buffer$1;
|
|
1069
1094
|
declare const ESCROW_SEED: Buffer$1;
|
|
1070
1095
|
declare const TEST_ORACLE_SEED: Buffer$1;
|
|
1071
|
-
declare const PARTNER_ORACLE_PROGRAM_ID = "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa";
|
|
1072
1096
|
declare const STREAMFLOW_TREASURY_PUBLIC_KEY: PublicKey;
|
|
1097
|
+
declare const WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
|
|
1073
1098
|
declare const WITHDRAWOR_PUBLIC_KEY: PublicKey;
|
|
1074
|
-
declare const FEE_ORACLE_PUBLIC_KEY: PublicKey;
|
|
1075
1099
|
declare const AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
|
|
1076
1100
|
declare const FEES_METADATA_SEED: Buffer$1;
|
|
1077
|
-
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;
|
|
1078
1104
|
declare const AIRDROP_AMOUNT = 1;
|
|
1079
1105
|
declare const PARTNER_SCHEMA: {
|
|
1080
1106
|
struct: {
|
|
@@ -1084,8 +1110,15 @@ declare const PARTNER_SCHEMA: {
|
|
|
1084
1110
|
len: number;
|
|
1085
1111
|
};
|
|
1086
1112
|
};
|
|
1087
|
-
|
|
1088
|
-
|
|
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
|
+
};
|
|
1089
1122
|
};
|
|
1090
1123
|
};
|
|
1091
1124
|
declare const PARTNERS_SCHEMA: {
|
|
@@ -1098,8 +1131,15 @@ declare const PARTNERS_SCHEMA: {
|
|
|
1098
1131
|
len: number;
|
|
1099
1132
|
};
|
|
1100
1133
|
};
|
|
1101
|
-
|
|
1102
|
-
|
|
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
|
+
};
|
|
1103
1143
|
};
|
|
1104
1144
|
};
|
|
1105
1145
|
};
|
|
@@ -1131,4 +1171,4 @@ declare const _default: {
|
|
|
1131
1171
|
}[];
|
|
1132
1172
|
};
|
|
1133
1173
|
|
|
1134
|
-
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,
|
|
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/solana/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 !
|
|
37
|
+
return !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
|
|
41
38
|
};
|
|
42
39
|
var isAligned = (stream) => {
|
|
43
|
-
return
|
|
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 "
|
|
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
|
|
244
|
-
var
|
|
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
|
|
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
|
-
|
|
253
|
-
|
|
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) :
|
|
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.
|
|
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) :
|
|
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:
|
|
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
|
|
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) :
|
|
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:
|
|
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) :
|
|
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:
|
|
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
|
|
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
|
-
|
|
2997
|
-
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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.
|
|
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
|
|
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
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
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
|
|
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
|
|
3756
|
-
|
|
3757
|
-
|
|
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
|
|
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,
|
|
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
|