@streamflow/stream 13.3.1 → 13.5.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/dist/cjs/{index-B2NHAfM3.d.cts → index-BLL6w66C.d.cts} +11 -1
- package/dist/cjs/index.cjs +125 -35
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/solana/api/index.cjs +122 -35
- package/dist/cjs/solana/api/index.cjs.map +1 -1
- package/dist/cjs/solana/api/index.d.cts +1 -1
- package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.d.cts +11 -0
- package/dist/cjs/solana/index.cjs +125 -35
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +22 -3
- package/dist/esm/{index-aMPWxsk6.d.ts → index-FDwxtRYV.d.ts} +11 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +197 -110
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/api/index.d.ts +1 -1
- package/dist/esm/solana/api/index.js +196 -109
- package/dist/esm/solana/api/index.js.map +1 -1
- package/dist/esm/solana/descriptor/idl/streamflow_aligned_unlocks.json +12 -1
- package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.d.ts +11 -0
- package/dist/esm/solana/index.d.ts +22 -3
- package/dist/esm/solana/index.js +197 -110
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import BN3 from 'bn.js';
|
|
2
2
|
import bs58 from 'bs58';
|
|
3
|
-
import { Buffer } from 'buffer';
|
|
3
|
+
import { Buffer as Buffer$1 } from 'buffer';
|
|
4
4
|
import { NATIVE_MINT, ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, getTransferHook, addExtraAccountMetasForExecute } from '@solana/spl-token';
|
|
5
5
|
import { PublicKey, TransactionInstruction, Connection, Keypair, SystemProgram, SYSVAR_RENT_PUBKEY, TransactionMessage, VersionedTransaction } from '@solana/web3.js';
|
|
6
|
-
import { ICluster, getNumberFromBN, isSignerKeypair, isSignerWallet, executeTransaction, ContractError, buildSendThrottler, assertHasPublicKey, prepareWrappedAccount, prepareTransaction, signAndExecuteTransaction, invariant, getMintAndProgram, ata, prepareBaseInstructions, getBN, createVersionedTransaction, executeMultipleTransactions, getMultipleAccountsInfoBatched, getProgramAccounts, isDev, checkOrCreateAtaBatch
|
|
6
|
+
import { ICluster, getNumberFromBN, isSignerKeypair, isSignerWallet, executeTransaction, ContractError, buildSendThrottler, assertHasPublicKey, prepareWrappedAccount, prepareTransaction, signAndExecuteTransaction, invariant, getMintAndProgram, ata, prepareBaseInstructions, getBN, createVersionedTransaction, executeMultipleTransactions, getMultipleAccountsInfoBatched, getProgramAccounts, pk, isDev, checkOrCreateAtaBatch } from '@streamflow/common';
|
|
7
7
|
export { ContractError, ICluster, getBN, getNumberFromBN } from '@streamflow/common';
|
|
8
8
|
import * as borsh from 'borsh';
|
|
9
9
|
import { Program } from '@coral-xyz/anchor';
|
|
@@ -61,6 +61,24 @@ var isTokenLock = (streamData) => {
|
|
|
61
61
|
}
|
|
62
62
|
return false;
|
|
63
63
|
};
|
|
64
|
+
var isStrictTokenLockCreate = (data, now = Math.floor(Date.now() / 1e3)) => {
|
|
65
|
+
if (data.canTopup || data.automaticWithdrawal || data.cancelableBySender || data.cancelableByRecipient || data.transferableBySender) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (!isCliffCloseToDepositedAmount({ depositedAmount: data.amount, cliffAmount: data.cliffAmount })) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (data.cliffAmount.gt(data.amount) || data.amountPerPeriod.isZero()) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
const remaining = data.amount.sub(data.cliffAmount);
|
|
75
|
+
const periodsLeft = remaining.add(data.amountPerPeriod).subn(1).div(data.amountPerPeriod);
|
|
76
|
+
const cliff = data.start === 0 ? now : data.cliff;
|
|
77
|
+
const unlockStart = cliff > 0 ? cliff : data.start;
|
|
78
|
+
const end = new BN3(unlockStart).add(periodsLeft.mul(new BN3(data.period)));
|
|
79
|
+
const cliffEndGap = end.sub(new BN3(cliff));
|
|
80
|
+
return !cliffEndGap.isNeg() && cliffEndGap.lten(MAX_CLIFF_END_GAP_SECONDS);
|
|
81
|
+
};
|
|
64
82
|
var buildStreamType = (streamData) => {
|
|
65
83
|
if (isTokenLock(streamData)) {
|
|
66
84
|
return "lock" /* Lock */;
|
|
@@ -261,16 +279,16 @@ var FEE_ORACLE_PUBLIC_KEY = {
|
|
|
261
279
|
var ALIGNED_COMPUTE_LIMIT = 3e5;
|
|
262
280
|
var CONTRACT_DISCRIMINATOR = [172, 138, 115, 242, 121, 67, 183, 26];
|
|
263
281
|
var TEST_ORACLE_DISCRIMINATOR = [198, 49, 63, 134, 232, 251, 168, 28];
|
|
264
|
-
var CONTRACT_SEED = Buffer.from("contract", "utf-8");
|
|
265
|
-
var ESCROW_SEED = Buffer.from("strm", "utf-8");
|
|
266
|
-
var TEST_ORACLE_SEED = Buffer.from("test-oracle", "utf-8");
|
|
267
|
-
var METADATA_SEED = Buffer.from("strm-met", "utf-8");
|
|
268
|
-
var REPOPULATED_METADATA_SEED = Buffer.from("strm-rep", "utf-8");
|
|
282
|
+
var CONTRACT_SEED = Buffer$1.from("contract", "utf-8");
|
|
283
|
+
var ESCROW_SEED = Buffer$1.from("strm", "utf-8");
|
|
284
|
+
var TEST_ORACLE_SEED = Buffer$1.from("test-oracle", "utf-8");
|
|
285
|
+
var METADATA_SEED = Buffer$1.from("strm-met", "utf-8");
|
|
286
|
+
var REPOPULATED_METADATA_SEED = Buffer$1.from("strm-rep", "utf-8");
|
|
269
287
|
var STREAMFLOW_TREASURY_PUBLIC_KEY = new PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
270
288
|
var WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
|
|
271
289
|
var WITHDRAWOR_PUBLIC_KEY = new PublicKey(WITHDRAWOR);
|
|
272
290
|
var AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
|
|
273
|
-
var FEES_METADATA_SEED = Buffer.from("strm_fees");
|
|
291
|
+
var FEES_METADATA_SEED = Buffer$1.from("strm_fees");
|
|
274
292
|
var DEFAULT_CREATION_FEE_SOL = 9e7;
|
|
275
293
|
var DEFAULT_AUTO_CLAIM_FEE_SOL = 19e7;
|
|
276
294
|
var DEFAULT_STREAMFLOW_FEE = 0.19;
|
|
@@ -514,7 +532,13 @@ var encodeUpdateStream = (values, data) => {
|
|
|
514
532
|
structs.push(BufferLayout.u8("cancelable_by_sender_exists"));
|
|
515
533
|
structs.push(BufferLayout.u8("cancelable_by_sender"));
|
|
516
534
|
} else {
|
|
517
|
-
structs.push(BufferLayout.u8("
|
|
535
|
+
structs.push(BufferLayout.u8("cancelable_by_sender_exists"));
|
|
536
|
+
}
|
|
537
|
+
if (values.stream_name) {
|
|
538
|
+
structs.push(BufferLayout.u8("stream_name_exists"));
|
|
539
|
+
structs.push(BufferLayout.blob(64, "stream_name"));
|
|
540
|
+
} else {
|
|
541
|
+
structs.push(BufferLayout.u8("stream_name_exists"));
|
|
518
542
|
}
|
|
519
543
|
return BufferLayout.struct(structs).encode(
|
|
520
544
|
{
|
|
@@ -529,7 +553,9 @@ var encodeUpdateStream = (values, data) => {
|
|
|
529
553
|
transferable_by_recipient_exists: values.transferable_by_recipient !== void 0 ? 1 : 0,
|
|
530
554
|
transferable_by_recipient: values.transferable_by_recipient ?? 0,
|
|
531
555
|
cancelable_by_sender_exists: values.cancelable_by_sender !== void 0 ? 1 : 0,
|
|
532
|
-
cancelable_by_sender: values.cancelable_by_sender ?? 0
|
|
556
|
+
cancelable_by_sender: values.cancelable_by_sender ?? 0,
|
|
557
|
+
stream_name_exists: values.stream_name ? 1 : 0,
|
|
558
|
+
stream_name: values.stream_name ?? 0
|
|
533
559
|
},
|
|
534
560
|
data
|
|
535
561
|
);
|
|
@@ -552,6 +578,13 @@ var calculateTotalAmountToDeposit = (depositedAmount, totalFee) => {
|
|
|
552
578
|
const totalFeeNormalized = new BN3(totalFee * FEE_NORMALIZER);
|
|
553
579
|
return depositedAmount.mul(totalFeeNormalized.add(FEE_MULTIPLIER)).div(FEE_MULTIPLIER);
|
|
554
580
|
};
|
|
581
|
+
var encodeStreamName = (name) => {
|
|
582
|
+
const encoded = new TextEncoder().encode(name);
|
|
583
|
+
return Buffer.alloc(64).fill(encoded, 0, encoded.byteLength);
|
|
584
|
+
};
|
|
585
|
+
var encodeStreamNameAsArray = (name) => {
|
|
586
|
+
return Array.from(encodeStreamName(name));
|
|
587
|
+
};
|
|
555
588
|
var decodeStream = (buf) => {
|
|
556
589
|
const raw = streamLayout.decode(buf);
|
|
557
590
|
return {
|
|
@@ -707,16 +740,14 @@ var createStreamInstruction = async (data, programId, accounts) => {
|
|
|
707
740
|
if (accounts.partnerLink) {
|
|
708
741
|
keys.push({ pubkey: accounts.partnerLink.pubkey, isSigner: accounts.partnerLink.isSigner, isWritable: false });
|
|
709
742
|
}
|
|
710
|
-
let bufferData = Buffer.alloc(createStreamLayout.span);
|
|
711
|
-
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
712
|
-
const streamNameBuffer = Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
743
|
+
let bufferData = Buffer$1.alloc(createStreamLayout.span);
|
|
713
744
|
const decodedData = {
|
|
714
|
-
start_time: data.start.toArrayLike(Buffer, "le", 8),
|
|
715
|
-
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer, "le", 8),
|
|
716
|
-
period: data.period.toArrayLike(Buffer, "le", 8),
|
|
717
|
-
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer, "le", 8),
|
|
718
|
-
cliff: data.cliff.toArrayLike(Buffer, "le", 8),
|
|
719
|
-
cliff_amount: data.cliffAmount.toArrayLike(Buffer, "le", 8),
|
|
745
|
+
start_time: data.start.toArrayLike(Buffer$1, "le", 8),
|
|
746
|
+
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer$1, "le", 8),
|
|
747
|
+
period: data.period.toArrayLike(Buffer$1, "le", 8),
|
|
748
|
+
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer$1, "le", 8),
|
|
749
|
+
cliff: data.cliff.toArrayLike(Buffer$1, "le", 8),
|
|
750
|
+
cliff_amount: data.cliffAmount.toArrayLike(Buffer$1, "le", 8),
|
|
720
751
|
cancelable_by_sender: Number(data.cancelableBySender),
|
|
721
752
|
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
722
753
|
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
@@ -727,15 +758,15 @@ var createStreamInstruction = async (data, programId, accounts) => {
|
|
|
727
758
|
can_update_rate: Number(data.canUpdateRate),
|
|
728
759
|
_can_update_rate_discriminator: 1,
|
|
729
760
|
pausable: Number(data.canPause),
|
|
730
|
-
stream_name:
|
|
731
|
-
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer, "le", 8)
|
|
761
|
+
stream_name: encodeStreamName(data.name),
|
|
762
|
+
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer$1, "le", 8)
|
|
732
763
|
};
|
|
733
764
|
const encodeLength = createStreamLayout.encode(decodedData, bufferData);
|
|
734
765
|
bufferData = bufferData.slice(0, encodeLength);
|
|
735
|
-
bufferData = Buffer.concat([
|
|
736
|
-
Buffer.from(await sha256.digest("global:create")).slice(0, 8),
|
|
766
|
+
bufferData = Buffer$1.concat([
|
|
767
|
+
Buffer$1.from(await sha256.digest("global:create")).slice(0, 8),
|
|
737
768
|
bufferData,
|
|
738
|
-
Buffer.alloc(10)
|
|
769
|
+
Buffer$1.alloc(10)
|
|
739
770
|
]);
|
|
740
771
|
return new TransactionInstruction({
|
|
741
772
|
keys,
|
|
@@ -767,16 +798,16 @@ var createUncheckedStreamInstruction = async (data, programId, accounts) => {
|
|
|
767
798
|
isWritable: true
|
|
768
799
|
});
|
|
769
800
|
}
|
|
770
|
-
let bufferData = Buffer.alloc(createUncheckedStreamLayout.span);
|
|
801
|
+
let bufferData = Buffer$1.alloc(createUncheckedStreamLayout.span);
|
|
771
802
|
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
772
|
-
const streamNameBuffer = Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
803
|
+
const streamNameBuffer = Buffer$1.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
773
804
|
const decodedData = {
|
|
774
|
-
start_time: data.start.toArrayLike(Buffer, "le", 8),
|
|
775
|
-
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer, "le", 8),
|
|
776
|
-
period: data.period.toArrayLike(Buffer, "le", 8),
|
|
777
|
-
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer, "le", 8),
|
|
778
|
-
cliff: data.cliff.toArrayLike(Buffer, "le", 8),
|
|
779
|
-
cliff_amount: data.cliffAmount.toArrayLike(Buffer, "le", 8),
|
|
805
|
+
start_time: data.start.toArrayLike(Buffer$1, "le", 8),
|
|
806
|
+
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer$1, "le", 8),
|
|
807
|
+
period: data.period.toArrayLike(Buffer$1, "le", 8),
|
|
808
|
+
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer$1, "le", 8),
|
|
809
|
+
cliff: data.cliff.toArrayLike(Buffer$1, "le", 8),
|
|
810
|
+
cliff_amount: data.cliffAmount.toArrayLike(Buffer$1, "le", 8),
|
|
780
811
|
cancelable_by_sender: Number(data.cancelableBySender),
|
|
781
812
|
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
782
813
|
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
@@ -784,7 +815,7 @@ var createUncheckedStreamInstruction = async (data, programId, accounts) => {
|
|
|
784
815
|
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
785
816
|
can_topup: Number(data.canTopup),
|
|
786
817
|
stream_name: streamNameBuffer,
|
|
787
|
-
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer, "le", 8),
|
|
818
|
+
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer$1, "le", 8),
|
|
788
819
|
recipient: data.recipient.toBuffer(),
|
|
789
820
|
partner: data.partner.toBuffer(),
|
|
790
821
|
pausable: Number(data.canPause),
|
|
@@ -793,7 +824,7 @@ var createUncheckedStreamInstruction = async (data, programId, accounts) => {
|
|
|
793
824
|
const encodeLength = createUncheckedStreamLayout.encode(decodedData, bufferData);
|
|
794
825
|
bufferData = bufferData.slice(0, encodeLength);
|
|
795
826
|
const digest = accounts.payer ? await sha256.digest("global:create_unchecked_with_payer") : await sha256.digest("global:create_unchecked");
|
|
796
|
-
bufferData = Buffer.concat([Buffer.from(digest).slice(0, 8), bufferData, Buffer.alloc(10)]);
|
|
827
|
+
bufferData = Buffer$1.concat([Buffer$1.from(digest).slice(0, 8), bufferData, Buffer$1.alloc(10)]);
|
|
797
828
|
return new TransactionInstruction({
|
|
798
829
|
keys,
|
|
799
830
|
programId,
|
|
@@ -836,18 +867,18 @@ var createStreamV2Instruction = async (data, programId, accounts) => {
|
|
|
836
867
|
if (accounts.partnerLink) {
|
|
837
868
|
keys.push({ pubkey: accounts.partnerLink.pubkey, isSigner: accounts.partnerLink.isSigner, isWritable: false });
|
|
838
869
|
}
|
|
839
|
-
let bufferData = Buffer.alloc(createStreamV2Layout.span);
|
|
870
|
+
let bufferData = Buffer$1.alloc(createStreamV2Layout.span);
|
|
840
871
|
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
841
|
-
const streamNameBuffer = Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
842
|
-
const nonceBuffer = Buffer.alloc(4);
|
|
872
|
+
const streamNameBuffer = Buffer$1.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
873
|
+
const nonceBuffer = Buffer$1.alloc(4);
|
|
843
874
|
nonceBuffer.writeUInt32LE(data.nonce);
|
|
844
875
|
const decodedData = {
|
|
845
|
-
start_time: data.start.toArrayLike(Buffer, "le", 8),
|
|
846
|
-
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer, "le", 8),
|
|
847
|
-
period: data.period.toArrayLike(Buffer, "le", 8),
|
|
848
|
-
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer, "le", 8),
|
|
849
|
-
cliff: data.cliff.toArrayLike(Buffer, "le", 8),
|
|
850
|
-
cliff_amount: data.cliffAmount.toArrayLike(Buffer, "le", 8),
|
|
876
|
+
start_time: data.start.toArrayLike(Buffer$1, "le", 8),
|
|
877
|
+
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer$1, "le", 8),
|
|
878
|
+
period: data.period.toArrayLike(Buffer$1, "le", 8),
|
|
879
|
+
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer$1, "le", 8),
|
|
880
|
+
cliff: data.cliff.toArrayLike(Buffer$1, "le", 8),
|
|
881
|
+
cliff_amount: data.cliffAmount.toArrayLike(Buffer$1, "le", 8),
|
|
851
882
|
cancelable_by_sender: Number(data.cancelableBySender),
|
|
852
883
|
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
853
884
|
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
@@ -855,17 +886,17 @@ var createStreamV2Instruction = async (data, programId, accounts) => {
|
|
|
855
886
|
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
856
887
|
can_topup: Number(data.canTopup),
|
|
857
888
|
stream_name: streamNameBuffer,
|
|
858
|
-
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer, "le", 8),
|
|
889
|
+
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer$1, "le", 8),
|
|
859
890
|
pausable: Number(data.canPause),
|
|
860
891
|
can_update_rate: Number(data.canUpdateRate),
|
|
861
892
|
nonce: nonceBuffer
|
|
862
893
|
};
|
|
863
894
|
const encodeLength = createStreamV2Layout.encode(decodedData, bufferData);
|
|
864
895
|
bufferData = bufferData.slice(0, encodeLength);
|
|
865
|
-
bufferData = Buffer.concat([
|
|
866
|
-
Buffer.from(await sha256.digest("global:create_v2")).slice(0, 8),
|
|
896
|
+
bufferData = Buffer$1.concat([
|
|
897
|
+
Buffer$1.from(await sha256.digest("global:create_v2")).slice(0, 8),
|
|
867
898
|
bufferData,
|
|
868
|
-
Buffer.alloc(10)
|
|
899
|
+
Buffer$1.alloc(10)
|
|
869
900
|
]);
|
|
870
901
|
return new TransactionInstruction({
|
|
871
902
|
keys,
|
|
@@ -897,18 +928,18 @@ var createUncheckedStreamV2Instruction = async (data, programId, accounts) => {
|
|
|
897
928
|
isWritable: true
|
|
898
929
|
});
|
|
899
930
|
}
|
|
900
|
-
let bufferData = Buffer.alloc(createUncheckedStreamV2Layout.span);
|
|
931
|
+
let bufferData = Buffer$1.alloc(createUncheckedStreamV2Layout.span);
|
|
901
932
|
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
902
|
-
const streamNameBuffer = Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
903
|
-
const nonceBuffer = Buffer.alloc(4);
|
|
933
|
+
const streamNameBuffer = Buffer$1.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
934
|
+
const nonceBuffer = Buffer$1.alloc(4);
|
|
904
935
|
nonceBuffer.writeUInt32LE(data.nonce);
|
|
905
936
|
const decodedData = {
|
|
906
|
-
start_time: data.start.toArrayLike(Buffer, "le", 8),
|
|
907
|
-
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer, "le", 8),
|
|
908
|
-
period: data.period.toArrayLike(Buffer, "le", 8),
|
|
909
|
-
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer, "le", 8),
|
|
910
|
-
cliff: data.cliff.toArrayLike(Buffer, "le", 8),
|
|
911
|
-
cliff_amount: data.cliffAmount.toArrayLike(Buffer, "le", 8),
|
|
937
|
+
start_time: data.start.toArrayLike(Buffer$1, "le", 8),
|
|
938
|
+
net_amount_deposited: data.depositedAmount.toArrayLike(Buffer$1, "le", 8),
|
|
939
|
+
period: data.period.toArrayLike(Buffer$1, "le", 8),
|
|
940
|
+
amount_per_period: data.amountPerPeriod.toArrayLike(Buffer$1, "le", 8),
|
|
941
|
+
cliff: data.cliff.toArrayLike(Buffer$1, "le", 8),
|
|
942
|
+
cliff_amount: data.cliffAmount.toArrayLike(Buffer$1, "le", 8),
|
|
912
943
|
cancelable_by_sender: Number(data.cancelableBySender),
|
|
913
944
|
cancelable_by_recipient: Number(data.cancelableByRecipient),
|
|
914
945
|
automatic_withdrawal: Number(data.automaticWithdrawal),
|
|
@@ -916,7 +947,7 @@ var createUncheckedStreamV2Instruction = async (data, programId, accounts) => {
|
|
|
916
947
|
transferable_by_recipient: Number(data.transferableByRecipient),
|
|
917
948
|
can_topup: Number(data.canTopup),
|
|
918
949
|
stream_name: streamNameBuffer,
|
|
919
|
-
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer, "le", 8),
|
|
950
|
+
withdraw_frequency: data.withdrawFrequency.toArrayLike(Buffer$1, "le", 8),
|
|
920
951
|
recipient: data.recipient.toBuffer(),
|
|
921
952
|
partner: data.partner.toBuffer(),
|
|
922
953
|
pausable: Number(data.canPause),
|
|
@@ -926,7 +957,7 @@ var createUncheckedStreamV2Instruction = async (data, programId, accounts) => {
|
|
|
926
957
|
const encodeLength = createUncheckedStreamV2Layout.encode(decodedData, bufferData);
|
|
927
958
|
bufferData = bufferData.slice(0, encodeLength);
|
|
928
959
|
const digest = accounts.payer ? await sha256.digest("global:create_unchecked_with_payer_v2") : await sha256.digest("global:create_unchecked_v2");
|
|
929
|
-
bufferData = Buffer.concat([Buffer.from(digest).slice(0, 8), bufferData, Buffer.alloc(10)]);
|
|
960
|
+
bufferData = Buffer$1.concat([Buffer$1.from(digest).slice(0, 8), bufferData, Buffer$1.alloc(10)]);
|
|
930
961
|
return new TransactionInstruction({
|
|
931
962
|
keys,
|
|
932
963
|
programId,
|
|
@@ -963,11 +994,11 @@ var withdrawStreamInstruction = async (amount, programId, {
|
|
|
963
994
|
{ pubkey: mint, isSigner: false, isWritable: true },
|
|
964
995
|
{ pubkey: tokenProgram, isSigner: false, isWritable: false }
|
|
965
996
|
];
|
|
966
|
-
let data = Buffer.alloc(withdrawStreamLayout.span);
|
|
967
|
-
const decodedData = { amount: amount.toArrayLike(Buffer, "le", 8) };
|
|
997
|
+
let data = Buffer$1.alloc(withdrawStreamLayout.span);
|
|
998
|
+
const decodedData = { amount: amount.toArrayLike(Buffer$1, "le", 8) };
|
|
968
999
|
const encodeLength = withdrawStreamLayout.encode(decodedData, data);
|
|
969
1000
|
data = data.slice(0, encodeLength);
|
|
970
|
-
data = Buffer.concat([Buffer.from(await sha256.digest("global:withdraw")).slice(0, 8), data, Buffer.alloc(10)]);
|
|
1001
|
+
data = Buffer$1.concat([Buffer$1.from(await sha256.digest("global:withdraw")).slice(0, 8), data, Buffer$1.alloc(10)]);
|
|
971
1002
|
return new TransactionInstruction({
|
|
972
1003
|
keys,
|
|
973
1004
|
programId,
|
|
@@ -981,18 +1012,19 @@ var updateStreamInstruction = async (params, programId, { authority, metadata, w
|
|
|
981
1012
|
{ pubkey: withdrawor, isSigner: false, isWritable: true },
|
|
982
1013
|
{ pubkey: systemProgram, isSigner: false, isWritable: false }
|
|
983
1014
|
];
|
|
984
|
-
let data = Buffer.alloc(100);
|
|
1015
|
+
let data = Buffer$1.alloc(100);
|
|
985
1016
|
const decodedData = {
|
|
986
1017
|
enable_automatic_withdrawal: Number(params.enableAutomaticWithdrawal),
|
|
987
|
-
withdraw_frequency: params.withdrawFrequency ? params.withdrawFrequency.toArrayLike(Buffer, "le", 8) : void 0,
|
|
988
|
-
amount_per_period: params.amountPerPeriod ? params.amountPerPeriod.toArrayLike(Buffer, "le", 8) : void 0,
|
|
1018
|
+
withdraw_frequency: params.withdrawFrequency ? params.withdrawFrequency.toArrayLike(Buffer$1, "le", 8) : void 0,
|
|
1019
|
+
amount_per_period: params.amountPerPeriod ? params.amountPerPeriod.toArrayLike(Buffer$1, "le", 8) : void 0,
|
|
989
1020
|
transferable_by_sender: params.transferableBySender !== void 0 ? Number(params.transferableBySender) : void 0,
|
|
990
1021
|
transferable_by_recipient: params.transferableByRecipient !== void 0 ? Number(params.transferableByRecipient) : void 0,
|
|
991
|
-
cancelable_by_sender: params.cancelableBySender !== void 0 ? Number(params.cancelableBySender) : void 0
|
|
1022
|
+
cancelable_by_sender: params.cancelableBySender !== void 0 ? Number(params.cancelableBySender) : void 0,
|
|
1023
|
+
stream_name: params.name !== void 0 ? encodeStreamName(params.name) : void 0
|
|
992
1024
|
};
|
|
993
1025
|
const encodeLength = encodeUpdateStream(decodedData, data);
|
|
994
1026
|
data = data.slice(0, encodeLength);
|
|
995
|
-
data = Buffer.concat([Buffer.from(await sha256.digest("global:update")).slice(0, 8), data, Buffer.alloc(20)]);
|
|
1027
|
+
data = Buffer$1.concat([Buffer$1.from(await sha256.digest("global:update")).slice(0, 8), data, Buffer$1.alloc(20)]);
|
|
996
1028
|
return new TransactionInstruction({
|
|
997
1029
|
keys,
|
|
998
1030
|
programId,
|
|
@@ -1033,7 +1065,7 @@ var cancelStreamInstruction = async (programId, {
|
|
|
1033
1065
|
{ pubkey: mint, isSigner: false, isWritable: true },
|
|
1034
1066
|
{ pubkey: tokenProgram, isSigner: false, isWritable: false }
|
|
1035
1067
|
];
|
|
1036
|
-
const data = Buffer.concat([Buffer.from(await sha256.digest("global:cancel")).slice(0, 8), Buffer.alloc(10)]);
|
|
1068
|
+
const data = Buffer$1.concat([Buffer$1.from(await sha256.digest("global:cancel")).slice(0, 8), Buffer$1.alloc(10)]);
|
|
1037
1069
|
return new TransactionInstruction({
|
|
1038
1070
|
keys,
|
|
1039
1071
|
programId,
|
|
@@ -1062,9 +1094,9 @@ var transferStreamInstruction = async (programId, {
|
|
|
1062
1094
|
{ pubkey: associatedTokenProgram, isSigner: false, isWritable: false },
|
|
1063
1095
|
{ pubkey: systemProgram, isSigner: false, isWritable: false }
|
|
1064
1096
|
];
|
|
1065
|
-
const data = Buffer.concat([
|
|
1066
|
-
Buffer.from(await sha256.digest("global:transfer_recipient")).slice(0, 8),
|
|
1067
|
-
Buffer.alloc(10)
|
|
1097
|
+
const data = Buffer$1.concat([
|
|
1098
|
+
Buffer$1.from(await sha256.digest("global:transfer_recipient")).slice(0, 8),
|
|
1099
|
+
Buffer$1.alloc(10)
|
|
1068
1100
|
]);
|
|
1069
1101
|
return new TransactionInstruction({
|
|
1070
1102
|
keys,
|
|
@@ -1092,10 +1124,10 @@ var claimRoutedFeeStreamInstruction = async (destination, programId, {
|
|
|
1092
1124
|
{ pubkey: mint, isSigner: false, isWritable: true },
|
|
1093
1125
|
{ pubkey: tokenProgram, isSigner: false, isWritable: false }
|
|
1094
1126
|
];
|
|
1095
|
-
const data = Buffer.concat([
|
|
1096
|
-
Buffer.from(await sha256.digest("global:claim_routed_fee")).slice(0, 8),
|
|
1097
|
-
Buffer.from([destination === "treasury" ? 0 : 1]),
|
|
1098
|
-
Buffer.alloc(10)
|
|
1127
|
+
const data = Buffer$1.concat([
|
|
1128
|
+
Buffer$1.from(await sha256.digest("global:claim_routed_fee")).slice(0, 8),
|
|
1129
|
+
Buffer$1.from([destination === "treasury" ? 0 : 1]),
|
|
1130
|
+
Buffer$1.alloc(10)
|
|
1099
1131
|
]);
|
|
1100
1132
|
return new TransactionInstruction({
|
|
1101
1133
|
keys,
|
|
@@ -1135,11 +1167,11 @@ var topupStreamInstruction = async (amount, programId, {
|
|
|
1135
1167
|
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
1136
1168
|
{ pubkey: systemProgram, isSigner: false, isWritable: false }
|
|
1137
1169
|
];
|
|
1138
|
-
let data = Buffer.alloc(topupStreamLayout.span);
|
|
1139
|
-
const decodedData = { amount: amount.toArrayLike(Buffer, "le", 8) };
|
|
1170
|
+
let data = Buffer$1.alloc(topupStreamLayout.span);
|
|
1171
|
+
const decodedData = { amount: amount.toArrayLike(Buffer$1, "le", 8) };
|
|
1140
1172
|
const encodeLength = topupStreamLayout.encode(decodedData, data);
|
|
1141
1173
|
data = data.slice(0, encodeLength);
|
|
1142
|
-
data = Buffer.concat([Buffer.from(await sha256.digest("global:topup")).slice(0, 8), data, Buffer.alloc(10)]);
|
|
1174
|
+
data = Buffer$1.concat([Buffer$1.from(await sha256.digest("global:topup")).slice(0, 8), data, Buffer$1.alloc(10)]);
|
|
1143
1175
|
return new TransactionInstruction({
|
|
1144
1176
|
keys,
|
|
1145
1177
|
programId,
|
|
@@ -3115,6 +3147,17 @@ var streamflow_aligned_unlocks_default = {
|
|
|
3115
3147
|
type: {
|
|
3116
3148
|
option: "bool"
|
|
3117
3149
|
}
|
|
3150
|
+
},
|
|
3151
|
+
{
|
|
3152
|
+
name: "stream_name",
|
|
3153
|
+
type: {
|
|
3154
|
+
option: {
|
|
3155
|
+
array: [
|
|
3156
|
+
"u8",
|
|
3157
|
+
64
|
|
3158
|
+
]
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3118
3161
|
}
|
|
3119
3162
|
]
|
|
3120
3163
|
}
|
|
@@ -3156,7 +3199,7 @@ var deriveTestOraclePDA = (programId, mint, creator) => {
|
|
|
3156
3199
|
};
|
|
3157
3200
|
var deriveStreamMetadataPDA = (programId, mint, sender, nonce) => {
|
|
3158
3201
|
return PublicKey.findProgramAddressSync(
|
|
3159
|
-
[METADATA_SEED, mint.toBuffer(), sender.toBuffer(), new BN3(nonce).toArrayLike(Buffer, "be", 4)],
|
|
3202
|
+
[METADATA_SEED, mint.toBuffer(), sender.toBuffer(), new BN3(nonce).toArrayLike(Buffer$1, "be", 4)],
|
|
3160
3203
|
programId
|
|
3161
3204
|
)[0];
|
|
3162
3205
|
};
|
|
@@ -3314,6 +3357,27 @@ var transformContract = async (schema) => {
|
|
|
3314
3357
|
// solana/StreamClient.ts
|
|
3315
3358
|
var METADATA_ACC_SIZE = 1104;
|
|
3316
3359
|
var ALIGNED_METADATA_ACC_SIZE = 320;
|
|
3360
|
+
var PARTNER_LINK_DISCRIMINATOR = Buffer$1.from([114, 220, 250, 94, 181, 182, 195, 222]);
|
|
3361
|
+
var PARTNER_LINK_SIZE = 8 + 32 + 32 + 32;
|
|
3362
|
+
var decodePartnerLink = (data) => data.length >= PARTNER_LINK_SIZE && data.subarray(0, 8).equals(PARTNER_LINK_DISCRIMINATOR) ? { partnerPubkey: new PublicKey(data.subarray(8, 40)), linkedPubkey: new PublicKey(data.subarray(40, 72)) } : null;
|
|
3363
|
+
var findFees = (partners, address) => {
|
|
3364
|
+
const filteredPartners = partners.filter((partner2) => new PublicKey(partner2.pubkey).toString() === address);
|
|
3365
|
+
if (filteredPartners.length === 0) {
|
|
3366
|
+
return null;
|
|
3367
|
+
}
|
|
3368
|
+
if (filteredPartners.length > 1) {
|
|
3369
|
+
throw new Error("More than one partner found, fees fetching is not possible.");
|
|
3370
|
+
}
|
|
3371
|
+
const partner = filteredPartners[0];
|
|
3372
|
+
return {
|
|
3373
|
+
creationFeeSol: Number(partner.creation_fee),
|
|
3374
|
+
autoClaimFeeSol: Number(partner.auto_claim_fee),
|
|
3375
|
+
streamflowFee: Number(partner.token_fee_percent.toFixed(4)),
|
|
3376
|
+
streamflowLockFee: Number(partner.token_lock_token_fee_percent.toFixed(4)),
|
|
3377
|
+
partnerFee: 0
|
|
3378
|
+
};
|
|
3379
|
+
};
|
|
3380
|
+
var getWrapFeePercent = (rates, data) => isStrictTokenLockCreate(data) ? rates.streamflowLockFee : rates.streamflowFee;
|
|
3317
3381
|
var SolanaStreamClient = class {
|
|
3318
3382
|
/**
|
|
3319
3383
|
* Create Stream instance
|
|
@@ -3407,10 +3471,8 @@ var SolanaStreamClient = class {
|
|
|
3407
3471
|
tokenProgramId ? new PublicKey(tokenProgramId) : void 0
|
|
3408
3472
|
);
|
|
3409
3473
|
if (isNative) {
|
|
3410
|
-
const
|
|
3411
|
-
|
|
3412
|
-
});
|
|
3413
|
-
const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
|
|
3474
|
+
const rates = await this.getCreateFeeRates(data.partnerLink, sender.publicKey);
|
|
3475
|
+
const totalAmount = calculateTotalAmountToDeposit(amount, getWrapFeePercent(rates, data));
|
|
3414
3476
|
ixs.push(...await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
|
|
3415
3477
|
}
|
|
3416
3478
|
const {
|
|
@@ -3555,8 +3617,6 @@ var SolanaStreamClient = class {
|
|
|
3555
3617
|
...await this.getCreateATAInstructions([recipientPublicKey], mintPublicKey, sender, true, tokenProgramId)
|
|
3556
3618
|
);
|
|
3557
3619
|
}
|
|
3558
|
-
const encodedUIntArray = new TextEncoder().encode(streamName);
|
|
3559
|
-
const streamNameArray = Array.from(encodedUIntArray);
|
|
3560
3620
|
const createMethod = this.alignedProxyProgram.methods.create({
|
|
3561
3621
|
startTime: new BN3(start),
|
|
3562
3622
|
netAmountDeposited: depositedAmount,
|
|
@@ -3570,7 +3630,7 @@ var SolanaStreamClient = class {
|
|
|
3570
3630
|
cancelableBySender,
|
|
3571
3631
|
canTopup,
|
|
3572
3632
|
oracleType: !!oracleType ? { [oracleType]: {} } : { none: {} },
|
|
3573
|
-
streamName:
|
|
3633
|
+
streamName: encodeStreamNameAsArray(streamName),
|
|
3574
3634
|
minPrice: typeof minPrice === "number" ? getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW2) : minPrice,
|
|
3575
3635
|
maxPrice: typeof maxPrice === "number" ? getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW2) : maxPrice,
|
|
3576
3636
|
minPercentage: typeof minPercentage === "number" ? getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW2) : minPercentage,
|
|
@@ -3654,7 +3714,7 @@ var SolanaStreamClient = class {
|
|
|
3654
3714
|
({ metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys));
|
|
3655
3715
|
}
|
|
3656
3716
|
const [escrowTokens] = PublicKey.findProgramAddressSync(
|
|
3657
|
-
[Buffer.from("strm"), metadataPubKey.toBuffer()],
|
|
3717
|
+
[Buffer$1.from("strm"), metadataPubKey.toBuffer()],
|
|
3658
3718
|
this.programId
|
|
3659
3719
|
);
|
|
3660
3720
|
const { mint: mintAccount, tokenProgramId: detectedTokenProgramId } = await getMintAndProgram(
|
|
@@ -3788,7 +3848,7 @@ var SolanaStreamClient = class {
|
|
|
3788
3848
|
({ metadata, metadataPubKey } = this.getOrCreateStreamMetadata(metadataPubKeys));
|
|
3789
3849
|
}
|
|
3790
3850
|
const [escrowTokens] = PublicKey.findProgramAddressSync(
|
|
3791
|
-
[Buffer.from("strm"), metadataPubKey.toBuffer()],
|
|
3851
|
+
[Buffer$1.from("strm"), metadataPubKey.toBuffer()],
|
|
3792
3852
|
this.programId
|
|
3793
3853
|
);
|
|
3794
3854
|
const { mint: mintAccount, tokenProgramId } = await getMintAndProgram(this.connection, mintPublicKey);
|
|
@@ -3799,7 +3859,20 @@ var SolanaStreamClient = class {
|
|
|
3799
3859
|
computeLimit
|
|
3800
3860
|
});
|
|
3801
3861
|
if (isNative) {
|
|
3802
|
-
const
|
|
3862
|
+
const rates = await this.getCreateFeeRates(partnerLink, sender.publicKey);
|
|
3863
|
+
const totalFee = getWrapFeePercent(rates, {
|
|
3864
|
+
start,
|
|
3865
|
+
amount: depositedAmount,
|
|
3866
|
+
period,
|
|
3867
|
+
cliff,
|
|
3868
|
+
cliffAmount,
|
|
3869
|
+
amountPerPeriod,
|
|
3870
|
+
canTopup,
|
|
3871
|
+
automaticWithdrawal,
|
|
3872
|
+
cancelableBySender,
|
|
3873
|
+
cancelableByRecipient,
|
|
3874
|
+
transferableBySender
|
|
3875
|
+
});
|
|
3803
3876
|
const totalAmount = calculateTotalAmountToDeposit(depositedAmount, totalFee);
|
|
3804
3877
|
ixs.push(...await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
|
|
3805
3878
|
}
|
|
@@ -3889,6 +3962,7 @@ var SolanaStreamClient = class {
|
|
|
3889
3962
|
if (recipients.length === 0) {
|
|
3890
3963
|
throw new Error("Recipients array is empty!");
|
|
3891
3964
|
}
|
|
3965
|
+
const wrapFeeRates = isNative ? await this.getCreateFeeRates(data.partnerLink, sender.publicKey) : void 0;
|
|
3892
3966
|
for (let i = 0; i < recipients.length; i++) {
|
|
3893
3967
|
const recipientData = recipients[i];
|
|
3894
3968
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
@@ -3897,8 +3971,8 @@ var SolanaStreamClient = class {
|
|
|
3897
3971
|
metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
|
|
3898
3972
|
};
|
|
3899
3973
|
const wrapInstructions = [];
|
|
3900
|
-
if (
|
|
3901
|
-
const totalFee =
|
|
3974
|
+
if (wrapFeeRates) {
|
|
3975
|
+
const totalFee = getWrapFeePercent(wrapFeeRates, createStreamData);
|
|
3902
3976
|
const recipientAmount = calculateTotalAmountToDeposit(recipientData.amount, totalFee);
|
|
3903
3977
|
wrapInstructions.push(...await prepareWrappedAccount(this.connection, sender.publicKey, recipientAmount));
|
|
3904
3978
|
}
|
|
@@ -4792,7 +4866,8 @@ var SolanaStreamClient = class {
|
|
|
4792
4866
|
await (isAlignedUnlock ? this.alignedProxyProgram.methods.updateContract({
|
|
4793
4867
|
transferableBySender: data.transferableBySender ?? null,
|
|
4794
4868
|
transferableByRecipient: data.transferableByRecipient ?? null,
|
|
4795
|
-
cancelableBySender: data.cancelableBySender ?? null
|
|
4869
|
+
cancelableBySender: data.cancelableBySender ?? null,
|
|
4870
|
+
streamName: data.name !== void 0 ? encodeStreamNameAsArray(data.name) : null
|
|
4796
4871
|
}).accounts({ sender: invoker.publicKey, streamMetadata: streamPublicKey, withdrawor: WITHDRAWOR_PUBLIC_KEY }).accountsPartial({ streamflowProgram: this.programId }).instruction() : updateStreamInstruction(data, this.programId, {
|
|
4797
4872
|
authority: invoker.publicKey,
|
|
4798
4873
|
metadata: streamPublicKey,
|
|
@@ -4808,26 +4883,38 @@ var SolanaStreamClient = class {
|
|
|
4808
4883
|
* @returns Fees
|
|
4809
4884
|
*/
|
|
4810
4885
|
async getFees({ address }) {
|
|
4886
|
+
const partners = await this.getFeeRows();
|
|
4887
|
+
return partners ? findFees(partners, address) : null;
|
|
4888
|
+
}
|
|
4889
|
+
async getFeeRows() {
|
|
4811
4890
|
const data = await this.connection.getAccountInfo(this.feeOraclePublicKey);
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4891
|
+
return data ? borsh.deserialize(PARTNERS_SCHEMA, data.data) : null;
|
|
4892
|
+
}
|
|
4893
|
+
/**
|
|
4894
|
+
* Fee rates the program applies to a create from `sender` with `partnerLink`, used to size the WSOL wrap.
|
|
4895
|
+
* Mirrors `resolve_vesting_partner`: a `partnerLink` counts if it signs or the partner oracle owns it, and a
|
|
4896
|
+
* PartnerLink account stands for its partner. A link to another wallet fails the program's lookup, which then
|
|
4897
|
+
* charges its hardcoded fallback and skips the sender's own row. Otherwise the sender's own row, then the
|
|
4898
|
+
* partner's, then the default row. `partner` only takes a share and never picks the row.
|
|
4899
|
+
*/
|
|
4900
|
+
async getCreateFeeRates(partnerLink, sender) {
|
|
4901
|
+
const fallback = { streamflowFee: DEFAULT_STREAMFLOW_FEE, streamflowLockFee: DEFAULT_STREAMFLOW_FEE };
|
|
4902
|
+
let linkedPartner;
|
|
4903
|
+
if (partnerLink?.isSigner) {
|
|
4904
|
+
linkedPartner = pk(partnerLink.address).toBase58();
|
|
4905
|
+
} else if (partnerLink) {
|
|
4906
|
+
const address = pk(partnerLink.address);
|
|
4907
|
+
const account = await this.connection.getAccountInfo(address);
|
|
4908
|
+
if (account?.owner.equals(this.partnerOracleProgramId)) {
|
|
4909
|
+
const link = decodePartnerLink(account.data);
|
|
4910
|
+
if (link && !link.linkedPubkey.equals(sender)) {
|
|
4911
|
+
return fallback;
|
|
4912
|
+
}
|
|
4913
|
+
linkedPartner = (link?.partnerPubkey ?? address).toBase58();
|
|
4914
|
+
}
|
|
4822
4915
|
}
|
|
4823
|
-
const
|
|
4824
|
-
return
|
|
4825
|
-
creationFeeSol: Number(partner.creation_fee),
|
|
4826
|
-
autoClaimFeeSol: Number(partner.auto_claim_fee),
|
|
4827
|
-
streamflowFee: Number(partner.token_fee_percent.toFixed(4)),
|
|
4828
|
-
streamflowLockFee: Number(partner.token_lock_token_fee_percent.toFixed(4)),
|
|
4829
|
-
partnerFee: 0
|
|
4830
|
-
};
|
|
4916
|
+
const partners = await this.getFeeRows() ?? [];
|
|
4917
|
+
return findFees(partners, sender.toBase58()) ?? (linkedPartner ? findFees(partners, linkedPartner) : null) ?? findFees(partners, WITHDRAWOR) ?? fallback;
|
|
4831
4918
|
}
|
|
4832
4919
|
/**
|
|
4833
4920
|
* Gets default streamflow fee
|
|
@@ -5848,6 +5935,6 @@ async function executeBatchSequential(builtTransactions, env) {
|
|
|
5848
5935
|
return { signatures, errors };
|
|
5849
5936
|
}
|
|
5850
5937
|
|
|
5851
|
-
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, METADATA_SEED, ORIGINAL_CONTRACT_SENDER_OFFSET, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, REPOPULATED_METADATA_SEED, 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_OLD_METADATA_KEY, 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, buildLockBatchParams, buildLockParams, buildStreamType, buildTransaction, buildVestingBatchParams, buildVestingParams, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancel, cancelStreamInstruction, claimRoutedFeeStreamInstruction, computeAmountPerPeriod, create, createBatch, createClient, createClientFromEnv, createLock, createLockBatch, createStreamInstruction, createStreamV2Instruction, createUncheckedStreamInstruction, createUncheckedStreamV2Instruction, createVesting, createVestingBatch, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveRepopulatedMetadataPDA, deriveStreamMetadataPDA, deriveTestOraclePDA, execute, executeBatch, executeBatchSequential, extractSolanaErrorCode, getMetadataKey, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isTokenLock, isVesting, resolveConnection, resolveDuration, sendAndConfirmStreamRawTransaction, sign, signAllTransactionWithRecipients, timelockIDL_default as timelockIDL, topup, topupStreamInstruction, transfer, transferStreamInstruction, transformContract, update, updateStreamInstruction, withdraw, withdrawStreamInstruction };
|
|
5938
|
+
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, METADATA_SEED, ORIGINAL_CONTRACT_SENDER_OFFSET, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, REPOPULATED_METADATA_SEED, 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_OLD_METADATA_KEY, 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, buildLockBatchParams, buildLockParams, buildStreamType, buildTransaction, buildVestingBatchParams, buildVestingParams, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancel, cancelStreamInstruction, claimRoutedFeeStreamInstruction, computeAmountPerPeriod, create, createBatch, createClient, createClientFromEnv, createLock, createLockBatch, createStreamInstruction, createStreamV2Instruction, createUncheckedStreamInstruction, createUncheckedStreamV2Instruction, createVesting, createVestingBatch, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveRepopulatedMetadataPDA, deriveStreamMetadataPDA, deriveTestOraclePDA, encodeStreamName, encodeStreamNameAsArray, execute, executeBatch, executeBatchSequential, extractSolanaErrorCode, getMetadataKey, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isStrictTokenLockCreate, isTokenLock, isVesting, resolveConnection, resolveDuration, sendAndConfirmStreamRawTransaction, sign, signAllTransactionWithRecipients, timelockIDL_default as timelockIDL, topup, topupStreamInstruction, transfer, transferStreamInstruction, transformContract, update, updateStreamInstruction, withdraw, withdrawStreamInstruction };
|
|
5852
5939
|
//# sourceMappingURL=index.js.map
|
|
5853
5940
|
//# sourceMappingURL=index.js.map
|