@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/cjs/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, ApiClient, ApiClientOptions, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, Chain, ContractSchema, ContractType, DEFAULT_AUTO_CLAIM_FEE_SOL, DEFAULT_CREATION_FEE_SOL, DEFAULT_STREAMFLOW_FEE, DynamicContractSchema, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, GetContractsOptions, MAX_SAFE_UNIX_TIME_VALUE, METADATA_SEED, ORIGINAL_CONTRACT_SENDER_OFFSET, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, PriceOracleType, 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, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, TabulariumContract, WITHDRAWOR, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, claimRoutedFeeStreamInstruction, createClient, createStreamInstruction, createStreamV2Instruction, createUncheckedStreamInstruction, createUncheckedStreamV2Instruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveRepopulatedMetadataPDA, deriveStreamMetadataPDA, deriveTestOraclePDA, extractSolanaErrorCode, getMetadataKey, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL, topupStreamInstruction, transferStreamInstruction, transformContract, updateStreamInstruction, withdrawStreamInstruction } from './solana/index.cjs';
|
|
1
|
+
export { g as Account, h as AlignedContract, i as AlignedProxyErrorCode, A as AlignedStream, j as AlignedStreamData, k as AlignedUnlocksContract, l as BatchCreationItem, m as BatchExecuteResult, n as BatchInstructionResult, B as BatchItem, o as BatchItemError, a as BatchItemResult, p as BatchItemSuccess, q as BuildTransactionFn, r as BuildTransactionOptions, s as BuiltTransaction, C as CancelFn, t as ChangeOracleParams, u as ClientCreationOptions, v as Contract, w as ContractErrorCode, x as CreateBatchFn, y as CreateFn, z as CreateInstructionResult, E as CreateParams, F as CreateTestOracleParams, D as DecodedStream, G as Env, H as ExecuteBatchFn, J as ExecuteBatchSequentialFn, K as ExecuteFn, L as ExecutionEnv, M as IAlignedStreamConfig, N as IBaseStreamConfig, O as ICancelData, P as IClaimRoutedFeeData, d as ICreateAlignedStreamData, Q as ICreateExt, e as ICreateLinearStreamData, T as ICreateLockBatchParams, U as ICreateLockParams, V as ICreateMultiError, W as ICreateMultipleAlignedStreamData, X as ICreateMultipleLinearStreamData, Y as ICreateMultipleStreamData, Z as ICreateResult, c as ICreateStreamData, _ as ICreateStreamExt, $ as ICreateStreamInstructions, a0 as ICreateVestingBatchParams, a1 as ICreateVestingParams, a2 as IFees, a3 as IGetAllData, a4 as IGetFeesData, a5 as IGetOneData, a6 as IInteractData, a7 as IInteractStreamExt, a8 as ILockBatchRecipient, a9 as IMultiTransactionResult, aa as IPrepareCreateStreamExt, ab as IPrepareStreamExt, ac as IPrepareTopUpstreamExt, ad as IRecipient, f as ISearchStreams, ae as ITopUpData, af as ITopUpStreamExt, ag as ITransactionExtWithInstructions, ah as ITransactionResult, ai as ITransferData, I as IUpdateData, aj as IVestingBatchRecipient, ak as IWithdrawData, al as InstructionGenerator, am as InstructionResult, an as Invoker, ao as LinearStream, ap as MetadataRecipientHashMap, aq as NativeOptions, ar as OracleType, as as OracleTypeName, R as RoutedFeeDestination, at as SignFn, au as SolanaStreamClient, b as Stream, av as StreamClientOptions, aw as StreamClientOptionsWithConnection, ax as StreamDirection, S as StreamType, ay as TestOracle, az as TopupFn, aA as TransactionSchedulingOptions, aB as TransferFn, aC as UpdateFn, aD as UpdateTestOracleParams, aE as WithdrawFn, aF as buildLockBatchParams, aG as buildLockParams, aH as buildTransaction, aI as buildVestingBatchParams, aJ as buildVestingParams, aK as cancel, aL as computeAmountPerPeriod, aM as create, aN as createBatch, aO as createClientFromEnv, aP as createLock, aQ as createLockBatch, aR as createVesting, aS as createVestingBatch, aT as execute, aU as executeBatch, aV as executeBatchSequential, aW as resolveConnection, aX as resolveDuration, aY as sign, aZ as topup, a_ as transfer, a$ as update, b0 as withdraw } from './index-BLL6w66C.cjs';
|
|
2
|
+
export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, ApiClient, ApiClientOptions, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, Chain, ContractSchema, ContractType, DEFAULT_AUTO_CLAIM_FEE_SOL, DEFAULT_CREATION_FEE_SOL, DEFAULT_STREAMFLOW_FEE, DynamicContractSchema, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, GetContractsOptions, MAX_SAFE_UNIX_TIME_VALUE, METADATA_SEED, ORIGINAL_CONTRACT_SENDER_OFFSET, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, PriceOracleType, 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, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, TabulariumContract, WITHDRAWOR, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, claimRoutedFeeStreamInstruction, createClient, createStreamInstruction, createStreamV2Instruction, createUncheckedStreamInstruction, createUncheckedStreamV2Instruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveRepopulatedMetadataPDA, deriveStreamMetadataPDA, deriveTestOraclePDA, encodeStreamName, encodeStreamNameAsArray, extractSolanaErrorCode, getMetadataKey, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isStrictTokenLockCreate, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL, topupStreamInstruction, transferStreamInstruction, transformContract, updateStreamInstruction, withdrawStreamInstruction } from './solana/index.cjs';
|
|
3
3
|
export { ContractError, ICluster, getBN, getNumberFromBN } from '@streamflow/common';
|
|
4
4
|
import '@solana/wallet-adapter-base';
|
|
5
5
|
import '@solana/web3.js';
|
|
@@ -81,6 +81,24 @@ var isTokenLock = (streamData) => {
|
|
|
81
81
|
}
|
|
82
82
|
return false;
|
|
83
83
|
};
|
|
84
|
+
var isStrictTokenLockCreate = (data, now = Math.floor(Date.now() / 1e3)) => {
|
|
85
|
+
if (data.canTopup || data.automaticWithdrawal || data.cancelableBySender || data.cancelableByRecipient || data.transferableBySender) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if (!isCliffCloseToDepositedAmount({ depositedAmount: data.amount, cliffAmount: data.cliffAmount })) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if (data.cliffAmount.gt(data.amount) || data.amountPerPeriod.isZero()) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const remaining = data.amount.sub(data.cliffAmount);
|
|
95
|
+
const periodsLeft = remaining.add(data.amountPerPeriod).subn(1).div(data.amountPerPeriod);
|
|
96
|
+
const cliff = data.start === 0 ? now : data.cliff;
|
|
97
|
+
const unlockStart = cliff > 0 ? cliff : data.start;
|
|
98
|
+
const end = new BN3__default.default(unlockStart).add(periodsLeft.mul(new BN3__default.default(data.period)));
|
|
99
|
+
const cliffEndGap = end.sub(new BN3__default.default(cliff));
|
|
100
|
+
return !cliffEndGap.isNeg() && cliffEndGap.lten(MAX_CLIFF_END_GAP_SECONDS);
|
|
101
|
+
};
|
|
84
102
|
var buildStreamType = (streamData) => {
|
|
85
103
|
if (isTokenLock(streamData)) {
|
|
86
104
|
return "lock" /* Lock */;
|
|
@@ -475,7 +493,13 @@ var encodeUpdateStream = (values, data) => {
|
|
|
475
493
|
structs.push(BufferLayout__namespace.u8("cancelable_by_sender_exists"));
|
|
476
494
|
structs.push(BufferLayout__namespace.u8("cancelable_by_sender"));
|
|
477
495
|
} else {
|
|
478
|
-
structs.push(BufferLayout__namespace.u8("
|
|
496
|
+
structs.push(BufferLayout__namespace.u8("cancelable_by_sender_exists"));
|
|
497
|
+
}
|
|
498
|
+
if (values.stream_name) {
|
|
499
|
+
structs.push(BufferLayout__namespace.u8("stream_name_exists"));
|
|
500
|
+
structs.push(BufferLayout__namespace.blob(64, "stream_name"));
|
|
501
|
+
} else {
|
|
502
|
+
structs.push(BufferLayout__namespace.u8("stream_name_exists"));
|
|
479
503
|
}
|
|
480
504
|
return BufferLayout__namespace.struct(structs).encode(
|
|
481
505
|
{
|
|
@@ -490,7 +514,9 @@ var encodeUpdateStream = (values, data) => {
|
|
|
490
514
|
transferable_by_recipient_exists: values.transferable_by_recipient !== void 0 ? 1 : 0,
|
|
491
515
|
transferable_by_recipient: values.transferable_by_recipient ?? 0,
|
|
492
516
|
cancelable_by_sender_exists: values.cancelable_by_sender !== void 0 ? 1 : 0,
|
|
493
|
-
cancelable_by_sender: values.cancelable_by_sender ?? 0
|
|
517
|
+
cancelable_by_sender: values.cancelable_by_sender ?? 0,
|
|
518
|
+
stream_name_exists: values.stream_name ? 1 : 0,
|
|
519
|
+
stream_name: values.stream_name ?? 0
|
|
494
520
|
},
|
|
495
521
|
data
|
|
496
522
|
);
|
|
@@ -507,6 +533,13 @@ var calculateTotalAmountToDeposit = (depositedAmount, totalFee) => {
|
|
|
507
533
|
const totalFeeNormalized = new BN3__default.default(totalFee * FEE_NORMALIZER);
|
|
508
534
|
return depositedAmount.mul(totalFeeNormalized.add(FEE_MULTIPLIER)).div(FEE_MULTIPLIER);
|
|
509
535
|
};
|
|
536
|
+
var encodeStreamName = (name) => {
|
|
537
|
+
const encoded = new TextEncoder().encode(name);
|
|
538
|
+
return Buffer.alloc(64).fill(encoded, 0, encoded.byteLength);
|
|
539
|
+
};
|
|
540
|
+
var encodeStreamNameAsArray = (name) => {
|
|
541
|
+
return Array.from(encodeStreamName(name));
|
|
542
|
+
};
|
|
510
543
|
var decodeStream = (buf) => {
|
|
511
544
|
const raw = streamLayout.decode(buf);
|
|
512
545
|
return {
|
|
@@ -650,8 +683,6 @@ var createStreamInstruction = async (data, programId, accounts) => {
|
|
|
650
683
|
keys.push({ pubkey: accounts.partnerLink.pubkey, isSigner: accounts.partnerLink.isSigner, isWritable: false });
|
|
651
684
|
}
|
|
652
685
|
let bufferData = buffer.Buffer.alloc(createStreamLayout.span);
|
|
653
|
-
const encodedUIntArray = new TextEncoder().encode(data.name);
|
|
654
|
-
const streamNameBuffer = buffer.Buffer.alloc(64).fill(encodedUIntArray, 0, encodedUIntArray.byteLength);
|
|
655
686
|
const decodedData = {
|
|
656
687
|
start_time: data.start.toArrayLike(buffer.Buffer, "le", 8),
|
|
657
688
|
net_amount_deposited: data.depositedAmount.toArrayLike(buffer.Buffer, "le", 8),
|
|
@@ -669,7 +700,7 @@ var createStreamInstruction = async (data, programId, accounts) => {
|
|
|
669
700
|
can_update_rate: Number(data.canUpdateRate),
|
|
670
701
|
_can_update_rate_discriminator: 1,
|
|
671
702
|
pausable: Number(data.canPause),
|
|
672
|
-
stream_name:
|
|
703
|
+
stream_name: encodeStreamName(data.name),
|
|
673
704
|
withdraw_frequency: data.withdrawFrequency.toArrayLike(buffer.Buffer, "le", 8)
|
|
674
705
|
};
|
|
675
706
|
const encodeLength = createStreamLayout.encode(decodedData, bufferData);
|
|
@@ -930,7 +961,8 @@ var updateStreamInstruction = async (params, programId, { authority, metadata, w
|
|
|
930
961
|
amount_per_period: params.amountPerPeriod ? params.amountPerPeriod.toArrayLike(buffer.Buffer, "le", 8) : void 0,
|
|
931
962
|
transferable_by_sender: params.transferableBySender !== void 0 ? Number(params.transferableBySender) : void 0,
|
|
932
963
|
transferable_by_recipient: params.transferableByRecipient !== void 0 ? Number(params.transferableByRecipient) : void 0,
|
|
933
|
-
cancelable_by_sender: params.cancelableBySender !== void 0 ? Number(params.cancelableBySender) : void 0
|
|
964
|
+
cancelable_by_sender: params.cancelableBySender !== void 0 ? Number(params.cancelableBySender) : void 0,
|
|
965
|
+
stream_name: params.name !== void 0 ? encodeStreamName(params.name) : void 0
|
|
934
966
|
};
|
|
935
967
|
const encodeLength = encodeUpdateStream(decodedData, data);
|
|
936
968
|
data = data.slice(0, encodeLength);
|
|
@@ -3057,6 +3089,17 @@ var streamflow_aligned_unlocks_default = {
|
|
|
3057
3089
|
type: {
|
|
3058
3090
|
option: "bool"
|
|
3059
3091
|
}
|
|
3092
|
+
},
|
|
3093
|
+
{
|
|
3094
|
+
name: "stream_name",
|
|
3095
|
+
type: {
|
|
3096
|
+
option: {
|
|
3097
|
+
array: [
|
|
3098
|
+
"u8",
|
|
3099
|
+
64
|
|
3100
|
+
]
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3060
3103
|
}
|
|
3061
3104
|
]
|
|
3062
3105
|
}
|
|
@@ -3253,6 +3296,27 @@ var transformContract = async (schema) => {
|
|
|
3253
3296
|
// solana/StreamClient.ts
|
|
3254
3297
|
var METADATA_ACC_SIZE = 1104;
|
|
3255
3298
|
var ALIGNED_METADATA_ACC_SIZE = 320;
|
|
3299
|
+
var PARTNER_LINK_DISCRIMINATOR = buffer.Buffer.from([114, 220, 250, 94, 181, 182, 195, 222]);
|
|
3300
|
+
var PARTNER_LINK_SIZE = 8 + 32 + 32 + 32;
|
|
3301
|
+
var decodePartnerLink = (data) => data.length >= PARTNER_LINK_SIZE && data.subarray(0, 8).equals(PARTNER_LINK_DISCRIMINATOR) ? { partnerPubkey: new web3_js.PublicKey(data.subarray(8, 40)), linkedPubkey: new web3_js.PublicKey(data.subarray(40, 72)) } : null;
|
|
3302
|
+
var findFees = (partners, address) => {
|
|
3303
|
+
const filteredPartners = partners.filter((partner2) => new web3_js.PublicKey(partner2.pubkey).toString() === address);
|
|
3304
|
+
if (filteredPartners.length === 0) {
|
|
3305
|
+
return null;
|
|
3306
|
+
}
|
|
3307
|
+
if (filteredPartners.length > 1) {
|
|
3308
|
+
throw new Error("More than one partner found, fees fetching is not possible.");
|
|
3309
|
+
}
|
|
3310
|
+
const partner = filteredPartners[0];
|
|
3311
|
+
return {
|
|
3312
|
+
creationFeeSol: Number(partner.creation_fee),
|
|
3313
|
+
autoClaimFeeSol: Number(partner.auto_claim_fee),
|
|
3314
|
+
streamflowFee: Number(partner.token_fee_percent.toFixed(4)),
|
|
3315
|
+
streamflowLockFee: Number(partner.token_lock_token_fee_percent.toFixed(4)),
|
|
3316
|
+
partnerFee: 0
|
|
3317
|
+
};
|
|
3318
|
+
};
|
|
3319
|
+
var getWrapFeePercent = (rates, data) => isStrictTokenLockCreate(data) ? rates.streamflowLockFee : rates.streamflowFee;
|
|
3256
3320
|
var SolanaStreamClient = class {
|
|
3257
3321
|
/**
|
|
3258
3322
|
* Create Stream instance
|
|
@@ -3346,10 +3410,8 @@ var SolanaStreamClient = class {
|
|
|
3346
3410
|
tokenProgramId ? new web3_js.PublicKey(tokenProgramId) : void 0
|
|
3347
3411
|
);
|
|
3348
3412
|
if (isNative) {
|
|
3349
|
-
const
|
|
3350
|
-
|
|
3351
|
-
});
|
|
3352
|
-
const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
|
|
3413
|
+
const rates = await this.getCreateFeeRates(data.partnerLink, sender.publicKey);
|
|
3414
|
+
const totalAmount = calculateTotalAmountToDeposit(amount, getWrapFeePercent(rates, data));
|
|
3353
3415
|
ixs.push(...await common.prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
|
|
3354
3416
|
}
|
|
3355
3417
|
const {
|
|
@@ -3494,8 +3556,6 @@ var SolanaStreamClient = class {
|
|
|
3494
3556
|
...await this.getCreateATAInstructions([recipientPublicKey], mintPublicKey, sender, true, tokenProgramId)
|
|
3495
3557
|
);
|
|
3496
3558
|
}
|
|
3497
|
-
const encodedUIntArray = new TextEncoder().encode(streamName);
|
|
3498
|
-
const streamNameArray = Array.from(encodedUIntArray);
|
|
3499
3559
|
const createMethod = this.alignedProxyProgram.methods.create({
|
|
3500
3560
|
startTime: new BN3__default.default(start),
|
|
3501
3561
|
netAmountDeposited: depositedAmount,
|
|
@@ -3509,7 +3569,7 @@ var SolanaStreamClient = class {
|
|
|
3509
3569
|
cancelableBySender,
|
|
3510
3570
|
canTopup,
|
|
3511
3571
|
oracleType: !!oracleType ? { [oracleType]: {} } : { none: {} },
|
|
3512
|
-
streamName:
|
|
3572
|
+
streamName: encodeStreamNameAsArray(streamName),
|
|
3513
3573
|
minPrice: typeof minPrice === "number" ? common.getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW2) : minPrice,
|
|
3514
3574
|
maxPrice: typeof maxPrice === "number" ? common.getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW2) : maxPrice,
|
|
3515
3575
|
minPercentage: typeof minPercentage === "number" ? common.getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW2) : minPercentage,
|
|
@@ -3738,7 +3798,20 @@ var SolanaStreamClient = class {
|
|
|
3738
3798
|
computeLimit
|
|
3739
3799
|
});
|
|
3740
3800
|
if (isNative) {
|
|
3741
|
-
const
|
|
3801
|
+
const rates = await this.getCreateFeeRates(partnerLink, sender.publicKey);
|
|
3802
|
+
const totalFee = getWrapFeePercent(rates, {
|
|
3803
|
+
start,
|
|
3804
|
+
amount: depositedAmount,
|
|
3805
|
+
period,
|
|
3806
|
+
cliff,
|
|
3807
|
+
cliffAmount,
|
|
3808
|
+
amountPerPeriod,
|
|
3809
|
+
canTopup,
|
|
3810
|
+
automaticWithdrawal,
|
|
3811
|
+
cancelableBySender,
|
|
3812
|
+
cancelableByRecipient,
|
|
3813
|
+
transferableBySender
|
|
3814
|
+
});
|
|
3742
3815
|
const totalAmount = calculateTotalAmountToDeposit(depositedAmount, totalFee);
|
|
3743
3816
|
ixs.push(...await common.prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
|
|
3744
3817
|
}
|
|
@@ -3828,6 +3901,7 @@ var SolanaStreamClient = class {
|
|
|
3828
3901
|
if (recipients.length === 0) {
|
|
3829
3902
|
throw new Error("Recipients array is empty!");
|
|
3830
3903
|
}
|
|
3904
|
+
const wrapFeeRates = isNative ? await this.getCreateFeeRates(data.partnerLink, sender.publicKey) : void 0;
|
|
3831
3905
|
for (let i = 0; i < recipients.length; i++) {
|
|
3832
3906
|
const recipientData = recipients[i];
|
|
3833
3907
|
const createStreamData = { ...streamParams, ...recipientData };
|
|
@@ -3836,8 +3910,8 @@ var SolanaStreamClient = class {
|
|
|
3836
3910
|
metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
|
|
3837
3911
|
};
|
|
3838
3912
|
const wrapInstructions = [];
|
|
3839
|
-
if (
|
|
3840
|
-
const totalFee =
|
|
3913
|
+
if (wrapFeeRates) {
|
|
3914
|
+
const totalFee = getWrapFeePercent(wrapFeeRates, createStreamData);
|
|
3841
3915
|
const recipientAmount = calculateTotalAmountToDeposit(recipientData.amount, totalFee);
|
|
3842
3916
|
wrapInstructions.push(...await common.prepareWrappedAccount(this.connection, sender.publicKey, recipientAmount));
|
|
3843
3917
|
}
|
|
@@ -4731,7 +4805,8 @@ var SolanaStreamClient = class {
|
|
|
4731
4805
|
await (isAlignedUnlock ? this.alignedProxyProgram.methods.updateContract({
|
|
4732
4806
|
transferableBySender: data.transferableBySender ?? null,
|
|
4733
4807
|
transferableByRecipient: data.transferableByRecipient ?? null,
|
|
4734
|
-
cancelableBySender: data.cancelableBySender ?? null
|
|
4808
|
+
cancelableBySender: data.cancelableBySender ?? null,
|
|
4809
|
+
streamName: data.name !== void 0 ? encodeStreamNameAsArray(data.name) : null
|
|
4735
4810
|
}).accounts({ sender: invoker.publicKey, streamMetadata: streamPublicKey, withdrawor: WITHDRAWOR_PUBLIC_KEY }).accountsPartial({ streamflowProgram: this.programId }).instruction() : updateStreamInstruction(data, this.programId, {
|
|
4736
4811
|
authority: invoker.publicKey,
|
|
4737
4812
|
metadata: streamPublicKey,
|
|
@@ -4747,26 +4822,38 @@ var SolanaStreamClient = class {
|
|
|
4747
4822
|
* @returns Fees
|
|
4748
4823
|
*/
|
|
4749
4824
|
async getFees({ address }) {
|
|
4825
|
+
const partners = await this.getFeeRows();
|
|
4826
|
+
return partners ? findFees(partners, address) : null;
|
|
4827
|
+
}
|
|
4828
|
+
async getFeeRows() {
|
|
4750
4829
|
const data = await this.connection.getAccountInfo(this.feeOraclePublicKey);
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4830
|
+
return data ? borsh__namespace.deserialize(PARTNERS_SCHEMA, data.data) : null;
|
|
4831
|
+
}
|
|
4832
|
+
/**
|
|
4833
|
+
* Fee rates the program applies to a create from `sender` with `partnerLink`, used to size the WSOL wrap.
|
|
4834
|
+
* Mirrors `resolve_vesting_partner`: a `partnerLink` counts if it signs or the partner oracle owns it, and a
|
|
4835
|
+
* PartnerLink account stands for its partner. A link to another wallet fails the program's lookup, which then
|
|
4836
|
+
* charges its hardcoded fallback and skips the sender's own row. Otherwise the sender's own row, then the
|
|
4837
|
+
* partner's, then the default row. `partner` only takes a share and never picks the row.
|
|
4838
|
+
*/
|
|
4839
|
+
async getCreateFeeRates(partnerLink, sender) {
|
|
4840
|
+
const fallback = { streamflowFee: DEFAULT_STREAMFLOW_FEE, streamflowLockFee: DEFAULT_STREAMFLOW_FEE };
|
|
4841
|
+
let linkedPartner;
|
|
4842
|
+
if (partnerLink?.isSigner) {
|
|
4843
|
+
linkedPartner = common.pk(partnerLink.address).toBase58();
|
|
4844
|
+
} else if (partnerLink) {
|
|
4845
|
+
const address = common.pk(partnerLink.address);
|
|
4846
|
+
const account = await this.connection.getAccountInfo(address);
|
|
4847
|
+
if (account?.owner.equals(this.partnerOracleProgramId)) {
|
|
4848
|
+
const link = decodePartnerLink(account.data);
|
|
4849
|
+
if (link && !link.linkedPubkey.equals(sender)) {
|
|
4850
|
+
return fallback;
|
|
4851
|
+
}
|
|
4852
|
+
linkedPartner = (link?.partnerPubkey ?? address).toBase58();
|
|
4853
|
+
}
|
|
4761
4854
|
}
|
|
4762
|
-
const
|
|
4763
|
-
return
|
|
4764
|
-
creationFeeSol: Number(partner.creation_fee),
|
|
4765
|
-
autoClaimFeeSol: Number(partner.auto_claim_fee),
|
|
4766
|
-
streamflowFee: Number(partner.token_fee_percent.toFixed(4)),
|
|
4767
|
-
streamflowLockFee: Number(partner.token_lock_token_fee_percent.toFixed(4)),
|
|
4768
|
-
partnerFee: 0
|
|
4769
|
-
};
|
|
4855
|
+
const partners = await this.getFeeRows() ?? [];
|
|
4856
|
+
return findFees(partners, sender.toBase58()) ?? (linkedPartner ? findFees(partners, linkedPartner) : null) ?? findFees(partners, WITHDRAWOR) ?? fallback;
|
|
4770
4857
|
}
|
|
4771
4858
|
/**
|
|
4772
4859
|
* Gets default streamflow fee
|