@streamflow/stream 10.0.0-alpha.p317.e143b57 → 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 +101 -46
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/solana/index.cjs +101 -46
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +57 -13
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +99 -47
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +57 -13
- package/dist/esm/solana/index.js +99 -47
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.d.cts
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.cjs';
|
|
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.cjs';
|
|
2
2
|
export { ContractError, ICluster, getBN, getNumberFromBN } from '@streamflow/common';
|
|
3
3
|
import 'p-queue';
|
|
4
4
|
import '@solana/web3.js';
|
|
@@ -63,7 +63,7 @@ var isVesting = (streamData) => {
|
|
|
63
63
|
return !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
|
|
64
64
|
};
|
|
65
65
|
var isAligned = (stream) => {
|
|
66
|
-
return
|
|
66
|
+
return stream.isAligned;
|
|
67
67
|
};
|
|
68
68
|
var isCreateAlignedStreamData = (obj) => {
|
|
69
69
|
return "minPrice" in obj && "maxPrice" in obj && "minPercentage" in obj && "maxPercentage" in obj;
|
|
@@ -251,25 +251,40 @@ var ALIGNED_UNLOCKS_PROGRAM_ID = {
|
|
|
251
251
|
[common.ICluster.Testnet]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
|
|
252
252
|
[common.ICluster.Local]: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH"
|
|
253
253
|
};
|
|
254
|
+
var PARTNER_ORACLE_PROGRAM_ID = {
|
|
255
|
+
[common.ICluster.Devnet]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3",
|
|
256
|
+
[common.ICluster.Mainnet]: "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa",
|
|
257
|
+
[common.ICluster.Testnet]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3",
|
|
258
|
+
[common.ICluster.Local]: "pardoTarcc6HKsPcbXkVycxsJsoN9QEzrdHgVdHAGY3"
|
|
259
|
+
};
|
|
260
|
+
var FEE_ORACLE_PUBLIC_KEY = {
|
|
261
|
+
[common.ICluster.Devnet]: "Aa2JJfFzUN3V54DXUHRBJowFw416xfZHpPk9DaNy3iYs",
|
|
262
|
+
[common.ICluster.Mainnet]: "B743wFVk2pCYhV91cn287e1xY7f1vt4gdY48hhNiuQmT",
|
|
263
|
+
[common.ICluster.Testnet]: "Aa2JJfFzUN3V54DXUHRBJowFw416xfZHpPk9DaNy3iYs",
|
|
264
|
+
[common.ICluster.Local]: "Aa2JJfFzUN3V54DXUHRBJowFw416xfZHpPk9DaNy3iYs"
|
|
265
|
+
};
|
|
254
266
|
var ALIGNED_COMPUTE_LIMIT = 3e5;
|
|
255
267
|
var CONTRACT_DISCRIMINATOR = [172, 138, 115, 242, 121, 67, 183, 26];
|
|
256
268
|
var TEST_ORACLE_DISCRIMINATOR = [198, 49, 63, 134, 232, 251, 168, 28];
|
|
257
269
|
var CONTRACT_SEED = buffer.Buffer.from("contract", "utf-8");
|
|
258
270
|
var ESCROW_SEED = buffer.Buffer.from("strm", "utf-8");
|
|
259
271
|
var TEST_ORACLE_SEED = buffer.Buffer.from("test-oracle", "utf-8");
|
|
260
|
-
var PARTNER_ORACLE_PROGRAM_ID = "pardpVtPjC8nLj1Dwncew62mUzfChdCX1EaoZe8oCAa";
|
|
261
272
|
var STREAMFLOW_TREASURY_PUBLIC_KEY = new web3_js.PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
262
|
-
var
|
|
263
|
-
var
|
|
273
|
+
var WITHDRAWOR = "wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u";
|
|
274
|
+
var WITHDRAWOR_PUBLIC_KEY = new web3_js.PublicKey(WITHDRAWOR);
|
|
264
275
|
var AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
|
|
265
276
|
var FEES_METADATA_SEED = buffer.Buffer.from("strm_fees");
|
|
266
|
-
var
|
|
277
|
+
var DEFAULT_CREATION_FEE_SOL = 9e7;
|
|
278
|
+
var DEFAULT_AUTO_CLAIM_FEE_SOL = 19e7;
|
|
279
|
+
var DEFAULT_STREAMFLOW_FEE = 0.19;
|
|
267
280
|
var AIRDROP_AMOUNT = 1;
|
|
268
281
|
var PARTNER_SCHEMA = {
|
|
269
282
|
struct: {
|
|
270
283
|
pubkey: { array: { type: "u8", len: 32 } },
|
|
271
|
-
|
|
272
|
-
|
|
284
|
+
creation_fee: "u32",
|
|
285
|
+
auto_claim_fee: "u32",
|
|
286
|
+
token_fee_percent: "f32",
|
|
287
|
+
buffer: { array: { type: "u8", len: 16 } }
|
|
273
288
|
}
|
|
274
289
|
};
|
|
275
290
|
var PARTNERS_SCHEMA = { array: { type: PARTNER_SCHEMA } };
|
|
@@ -2522,6 +2537,8 @@ var SolanaStreamClient = class {
|
|
|
2522
2537
|
this.commitment = commitment;
|
|
2523
2538
|
this.connection = new web3_js.Connection(optionsOrClusterUrl, this.commitment);
|
|
2524
2539
|
this.programId = programId !== "" ? new web3_js.PublicKey(programId) : new web3_js.PublicKey(PROGRAM_ID[cluster]);
|
|
2540
|
+
this.partnerOracleProgramId = new web3_js.PublicKey(PARTNER_ORACLE_PROGRAM_ID[cluster]);
|
|
2541
|
+
this.feeOraclePublicKey = new web3_js.PublicKey(FEE_ORACLE_PUBLIC_KEY[cluster]);
|
|
2525
2542
|
this.schedulingParams = {
|
|
2526
2543
|
sendThrottler: sendThrottler ?? common.buildSendThrottler(sendRate)
|
|
2527
2544
|
};
|
|
@@ -2536,6 +2553,8 @@ var SolanaStreamClient = class {
|
|
|
2536
2553
|
this.commitment = commitment2;
|
|
2537
2554
|
this.connection = new web3_js.Connection(clusterUrl, this.commitment);
|
|
2538
2555
|
this.programId = programId2 !== "" ? new web3_js.PublicKey(programId2) : new web3_js.PublicKey(PROGRAM_ID[cluster2]);
|
|
2556
|
+
this.partnerOracleProgramId = new web3_js.PublicKey(PARTNER_ORACLE_PROGRAM_ID[cluster2]);
|
|
2557
|
+
this.feeOraclePublicKey = new web3_js.PublicKey(FEE_ORACLE_PUBLIC_KEY[cluster2]);
|
|
2539
2558
|
const schedulingOptions = sendScheduler && "sendRate" in sendScheduler ? sendScheduler : void 0;
|
|
2540
2559
|
const sendThrottler2 = !sendScheduler ? common.buildSendThrottler(1) : "sendRate" in sendScheduler ? common.buildSendThrottler(sendScheduler.sendRate ?? 1, sendScheduler.sendInterval) : sendScheduler;
|
|
2541
2560
|
this.schedulingParams = {
|
|
@@ -2576,7 +2595,7 @@ var SolanaStreamClient = class {
|
|
|
2576
2595
|
const { partner, amount, tokenProgramId } = data;
|
|
2577
2596
|
const { isNative, sender, customInstructions } = extParams;
|
|
2578
2597
|
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2579
|
-
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) :
|
|
2598
|
+
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : sender.publicKey;
|
|
2580
2599
|
const mintPublicKey = new web3_js.PublicKey(data.tokenId);
|
|
2581
2600
|
const ixs = await this.getCreateATAInstructions(
|
|
2582
2601
|
[partnerPublicKey],
|
|
@@ -2712,7 +2731,7 @@ var SolanaStreamClient = class {
|
|
|
2712
2731
|
if (!tokenProgramId) {
|
|
2713
2732
|
tokenProgramId = (await common.getMintAndProgram(this.connection, mintPublicKey)).tokenProgramId;
|
|
2714
2733
|
}
|
|
2715
|
-
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) :
|
|
2734
|
+
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : sender.publicKey;
|
|
2716
2735
|
const streamflowProgramPublicKey = new web3_js.PublicKey(this.programId);
|
|
2717
2736
|
const escrowPDA = deriveEscrowPDA(streamflowProgramPublicKey, metadataPubKey);
|
|
2718
2737
|
const oracle = priceOracle ?? deriveTestOraclePDA(this.alignedProxyProgram.programId, mintPublicKey, sender.publicKey);
|
|
@@ -2759,7 +2778,7 @@ var SolanaStreamClient = class {
|
|
|
2759
2778
|
partner: partnerPublicKey,
|
|
2760
2779
|
recipient: recipientPublicKey,
|
|
2761
2780
|
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
2762
|
-
feeOracle:
|
|
2781
|
+
feeOracle: this.feeOraclePublicKey,
|
|
2763
2782
|
priceOracle: oracle,
|
|
2764
2783
|
tokenProgram: tokenProgramId,
|
|
2765
2784
|
streamflowProgram: this.programId
|
|
@@ -2815,7 +2834,7 @@ var SolanaStreamClient = class {
|
|
|
2815
2834
|
const senderTokens = await common.ata(mintPublicKey, sender.publicKey, tokenProgramId);
|
|
2816
2835
|
const recipientTokens = await common.ata(mintPublicKey, recipientPublicKey, tokenProgramId);
|
|
2817
2836
|
const streamflowTreasuryTokens = await common.ata(mintPublicKey, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
2818
|
-
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) :
|
|
2837
|
+
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : sender.publicKey;
|
|
2819
2838
|
const partnerTokens = await common.ata(mintPublicKey, partnerPublicKey, tokenProgramId);
|
|
2820
2839
|
ixs.push(
|
|
2821
2840
|
await createStreamInstruction(
|
|
@@ -2850,7 +2869,7 @@ var SolanaStreamClient = class {
|
|
|
2850
2869
|
partner: partnerPublicKey,
|
|
2851
2870
|
partnerTokens,
|
|
2852
2871
|
mint: new web3_js.PublicKey(mint),
|
|
2853
|
-
feeOracle:
|
|
2872
|
+
feeOracle: this.feeOraclePublicKey,
|
|
2854
2873
|
rent: web3_js.SYSVAR_RENT_PUBKEY,
|
|
2855
2874
|
timelockProgram: this.programId,
|
|
2856
2875
|
tokenProgram: tokenProgramId,
|
|
@@ -2939,7 +2958,7 @@ var SolanaStreamClient = class {
|
|
|
2939
2958
|
);
|
|
2940
2959
|
const { tokenProgramId } = await common.getMintAndProgram(this.connection, mintPublicKey);
|
|
2941
2960
|
const senderTokens = await common.ata(mintPublicKey, sender.publicKey, tokenProgramId);
|
|
2942
|
-
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) :
|
|
2961
|
+
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : sender.publicKey;
|
|
2943
2962
|
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
2944
2963
|
computePrice,
|
|
2945
2964
|
computeLimit
|
|
@@ -2977,7 +2996,7 @@ var SolanaStreamClient = class {
|
|
|
2977
2996
|
metadata: metadataPubKey,
|
|
2978
2997
|
escrowTokens,
|
|
2979
2998
|
mint: new web3_js.PublicKey(mint),
|
|
2980
|
-
feeOracle:
|
|
2999
|
+
feeOracle: this.feeOraclePublicKey,
|
|
2981
3000
|
rent: web3_js.SYSVAR_RENT_PUBKEY,
|
|
2982
3001
|
timelockProgram: this.programId,
|
|
2983
3002
|
tokenProgram: tokenProgramId,
|
|
@@ -3002,7 +3021,7 @@ var SolanaStreamClient = class {
|
|
|
3002
3021
|
const metadatas = [];
|
|
3003
3022
|
const metadataToRecipient = {};
|
|
3004
3023
|
const instructionsBatch = [];
|
|
3005
|
-
const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) :
|
|
3024
|
+
const partnerPublicKey = data.partner ? new web3_js.PublicKey(data.partner) : sender.publicKey;
|
|
3006
3025
|
const mintPublicKey = new web3_js.PublicKey(data.tokenId);
|
|
3007
3026
|
if (recipients.length === 0) {
|
|
3008
3027
|
throw new Error("Recipients array is empty!");
|
|
@@ -3680,20 +3699,41 @@ var SolanaStreamClient = class {
|
|
|
3680
3699
|
const accounts = await this.connection.getProgramAccounts(this.programId, {
|
|
3681
3700
|
filters
|
|
3682
3701
|
});
|
|
3683
|
-
const
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3702
|
+
const decoded = this.decodeStreamsFromAccounts(accounts);
|
|
3703
|
+
const alignedEntries = this.collectAlignedEntries(decoded);
|
|
3704
|
+
const alignedProxies = await this.fetchAlignedProxiesByEntries(alignedEntries);
|
|
3705
|
+
return this.mapDecodedToProgramAccounts(decoded, alignedEntries, alignedProxies);
|
|
3706
|
+
}
|
|
3707
|
+
decodeStreamsFromAccounts(accounts) {
|
|
3708
|
+
return accounts.map(({ pubkey, account }) => ({
|
|
3709
|
+
pubkey,
|
|
3710
|
+
stream: decodeStream(account.data)
|
|
3711
|
+
}));
|
|
3712
|
+
}
|
|
3713
|
+
collectAlignedEntries(decoded) {
|
|
3714
|
+
const entries = [];
|
|
3715
|
+
decoded.forEach(({ pubkey, stream }, index) => {
|
|
3716
|
+
if (this.isAlignedUnlock(pubkey, stream.sender)) {
|
|
3717
|
+
entries.push({ index, pda: deriveContractPDA(this.alignedProxyProgram.programId, pubkey) });
|
|
3718
|
+
}
|
|
3719
|
+
});
|
|
3720
|
+
return entries;
|
|
3721
|
+
}
|
|
3722
|
+
async fetchAlignedProxiesByEntries(aligned) {
|
|
3723
|
+
if (aligned.length === 0) return [];
|
|
3724
|
+
const res = await this.alignedProxyProgram.account.contract.fetchMultiple(aligned.map((a) => a.pda));
|
|
3725
|
+
return res;
|
|
3726
|
+
}
|
|
3727
|
+
mapDecodedToProgramAccounts(decoded, alignedEntries, alignedProxies) {
|
|
3728
|
+
return decoded.map(({ pubkey, stream }, idx) => {
|
|
3729
|
+
const alignedIdx = alignedEntries.findIndex((a) => a.index === idx);
|
|
3730
|
+
if (alignedIdx !== -1) {
|
|
3731
|
+
const alignedProxy = alignedProxies[alignedIdx];
|
|
3732
|
+
common.invariant(alignedProxy, "Couldn't get aligned proxy account info");
|
|
3733
|
+
return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
|
|
3734
|
+
}
|
|
3735
|
+
return { publicKey: pubkey, account: new Contract(stream) };
|
|
3736
|
+
});
|
|
3697
3737
|
}
|
|
3698
3738
|
/**
|
|
3699
3739
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
@@ -3763,37 +3803,49 @@ var SolanaStreamClient = class {
|
|
|
3763
3803
|
* @returns Fees
|
|
3764
3804
|
*/
|
|
3765
3805
|
async getFees({ address }) {
|
|
3766
|
-
const
|
|
3767
|
-
[buffer.Buffer.from(FEES_METADATA_SEED)],
|
|
3768
|
-
new web3_js.PublicKey(PARTNER_ORACLE_PROGRAM_ID)
|
|
3769
|
-
);
|
|
3770
|
-
const data = await this.connection.getAccountInfo(metadataPubKey);
|
|
3806
|
+
const data = await this.connection.getAccountInfo(this.feeOraclePublicKey);
|
|
3771
3807
|
if (!data) {
|
|
3772
3808
|
return null;
|
|
3773
3809
|
}
|
|
3774
3810
|
const partners = borsh__namespace.deserialize(PARTNERS_SCHEMA, data.data);
|
|
3775
|
-
const
|
|
3776
|
-
|
|
3777
|
-
|
|
3811
|
+
for (const partner of partners) {
|
|
3812
|
+
const partnerAddress = new web3_js.PublicKey(partner.pubkey).toString();
|
|
3813
|
+
if (partnerAddress === address) {
|
|
3814
|
+
return {
|
|
3815
|
+
creationFeeSol: Number(partner.creation_fee),
|
|
3816
|
+
autoClaimFeeSol: Number(partner.auto_claim_fee),
|
|
3817
|
+
streamflowFee: Number(partner.token_fee_percent.toFixed(4)),
|
|
3818
|
+
partnerFee: 0
|
|
3819
|
+
};
|
|
3820
|
+
}
|
|
3778
3821
|
}
|
|
3779
|
-
return
|
|
3780
|
-
streamflowFee: Number(filteredPartners[0].strm_fee.toFixed(4)),
|
|
3781
|
-
partnerFee: Number(filteredPartners[0].partner_fee.toFixed(4))
|
|
3782
|
-
};
|
|
3822
|
+
return null;
|
|
3783
3823
|
}
|
|
3784
3824
|
/**
|
|
3785
3825
|
* Gets default streamflow fee
|
|
3786
3826
|
* @returns Default streamflow fee
|
|
3787
3827
|
*/
|
|
3788
3828
|
async getDefaultStreamflowFee() {
|
|
3789
|
-
return
|
|
3829
|
+
return (await this.getDefaultFees()).streamflowFee;
|
|
3790
3830
|
}
|
|
3791
3831
|
/**
|
|
3792
|
-
*
|
|
3793
|
-
*
|
|
3794
|
-
*
|
|
3795
|
-
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
3832
|
+
* Get all defaults fees applied by the protocol.
|
|
3833
|
+
*
|
|
3834
|
+
* Protocol will use fees set for WITHDRAWOR as default if they are set.
|
|
3796
3835
|
*/
|
|
3836
|
+
async getDefaultFees() {
|
|
3837
|
+
return await this.getFees({ address: WITHDRAWOR }) || {
|
|
3838
|
+
creationFeeSol: DEFAULT_CREATION_FEE_SOL,
|
|
3839
|
+
autoClaimFeeSol: DEFAULT_AUTO_CLAIM_FEE_SOL,
|
|
3840
|
+
streamflowFee: DEFAULT_STREAMFLOW_FEE,
|
|
3841
|
+
partnerFee: 0
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
/**
|
|
3845
|
+
* Returns total fee percent, streamflow fees + partner fees
|
|
3846
|
+
* @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
|
|
3847
|
+
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
3848
|
+
*/
|
|
3797
3849
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3798
3850
|
async getTotalFee(getFeesData) {
|
|
3799
3851
|
const fees = await this.getFees(getFeesData);
|
|
@@ -4320,6 +4372,8 @@ exports.CONTRACT_SEED = CONTRACT_SEED;
|
|
|
4320
4372
|
exports.CREATE_PARAMS_PADDING = CREATE_PARAMS_PADDING;
|
|
4321
4373
|
exports.Contract = Contract;
|
|
4322
4374
|
exports.ContractErrorCode = ContractErrorCode;
|
|
4375
|
+
exports.DEFAULT_AUTO_CLAIM_FEE_SOL = DEFAULT_AUTO_CLAIM_FEE_SOL;
|
|
4376
|
+
exports.DEFAULT_CREATION_FEE_SOL = DEFAULT_CREATION_FEE_SOL;
|
|
4323
4377
|
exports.DEFAULT_STREAMFLOW_FEE = DEFAULT_STREAMFLOW_FEE;
|
|
4324
4378
|
exports.ESCROW_SEED = ESCROW_SEED;
|
|
4325
4379
|
exports.FEES_METADATA_SEED = FEES_METADATA_SEED;
|
|
@@ -4344,6 +4398,7 @@ exports.StreamType = StreamType;
|
|
|
4344
4398
|
exports.TEST_ORACLE_DISCRIMINATOR = TEST_ORACLE_DISCRIMINATOR;
|
|
4345
4399
|
exports.TEST_ORACLE_SEED = TEST_ORACLE_SEED;
|
|
4346
4400
|
exports.TX_FINALITY_CONFIRMED = TX_FINALITY_CONFIRMED;
|
|
4401
|
+
exports.WITHDRAWOR = WITHDRAWOR;
|
|
4347
4402
|
exports.WITHDRAWOR_PUBLIC_KEY = WITHDRAWOR_PUBLIC_KEY;
|
|
4348
4403
|
exports.WITHDRAW_AVAILABLE_AMOUNT = WITHDRAW_AVAILABLE_AMOUNT;
|
|
4349
4404
|
exports.buildStreamType = buildStreamType;
|