@streamflow/stream 10.0.0-alpha.p311.10f340e → 10.0.0-alpha.p313.3ce4d29
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 +8 -64
- package/dist/cjs/index.cjs +440 -3794
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +3 -182
- package/dist/cjs/solana/index.cjs +393 -309
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +1134 -17
- package/dist/esm/index.d.ts +3 -182
- package/dist/esm/index.js +258 -3626
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +1134 -17
- package/dist/esm/solana/index.js +274 -240
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -43
- package/dist/cjs/BaseStreamClient-Dvs8yWEE.d.cts +0 -550
- package/dist/cjs/aptos/index.cjs +0 -450
- package/dist/cjs/aptos/index.cjs.map +0 -1
- package/dist/cjs/aptos/index.d.cts +0 -14
- package/dist/cjs/evm/index.cjs +0 -1909
- package/dist/cjs/evm/index.cjs.map +0 -1
- package/dist/cjs/evm/index.d.cts +0 -13
- package/dist/cjs/index-BHKWsVnx.d.cts +0 -849
- package/dist/cjs/index-CGNg22mO.d.cts +0 -203
- package/dist/cjs/index-Dk1hKzM3.d.cts +0 -213
- package/dist/cjs/index-dSxy_PVV.d.cts +0 -136
- package/dist/cjs/sui/index.cjs +0 -1015
- package/dist/cjs/sui/index.cjs.map +0 -1
- package/dist/cjs/sui/index.d.cts +0 -13
- package/dist/esm/BaseStreamClient-Dvs8yWEE.d.ts +0 -550
- package/dist/esm/aptos/index.d.ts +0 -14
- package/dist/esm/aptos/index.js +0 -437
- package/dist/esm/aptos/index.js.map +0 -1
- package/dist/esm/evm/index.d.ts +0 -13
- package/dist/esm/evm/index.js +0 -1896
- package/dist/esm/evm/index.js.map +0 -1
- package/dist/esm/index-CRXW7eZy.d.ts +0 -203
- package/dist/esm/index-CgDmuCzv.d.ts +0 -849
- package/dist/esm/index-DED7TgAo.d.ts +0 -136
- package/dist/esm/index-li6QZ_tF.d.ts +0 -213
- package/dist/esm/sui/index.d.ts +0 -13
- package/dist/esm/sui/index.js +0 -1005
- package/dist/esm/sui/index.js.map +0 -1
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var BN3 = require('bn.js');
|
|
4
4
|
var bs58 = require('bs58');
|
|
5
5
|
var buffer = require('buffer');
|
|
6
6
|
var splToken = require('@solana/spl-token');
|
|
7
7
|
var web3_js = require('@solana/web3.js');
|
|
8
|
-
var
|
|
8
|
+
var common = require('@streamflow/common');
|
|
9
9
|
var borsh = require('borsh');
|
|
10
10
|
var anchor = require('@coral-xyz/anchor');
|
|
11
|
-
var common = require('@streamflow/common');
|
|
12
11
|
var BufferLayout = require('@solana/buffer-layout');
|
|
13
12
|
|
|
14
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -31,20 +30,13 @@ function _interopNamespace(e) {
|
|
|
31
30
|
return Object.freeze(n);
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
var
|
|
33
|
+
var BN3__default = /*#__PURE__*/_interopDefault(BN3);
|
|
35
34
|
var bs58__default = /*#__PURE__*/_interopDefault(bs58);
|
|
36
35
|
var borsh__namespace = /*#__PURE__*/_interopNamespace(borsh);
|
|
37
36
|
var BufferLayout__namespace = /*#__PURE__*/_interopNamespace(BufferLayout);
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
var __export = (target, all) => {
|
|
41
|
-
for (var name in all)
|
|
42
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
43
|
-
};
|
|
38
|
+
// solana/StreamClient.ts
|
|
44
39
|
var MAX_SAFE_UNIX_TIME_VALUE = 864e10;
|
|
45
|
-
var WITHDRAW_AVAILABLE_AMOUNT = new BN4__default.default("18446744073709551615");
|
|
46
|
-
|
|
47
|
-
// common/contractUtils.ts
|
|
48
40
|
var calculateUnlockedAmount = ({
|
|
49
41
|
depositedAmount,
|
|
50
42
|
cliff,
|
|
@@ -57,15 +49,24 @@ var calculateUnlockedAmount = ({
|
|
|
57
49
|
fundsUnlockedAtLastRateChange
|
|
58
50
|
}) => {
|
|
59
51
|
const deposited = depositedAmount;
|
|
60
|
-
if (currentTimestamp < cliff) return new
|
|
52
|
+
if (currentTimestamp < cliff) return new BN3__default.default(0);
|
|
61
53
|
if (currentTimestamp > end) return deposited;
|
|
62
54
|
const savedUnlockedFunds = lastRateChangeTime === 0 ? cliffAmount : fundsUnlockedAtLastRateChange;
|
|
63
55
|
const savedUnlockedFundsTime = lastRateChangeTime === 0 ? cliff : lastRateChangeTime;
|
|
64
|
-
const streamed = new
|
|
56
|
+
const streamed = new BN3__default.default(Math.floor((currentTimestamp - savedUnlockedFundsTime) / period)).mul(amountPerPeriod).add(savedUnlockedFunds);
|
|
65
57
|
return streamed.lt(deposited) ? streamed : deposited;
|
|
66
58
|
};
|
|
67
59
|
var isCliffCloseToDepositedAmount = (streamData) => {
|
|
68
|
-
return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new
|
|
60
|
+
return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new BN3__default.default(1)));
|
|
61
|
+
};
|
|
62
|
+
var isPayment = (streamData) => {
|
|
63
|
+
return streamData.canTopup;
|
|
64
|
+
};
|
|
65
|
+
var isVesting = (streamData) => {
|
|
66
|
+
return !streamData.canTopup && !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
|
|
67
|
+
};
|
|
68
|
+
var isAligned = (stream) => {
|
|
69
|
+
return "minPrice" in stream && "maxPrice" in stream && "minPercentage" in stream && "maxPercentage" in stream;
|
|
69
70
|
};
|
|
70
71
|
var isCreateAlignedStreamData = (obj) => {
|
|
71
72
|
return "minPrice" in obj && "maxPrice" in obj && "minPercentage" in obj && "maxPercentage" in obj;
|
|
@@ -77,66 +78,167 @@ var isTokenLock = (streamData) => {
|
|
|
77
78
|
return !streamData.canTopup && !streamData.automaticWithdrawal && !streamData.cancelableBySender && !streamData.cancelableByRecipient && !streamData.transferableBySender && (isCliffCloseToDepositedAmount(streamData) || isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage));
|
|
78
79
|
};
|
|
79
80
|
var buildStreamType = (streamData) => {
|
|
81
|
+
if (isVesting(streamData)) {
|
|
82
|
+
return "vesting" /* Vesting */;
|
|
83
|
+
}
|
|
80
84
|
if (isTokenLock(streamData)) {
|
|
81
85
|
return "lock" /* Lock */;
|
|
82
86
|
}
|
|
83
|
-
return "
|
|
87
|
+
return "payment" /* Payment */;
|
|
84
88
|
};
|
|
85
89
|
var decodeEndTime = (endTime) => {
|
|
86
|
-
if (endTime.gt(new
|
|
90
|
+
if (endTime.gt(new BN3__default.default(MAX_SAFE_UNIX_TIME_VALUE))) {
|
|
87
91
|
return MAX_SAFE_UNIX_TIME_VALUE;
|
|
88
92
|
}
|
|
89
93
|
return endTime.toNumber();
|
|
90
94
|
};
|
|
91
|
-
var
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
var ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
96
|
+
var StreamDirection = /* @__PURE__ */ ((StreamDirection2) => {
|
|
97
|
+
StreamDirection2["Outgoing"] = "outgoing";
|
|
98
|
+
StreamDirection2["Incoming"] = "incoming";
|
|
99
|
+
StreamDirection2["All"] = "all";
|
|
100
|
+
return StreamDirection2;
|
|
101
|
+
})(StreamDirection || {});
|
|
102
|
+
var StreamType = /* @__PURE__ */ ((StreamType2) => {
|
|
103
|
+
StreamType2["All"] = "all";
|
|
104
|
+
StreamType2["Payment"] = "payment";
|
|
105
|
+
StreamType2["Vesting"] = "vesting";
|
|
106
|
+
StreamType2["Lock"] = "lock";
|
|
107
|
+
return StreamType2;
|
|
108
|
+
})(StreamType || {});
|
|
109
|
+
var ContractErrorCode = /* @__PURE__ */ ((ContractErrorCode2) => {
|
|
110
|
+
ContractErrorCode2["AccountsNotWritable"] = "AccountsNotWritable";
|
|
111
|
+
ContractErrorCode2["InvalidMetadata"] = "InvalidMetadata";
|
|
112
|
+
ContractErrorCode2["InvalidMetadataAccount"] = "InvalidMetadataAccount";
|
|
113
|
+
ContractErrorCode2["MetadataAccountMismatch"] = "MetadataAccountMismatch";
|
|
114
|
+
ContractErrorCode2["InvalidEscrowAccount"] = "InvalidEscrowAccount";
|
|
115
|
+
ContractErrorCode2["NotAssociated"] = "NotAssociated";
|
|
116
|
+
ContractErrorCode2["MintMismatch"] = "MintMismatch";
|
|
117
|
+
ContractErrorCode2["TransferNotAllowed"] = "TransferNotAllowed";
|
|
118
|
+
ContractErrorCode2["ContractClosed"] = "ContractClosed";
|
|
119
|
+
ContractErrorCode2["InvalidTreasury"] = "InvalidTreasury";
|
|
120
|
+
ContractErrorCode2["InvalidTimestamps"] = "InvalidTimestamps";
|
|
121
|
+
ContractErrorCode2["InvalidDepositConfiguration"] = "InvalidDepositConfiguration";
|
|
122
|
+
ContractErrorCode2["AmountIsZero"] = "AmountIsZero";
|
|
123
|
+
ContractErrorCode2["AmountMoreThanAvailable"] = "AmountMoreThanAvailable";
|
|
124
|
+
ContractErrorCode2["AmountAvailableIsZero"] = "AmountAvailableIsZero";
|
|
125
|
+
ContractErrorCode2["ArithmeticError"] = "ArithmeticError";
|
|
126
|
+
ContractErrorCode2["InvalidMetadataSize"] = "InvalidMetadataSize";
|
|
127
|
+
ContractErrorCode2["UninitializedMetadata"] = "UninitializedMetadata";
|
|
128
|
+
ContractErrorCode2["Unauthorized"] = "Unauthorized";
|
|
129
|
+
ContractErrorCode2["SelfTransfer"] = "SelfTransfer";
|
|
130
|
+
ContractErrorCode2["AlreadyPaused"] = "AlreadyPaused";
|
|
131
|
+
ContractErrorCode2["NotPaused"] = "NotPaused";
|
|
132
|
+
ContractErrorCode2["MetadataNotRentExempt"] = "MetadataNotRentExempt";
|
|
133
|
+
return ContractErrorCode2;
|
|
134
|
+
})(ContractErrorCode || {});
|
|
135
|
+
var AlignedProxyErrorCode = /* @__PURE__ */ ((AlignedProxyErrorCode2) => {
|
|
136
|
+
AlignedProxyErrorCode2["Unauthorized"] = "Unauthorized";
|
|
137
|
+
AlignedProxyErrorCode2["ArithmeticError"] = "ArithmeticError";
|
|
138
|
+
AlignedProxyErrorCode2["UnsupportedTokenExtensions"] = "UnsupportedTokenExtensions";
|
|
139
|
+
AlignedProxyErrorCode2["PeriodTooShort"] = "PeriodTooShort";
|
|
140
|
+
AlignedProxyErrorCode2["InvalidTickSize"] = "InvalidTickSize";
|
|
141
|
+
AlignedProxyErrorCode2["InvalidPercentageBoundaries"] = "InvalidPercentageBoundaries";
|
|
142
|
+
AlignedProxyErrorCode2["InvalidPriceBoundaries"] = "InvalidPriceBoundaries";
|
|
143
|
+
AlignedProxyErrorCode2["UnsupportedOracle"] = "UnsupportedOracle";
|
|
144
|
+
AlignedProxyErrorCode2["InvalidOracleAccount"] = "InvalidOracleAccount";
|
|
145
|
+
AlignedProxyErrorCode2["InvalidOraclePrice"] = "InvalidOraclePrice";
|
|
146
|
+
AlignedProxyErrorCode2["InvalidStreamMetadata"] = "InvalidStreamMetadata";
|
|
147
|
+
AlignedProxyErrorCode2["AmountAlreadyUpdated"] = "AmountAlreadyUpdated";
|
|
148
|
+
AlignedProxyErrorCode2["AllFundsUnlocked"] = "AllFundsUnlocked";
|
|
149
|
+
return AlignedProxyErrorCode2;
|
|
150
|
+
})(AlignedProxyErrorCode || {});
|
|
151
|
+
var Contract = class {
|
|
152
|
+
constructor(stream) {
|
|
153
|
+
this.magic = stream.magic.toNumber();
|
|
154
|
+
this.version = stream.version.toNumber();
|
|
155
|
+
this.createdAt = stream.createdAt.toNumber();
|
|
156
|
+
this.withdrawnAmount = stream.withdrawnAmount;
|
|
157
|
+
this.canceledAt = stream.canceledAt.toNumber();
|
|
158
|
+
this.end = decodeEndTime(stream.end);
|
|
159
|
+
this.lastWithdrawnAt = stream.lastWithdrawnAt.toNumber();
|
|
160
|
+
this.sender = stream.sender.toBase58();
|
|
161
|
+
this.senderTokens = stream.senderTokens.toBase58();
|
|
162
|
+
this.recipient = stream.recipient.toBase58();
|
|
163
|
+
this.recipientTokens = stream.recipientTokens.toBase58();
|
|
164
|
+
this.mint = stream.mint.toBase58();
|
|
165
|
+
this.escrowTokens = stream.escrowTokens.toBase58();
|
|
166
|
+
this.streamflowTreasury = stream.streamflowTreasury.toBase58();
|
|
167
|
+
this.streamflowTreasuryTokens = stream.streamflowTreasuryTokens.toBase58();
|
|
168
|
+
this.streamflowFeeTotal = stream.streamflowFeeTotal;
|
|
169
|
+
this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
|
|
170
|
+
this.streamflowFeePercent = stream.streamflowFeePercent;
|
|
171
|
+
this.partnerFeeTotal = stream.partnerFeeTotal;
|
|
172
|
+
this.partnerFeeWithdrawn = stream.partnerFeeWithdrawn;
|
|
173
|
+
this.partnerFeePercent = stream.partnerFeePercent;
|
|
174
|
+
this.partner = stream.partner.toBase58();
|
|
175
|
+
this.partnerTokens = stream.partnerTokens?.toBase58();
|
|
176
|
+
this.start = stream.start.toNumber();
|
|
177
|
+
this.depositedAmount = stream.depositedAmount;
|
|
178
|
+
this.period = stream.period.toNumber();
|
|
179
|
+
this.amountPerPeriod = stream.amountPerPeriod;
|
|
180
|
+
this.cliff = stream.cliff.toNumber();
|
|
181
|
+
this.cliffAmount = stream.cliffAmount;
|
|
182
|
+
this.cancelableBySender = stream.cancelableBySender;
|
|
183
|
+
this.cancelableByRecipient = stream.cancelableByRecipient;
|
|
184
|
+
this.automaticWithdrawal = stream.automaticWithdrawal;
|
|
185
|
+
this.transferableBySender = stream.transferableBySender;
|
|
186
|
+
this.transferableByRecipient = stream.transferableByRecipient;
|
|
187
|
+
this.canTopup = stream.canTopup;
|
|
188
|
+
this.name = stream.name;
|
|
189
|
+
this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
|
|
190
|
+
this.closed = stream.closed;
|
|
191
|
+
this.currentPauseStart = stream.currentPauseStart.toNumber();
|
|
192
|
+
this.pauseCumulative = stream.pauseCumulative;
|
|
193
|
+
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
194
|
+
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
195
|
+
this.type = buildStreamType(this);
|
|
196
|
+
this.isAligned = false;
|
|
197
|
+
}
|
|
198
|
+
unlocked(currentTimestamp) {
|
|
199
|
+
return calculateUnlockedAmount({
|
|
200
|
+
...this,
|
|
201
|
+
currentTimestamp
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
remaining(decimals) {
|
|
205
|
+
return common.getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
var AlignedContract = class extends Contract {
|
|
209
|
+
constructor(stream, alignedProxy) {
|
|
210
|
+
super(stream);
|
|
211
|
+
this.minPrice = common.getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
212
|
+
this.maxPrice = common.getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
213
|
+
this.minPercentage = common.getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
214
|
+
this.maxPercentage = common.getNumberFromBN(alignedProxy.maxPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
215
|
+
this.oracleType = Object.keys(alignedProxy.priceOracleType).find((key) => !!key) || "none";
|
|
216
|
+
this.tickSize = alignedProxy.tickSize.toNumber();
|
|
217
|
+
this.priceOracle = this.oracleType === "none" ? void 0 : alignedProxy.priceOracle.toBase58();
|
|
218
|
+
this.sender = alignedProxy.sender.toBase58();
|
|
219
|
+
this.canceledAt = alignedProxy.streamCanceledTime.toNumber();
|
|
220
|
+
this.proxyAddress = stream.sender.toBase58();
|
|
221
|
+
this.initialAmountPerPeriod = alignedProxy.initialAmountPerPeriod;
|
|
222
|
+
this.initialPrice = common.getNumberFromBN(alignedProxy.initialPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
223
|
+
this.lastPrice = common.getNumberFromBN(alignedProxy.lastPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
224
|
+
this.lastAmountUpdateTime = alignedProxy.lastAmountUpdateTime.toNumber();
|
|
225
|
+
this.initialNetAmount = alignedProxy.initialNetAmount;
|
|
226
|
+
this.expiryTime = alignedProxy.expiryTime.toNumber();
|
|
227
|
+
this.expiryPercentage = common.getNumberFromBN(alignedProxy.expiryPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
228
|
+
this.floorPrice = common.getNumberFromBN(alignedProxy.floorPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
229
|
+
this.type = buildStreamType(this);
|
|
230
|
+
this.isAligned = true;
|
|
231
|
+
}
|
|
98
232
|
};
|
|
99
|
-
|
|
100
|
-
// solana/constants.ts
|
|
101
|
-
var constants_exports = {};
|
|
102
|
-
__export(constants_exports, {
|
|
103
|
-
AIRDROP_AMOUNT: () => AIRDROP_AMOUNT,
|
|
104
|
-
AIRDROP_TEST_TOKEN: () => AIRDROP_TEST_TOKEN,
|
|
105
|
-
ALIGNED_COMPUTE_LIMIT: () => ALIGNED_COMPUTE_LIMIT,
|
|
106
|
-
ALIGNED_PRECISION_FACTOR_POW: () => ALIGNED_PRECISION_FACTOR_POW,
|
|
107
|
-
ALIGNED_UNLOCKS_PROGRAM_ID: () => ALIGNED_UNLOCKS_PROGRAM_ID,
|
|
108
|
-
CONTRACT_DISCRIMINATOR: () => CONTRACT_DISCRIMINATOR,
|
|
109
|
-
CONTRACT_SEED: () => CONTRACT_SEED,
|
|
110
|
-
CREATE_PARAMS_PADDING: () => CREATE_PARAMS_PADDING,
|
|
111
|
-
DEFAULT_STREAMFLOW_FEE: () => DEFAULT_STREAMFLOW_FEE,
|
|
112
|
-
ESCROW_SEED: () => ESCROW_SEED,
|
|
113
|
-
FEES_METADATA_SEED: () => FEES_METADATA_SEED,
|
|
114
|
-
FEE_ORACLE_PUBLIC_KEY: () => FEE_ORACLE_PUBLIC_KEY,
|
|
115
|
-
ORIGINAL_CONTRACT_SENDER_OFFSET: () => ORIGINAL_CONTRACT_SENDER_OFFSET,
|
|
116
|
-
PARTNERS_SCHEMA: () => PARTNERS_SCHEMA,
|
|
117
|
-
PARTNER_ORACLE_PROGRAM_ID: () => PARTNER_ORACLE_PROGRAM_ID,
|
|
118
|
-
PARTNER_SCHEMA: () => PARTNER_SCHEMA,
|
|
119
|
-
PROGRAM_ID: () => PROGRAM_ID,
|
|
120
|
-
SOLANA_ERROR_MAP: () => SOLANA_ERROR_MAP,
|
|
121
|
-
SOLANA_ERROR_MATCH_REGEX: () => SOLANA_ERROR_MATCH_REGEX,
|
|
122
|
-
STREAMFLOW_TREASURY_PUBLIC_KEY: () => STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
123
|
-
STREAM_STRUCT_OFFSETS: () => STREAM_STRUCT_OFFSETS,
|
|
124
|
-
STREAM_STRUCT_OFFSET_CLOSED: () => STREAM_STRUCT_OFFSET_CLOSED,
|
|
125
|
-
STREAM_STRUCT_OFFSET_MINT: () => STREAM_STRUCT_OFFSET_MINT,
|
|
126
|
-
STREAM_STRUCT_OFFSET_RECIPIENT: () => STREAM_STRUCT_OFFSET_RECIPIENT,
|
|
127
|
-
STREAM_STRUCT_OFFSET_SENDER: () => STREAM_STRUCT_OFFSET_SENDER,
|
|
128
|
-
TEST_ORACLE_DISCRIMINATOR: () => TEST_ORACLE_DISCRIMINATOR,
|
|
129
|
-
TEST_ORACLE_SEED: () => TEST_ORACLE_SEED,
|
|
130
|
-
TX_FINALITY_CONFIRMED: () => TX_FINALITY_CONFIRMED,
|
|
131
|
-
WITHDRAWOR_PUBLIC_KEY: () => WITHDRAWOR_PUBLIC_KEY
|
|
132
|
-
});
|
|
133
233
|
var TX_FINALITY_CONFIRMED = "confirmed";
|
|
134
234
|
var ORIGINAL_CONTRACT_SENDER_OFFSET = 9;
|
|
135
235
|
var STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
136
236
|
var STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
137
237
|
var STREAM_STRUCT_OFFSET_MINT = 177;
|
|
138
238
|
var STREAM_STRUCT_OFFSET_CLOSED = 671;
|
|
139
|
-
var
|
|
239
|
+
var MAX_SAFE_UNIX_TIME_VALUE2 = 864e10;
|
|
240
|
+
var WITHDRAW_AVAILABLE_AMOUNT = new BN3__default.default("18446744073709551615");
|
|
241
|
+
var ALIGNED_PRECISION_FACTOR_POW2 = 9;
|
|
140
242
|
var STREAM_STRUCT_OFFSETS = {
|
|
141
243
|
mint: STREAM_STRUCT_OFFSET_MINT,
|
|
142
244
|
recipient: STREAM_STRUCT_OFFSET_RECIPIENT,
|
|
@@ -217,88 +319,8 @@ var SOLANA_ERROR_MAP = {
|
|
|
217
319
|
6011: "AmountAlreadyUpdated" /* AmountAlreadyUpdated */,
|
|
218
320
|
6012: "AllFundsUnlocked" /* AllFundsUnlocked */
|
|
219
321
|
};
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
this.magic = stream.magic.toNumber();
|
|
223
|
-
this.version = stream.version.toNumber();
|
|
224
|
-
this.createdAt = stream.createdAt.toNumber();
|
|
225
|
-
this.withdrawnAmount = stream.withdrawnAmount;
|
|
226
|
-
this.canceledAt = stream.canceledAt.toNumber();
|
|
227
|
-
this.end = decodeEndTime(stream.end);
|
|
228
|
-
this.lastWithdrawnAt = stream.lastWithdrawnAt.toNumber();
|
|
229
|
-
this.sender = stream.sender.toBase58();
|
|
230
|
-
this.senderTokens = stream.senderTokens.toBase58();
|
|
231
|
-
this.recipient = stream.recipient.toBase58();
|
|
232
|
-
this.recipientTokens = stream.recipientTokens.toBase58();
|
|
233
|
-
this.mint = stream.mint.toBase58();
|
|
234
|
-
this.escrowTokens = stream.escrowTokens.toBase58();
|
|
235
|
-
this.streamflowTreasury = stream.streamflowTreasury.toBase58();
|
|
236
|
-
this.streamflowTreasuryTokens = stream.streamflowTreasuryTokens.toBase58();
|
|
237
|
-
this.streamflowFeeTotal = stream.streamflowFeeTotal;
|
|
238
|
-
this.streamflowFeeWithdrawn = stream.streamflowFeeWithdrawn;
|
|
239
|
-
this.streamflowFeePercent = stream.streamflowFeePercent;
|
|
240
|
-
this.partnerFeeTotal = stream.partnerFeeTotal;
|
|
241
|
-
this.partnerFeeWithdrawn = stream.partnerFeeWithdrawn;
|
|
242
|
-
this.partnerFeePercent = stream.partnerFeePercent;
|
|
243
|
-
this.partner = stream.partner.toBase58();
|
|
244
|
-
this.partnerTokens = stream.partnerTokens?.toBase58();
|
|
245
|
-
this.start = stream.start.toNumber();
|
|
246
|
-
this.depositedAmount = stream.depositedAmount;
|
|
247
|
-
this.period = stream.period.toNumber();
|
|
248
|
-
this.amountPerPeriod = stream.amountPerPeriod;
|
|
249
|
-
this.cliff = stream.cliff.toNumber();
|
|
250
|
-
this.cliffAmount = stream.cliffAmount;
|
|
251
|
-
this.cancelableBySender = stream.cancelableBySender;
|
|
252
|
-
this.cancelableByRecipient = stream.cancelableByRecipient;
|
|
253
|
-
this.automaticWithdrawal = stream.automaticWithdrawal;
|
|
254
|
-
this.transferableBySender = stream.transferableBySender;
|
|
255
|
-
this.transferableByRecipient = stream.transferableByRecipient;
|
|
256
|
-
this.canTopup = stream.canTopup;
|
|
257
|
-
this.name = stream.name;
|
|
258
|
-
this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
|
|
259
|
-
this.closed = stream.closed;
|
|
260
|
-
this.currentPauseStart = stream.currentPauseStart.toNumber();
|
|
261
|
-
this.pauseCumulative = stream.pauseCumulative;
|
|
262
|
-
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
263
|
-
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
264
|
-
this.type = buildStreamType(this);
|
|
265
|
-
this.isAligned = false;
|
|
266
|
-
}
|
|
267
|
-
unlocked(currentTimestamp) {
|
|
268
|
-
return calculateUnlockedAmount({
|
|
269
|
-
...this,
|
|
270
|
-
currentTimestamp
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
remaining(decimals) {
|
|
274
|
-
return getNumberFromBN(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
var AlignedContract = class extends Contract {
|
|
278
|
-
constructor(stream, alignedProxy) {
|
|
279
|
-
super(stream);
|
|
280
|
-
this.minPrice = getNumberFromBN(alignedProxy.minPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
281
|
-
this.maxPrice = getNumberFromBN(alignedProxy.maxPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
282
|
-
this.minPercentage = getNumberFromBN(alignedProxy.minPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
283
|
-
this.maxPercentage = getNumberFromBN(alignedProxy.maxPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
284
|
-
this.oracleType = Object.keys(alignedProxy.priceOracleType).find((key) => !!key) || "none";
|
|
285
|
-
this.tickSize = alignedProxy.tickSize.toNumber();
|
|
286
|
-
this.priceOracle = this.oracleType === "none" ? void 0 : alignedProxy.priceOracle.toBase58();
|
|
287
|
-
this.sender = alignedProxy.sender.toBase58();
|
|
288
|
-
this.canceledAt = alignedProxy.streamCanceledTime.toNumber();
|
|
289
|
-
this.proxyAddress = stream.sender.toBase58();
|
|
290
|
-
this.initialAmountPerPeriod = alignedProxy.initialAmountPerPeriod;
|
|
291
|
-
this.initialPrice = getNumberFromBN(alignedProxy.initialPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
292
|
-
this.lastPrice = getNumberFromBN(alignedProxy.lastPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
293
|
-
this.lastAmountUpdateTime = alignedProxy.lastAmountUpdateTime.toNumber();
|
|
294
|
-
this.initialNetAmount = alignedProxy.initialNetAmount;
|
|
295
|
-
this.expiryTime = alignedProxy.expiryTime.toNumber();
|
|
296
|
-
this.expiryPercentage = getNumberFromBN(alignedProxy.expiryPercentage, ALIGNED_PRECISION_FACTOR_POW);
|
|
297
|
-
this.floorPrice = getNumberFromBN(alignedProxy.floorPrice, ALIGNED_PRECISION_FACTOR_POW);
|
|
298
|
-
this.type = buildStreamType(this);
|
|
299
|
-
this.isAligned = true;
|
|
300
|
-
}
|
|
301
|
-
};
|
|
322
|
+
|
|
323
|
+
// solana/layout.ts
|
|
302
324
|
var streamLayout = BufferLayout__namespace.struct([
|
|
303
325
|
BufferLayout__namespace.blob(8, "magic"),
|
|
304
326
|
BufferLayout__namespace.blob(1, "version"),
|
|
@@ -458,20 +480,25 @@ var encodeUpdateStream = (values, data) => {
|
|
|
458
480
|
var topupStreamLayout = BufferLayout__namespace.struct([
|
|
459
481
|
BufferLayout__namespace.blob(8, "amount")
|
|
460
482
|
]);
|
|
461
|
-
|
|
462
|
-
|
|
483
|
+
var FEE_PRECISION = 4;
|
|
484
|
+
var FEE_NORMALIZER = 10 ** FEE_PRECISION;
|
|
485
|
+
var FEE_MULTIPLIER = new BN3__default.default(10 ** 6);
|
|
463
486
|
var decoder = new TextDecoder("utf-8");
|
|
464
487
|
var LE = "le";
|
|
488
|
+
var calculateTotalAmountToDeposit = (depositedAmount, totalFee) => {
|
|
489
|
+
const totalFeeNormalized = new BN3__default.default(totalFee * FEE_NORMALIZER);
|
|
490
|
+
return depositedAmount.mul(totalFeeNormalized.add(FEE_MULTIPLIER)).div(FEE_MULTIPLIER);
|
|
491
|
+
};
|
|
465
492
|
var decodeStream = (buf) => {
|
|
466
493
|
const raw = streamLayout.decode(buf);
|
|
467
494
|
return {
|
|
468
|
-
magic: new
|
|
469
|
-
version: new
|
|
470
|
-
createdAt: new
|
|
471
|
-
withdrawnAmount: new
|
|
472
|
-
canceledAt: new
|
|
473
|
-
end: new
|
|
474
|
-
lastWithdrawnAt: new
|
|
495
|
+
magic: new BN3__default.default(raw.magic, LE),
|
|
496
|
+
version: new BN3__default.default(raw.version, LE),
|
|
497
|
+
createdAt: new BN3__default.default(raw.created_at, LE),
|
|
498
|
+
withdrawnAmount: new BN3__default.default(raw.withdrawn_amount, LE),
|
|
499
|
+
canceledAt: new BN3__default.default(raw.canceled_at, LE),
|
|
500
|
+
end: new BN3__default.default(raw.end_time, LE),
|
|
501
|
+
lastWithdrawnAt: new BN3__default.default(raw.last_withdrawn_at, LE),
|
|
475
502
|
sender: new web3_js.PublicKey(raw.sender),
|
|
476
503
|
senderTokens: new web3_js.PublicKey(raw.sender_tokens),
|
|
477
504
|
recipient: new web3_js.PublicKey(raw.recipient),
|
|
@@ -480,20 +507,20 @@ var decodeStream = (buf) => {
|
|
|
480
507
|
escrowTokens: new web3_js.PublicKey(raw.escrow_tokens),
|
|
481
508
|
streamflowTreasury: new web3_js.PublicKey(raw.streamflow_treasury),
|
|
482
509
|
streamflowTreasuryTokens: new web3_js.PublicKey(raw.streamflow_treasury_tokens),
|
|
483
|
-
streamflowFeeTotal: new
|
|
484
|
-
streamflowFeeWithdrawn: new
|
|
510
|
+
streamflowFeeTotal: new BN3__default.default(raw.streamflow_fee_total, LE),
|
|
511
|
+
streamflowFeeWithdrawn: new BN3__default.default(raw.streamflow_fee_withdrawn, LE),
|
|
485
512
|
streamflowFeePercent: raw.streamflow_fee_percent,
|
|
486
|
-
partnerFeeTotal: new
|
|
487
|
-
partnerFeeWithdrawn: new
|
|
513
|
+
partnerFeeTotal: new BN3__default.default(raw.partner_fee_total, LE),
|
|
514
|
+
partnerFeeWithdrawn: new BN3__default.default(raw.partner_fee_withdrawn, LE),
|
|
488
515
|
partnerFeePercent: raw.partner_fee_percent,
|
|
489
516
|
partner: new web3_js.PublicKey(raw.partner),
|
|
490
517
|
partnerTokens: new web3_js.PublicKey(raw.partner_tokens),
|
|
491
|
-
start: new
|
|
492
|
-
depositedAmount: new
|
|
493
|
-
period: new
|
|
494
|
-
amountPerPeriod: new
|
|
495
|
-
cliff: new
|
|
496
|
-
cliffAmount: new
|
|
518
|
+
start: new BN3__default.default(raw.start_time, LE),
|
|
519
|
+
depositedAmount: new BN3__default.default(raw.net_amount_deposited, LE),
|
|
520
|
+
period: new BN3__default.default(raw.period, LE),
|
|
521
|
+
amountPerPeriod: new BN3__default.default(raw.amount_per_period, LE),
|
|
522
|
+
cliff: new BN3__default.default(raw.cliff, LE),
|
|
523
|
+
cliffAmount: new BN3__default.default(raw.cliff_amount, LE),
|
|
497
524
|
cancelableBySender: Boolean(raw.cancelable_by_sender),
|
|
498
525
|
cancelableByRecipient: Boolean(raw.cancelable_by_recipient),
|
|
499
526
|
automaticWithdrawal: Boolean(raw.automatic_withdrawal),
|
|
@@ -501,17 +528,17 @@ var decodeStream = (buf) => {
|
|
|
501
528
|
transferableByRecipient: Boolean(raw.transferable_by_recipient),
|
|
502
529
|
canTopup: Boolean(raw.can_topup),
|
|
503
530
|
name: decoder.decode(raw.stream_name),
|
|
504
|
-
withdrawFrequency: new
|
|
531
|
+
withdrawFrequency: new BN3__default.default(raw.withdraw_frequency, LE),
|
|
505
532
|
closed: Boolean(raw.closed),
|
|
506
|
-
currentPauseStart: new
|
|
507
|
-
pauseCumulative: new
|
|
508
|
-
lastRateChangeTime: new
|
|
509
|
-
fundsUnlockedAtLastRateChange: new
|
|
533
|
+
currentPauseStart: new BN3__default.default(raw.current_pause_start, LE),
|
|
534
|
+
pauseCumulative: new BN3__default.default(raw.pause_cumulative, LE),
|
|
535
|
+
lastRateChangeTime: new BN3__default.default(raw.last_rate_change_time, LE),
|
|
536
|
+
fundsUnlockedAtLastRateChange: new BN3__default.default(raw.funds_unlocked_at_last_rate_change, LE)
|
|
510
537
|
};
|
|
511
538
|
};
|
|
512
539
|
async function signAllTransactionWithRecipients(sender, items) {
|
|
513
|
-
const isKeypair =
|
|
514
|
-
const isWallet =
|
|
540
|
+
const isKeypair = common.isSignerKeypair(sender);
|
|
541
|
+
const isWallet = common.isSignerWallet(sender);
|
|
515
542
|
if (isKeypair) {
|
|
516
543
|
return items.map((t) => {
|
|
517
544
|
t.tx.sign([sender]);
|
|
@@ -529,7 +556,7 @@ async function signAllTransactionWithRecipients(sender, items) {
|
|
|
529
556
|
}
|
|
530
557
|
async function sendAndConfirmStreamRawTransaction(connection, batchItem, confirmationParams, throttleParams) {
|
|
531
558
|
try {
|
|
532
|
-
const completedTxSignature = await
|
|
559
|
+
const completedTxSignature = await common.executeTransaction(connection, batchItem.tx, confirmationParams, throttleParams);
|
|
533
560
|
return { ...batchItem, signature: completedTxSignature };
|
|
534
561
|
} catch (error) {
|
|
535
562
|
throw {
|
|
@@ -538,6 +565,19 @@ async function sendAndConfirmStreamRawTransaction(connection, batchItem, confirm
|
|
|
538
565
|
};
|
|
539
566
|
}
|
|
540
567
|
}
|
|
568
|
+
async function handleContractError(func, callback) {
|
|
569
|
+
try {
|
|
570
|
+
return await func();
|
|
571
|
+
} catch (err) {
|
|
572
|
+
if (err instanceof Error) {
|
|
573
|
+
if (callback) {
|
|
574
|
+
throw new common.ContractError(err, callback(err));
|
|
575
|
+
}
|
|
576
|
+
throw new common.ContractError(err);
|
|
577
|
+
}
|
|
578
|
+
throw err;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
541
581
|
function extractSolanaErrorCode(errorText, logs) {
|
|
542
582
|
let match = SOLANA_ERROR_MATCH_REGEX.exec(errorText);
|
|
543
583
|
if (!match && logs) {
|
|
@@ -867,28 +907,6 @@ var topupStreamInstruction = async (amount, programId, {
|
|
|
867
907
|
});
|
|
868
908
|
};
|
|
869
909
|
|
|
870
|
-
// common/BaseStreamClient.ts
|
|
871
|
-
var BaseStreamClient = class {
|
|
872
|
-
/**
|
|
873
|
-
* Returns total fee percent, streamflow fees + partner fees
|
|
874
|
-
* @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
|
|
875
|
-
* @param chainSpecificParams additional parameters required by chain client
|
|
876
|
-
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
877
|
-
*/
|
|
878
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
879
|
-
async getTotalFee(getFeesData, chainSpecificParams) {
|
|
880
|
-
const fees = await this.getFees(getFeesData, chainSpecificParams);
|
|
881
|
-
if (fees) {
|
|
882
|
-
return fees.partnerFee + fees.streamflowFee;
|
|
883
|
-
}
|
|
884
|
-
return this.getDefaultStreamflowFee(chainSpecificParams);
|
|
885
|
-
}
|
|
886
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
887
|
-
extractErrorCode(err) {
|
|
888
|
-
return null;
|
|
889
|
-
}
|
|
890
|
-
};
|
|
891
|
-
|
|
892
910
|
// solana/descriptor/idl/streamflow_aligned_unlocks.json
|
|
893
911
|
var streamflow_aligned_unlocks_default = {
|
|
894
912
|
address: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
|
|
@@ -2402,18 +2420,17 @@ var deriveTestOraclePDA = (programId, mint, creator) => {
|
|
|
2402
2420
|
// solana/StreamClient.ts
|
|
2403
2421
|
var METADATA_ACC_SIZE = 1104;
|
|
2404
2422
|
var ALIGNED_METADATA_ACC_SIZE = 320;
|
|
2405
|
-
var SolanaStreamClient = class
|
|
2423
|
+
var SolanaStreamClient = class {
|
|
2406
2424
|
/**
|
|
2407
2425
|
* Create Stream instance
|
|
2408
2426
|
*/
|
|
2409
2427
|
constructor(optionsOrClusterUrl, cluster = common.ICluster.Mainnet, commitment = "confirmed", programId = "", sendRate = 1, sendThrottler) {
|
|
2410
|
-
super();
|
|
2411
2428
|
if (typeof optionsOrClusterUrl === "string") {
|
|
2412
2429
|
this.commitment = commitment;
|
|
2413
2430
|
this.connection = new web3_js.Connection(optionsOrClusterUrl, this.commitment);
|
|
2414
2431
|
this.programId = programId !== "" ? new web3_js.PublicKey(programId) : new web3_js.PublicKey(PROGRAM_ID[cluster]);
|
|
2415
2432
|
this.schedulingParams = {
|
|
2416
|
-
sendThrottler: sendThrottler ??
|
|
2433
|
+
sendThrottler: sendThrottler ?? common.buildSendThrottler(sendRate)
|
|
2417
2434
|
};
|
|
2418
2435
|
} else {
|
|
2419
2436
|
const {
|
|
@@ -2427,7 +2444,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2427
2444
|
this.connection = new web3_js.Connection(clusterUrl, this.commitment);
|
|
2428
2445
|
this.programId = programId2 !== "" ? new web3_js.PublicKey(programId2) : new web3_js.PublicKey(PROGRAM_ID[cluster2]);
|
|
2429
2446
|
const schedulingOptions = sendScheduler && "sendRate" in sendScheduler ? sendScheduler : void 0;
|
|
2430
|
-
const sendThrottler2 = !sendScheduler ?
|
|
2447
|
+
const sendThrottler2 = !sendScheduler ? common.buildSendThrottler(1) : "sendRate" in sendScheduler ? common.buildSendThrottler(sendScheduler.sendRate ?? 1, sendScheduler.sendInterval) : sendScheduler;
|
|
2431
2448
|
this.schedulingParams = {
|
|
2432
2449
|
...schedulingOptions,
|
|
2433
2450
|
sendThrottler: sendThrottler2
|
|
@@ -2448,6 +2465,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2448
2465
|
getProgramId() {
|
|
2449
2466
|
return this.programId.toBase58();
|
|
2450
2467
|
}
|
|
2468
|
+
getAlignedProxyProgramId() {
|
|
2469
|
+
return this.alignedProxyProgram.programId.toBase58();
|
|
2470
|
+
}
|
|
2451
2471
|
/**
|
|
2452
2472
|
* Builds transaction instructions for creating a new stream/vesting contract without creating a transaction.
|
|
2453
2473
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
@@ -2456,7 +2476,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2456
2476
|
* (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
|
|
2457
2477
|
*
|
|
2458
2478
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
2459
|
-
* @param {Omit<
|
|
2479
|
+
* @param {Omit<ICreateStreamExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2460
2480
|
* @returns Transaction instructions and metadata ID
|
|
2461
2481
|
*/
|
|
2462
2482
|
async buildCreateTransactionInstructions(data, extParams) {
|
|
@@ -2477,7 +2497,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2477
2497
|
address: partnerPublicKey.toString()
|
|
2478
2498
|
});
|
|
2479
2499
|
const totalAmount = calculateTotalAmountToDeposit(amount, totalFee);
|
|
2480
|
-
ixs.push(...await
|
|
2500
|
+
ixs.push(...await common.prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
|
|
2481
2501
|
}
|
|
2482
2502
|
const {
|
|
2483
2503
|
ixs: createIxs,
|
|
@@ -2503,13 +2523,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2503
2523
|
* (before stream creation) to ensure the WSOL account exists when the stream creation instruction executes.
|
|
2504
2524
|
*
|
|
2505
2525
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
2506
|
-
* @param {Omit<
|
|
2526
|
+
* @param {Omit<ICreateStreamExt, "sender"> & { senderPublicKey: PublicKey }} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2507
2527
|
* @returns Transaction and metadata information
|
|
2508
2528
|
*/
|
|
2509
2529
|
async buildCreateTransaction(data, extParams) {
|
|
2510
2530
|
const { sender } = extParams;
|
|
2511
2531
|
const { ixs, metadataId, metadata } = await this.buildCreateTransactionInstructions(data, extParams);
|
|
2512
|
-
const { tx, hash, context } = await
|
|
2532
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
|
|
2513
2533
|
metadata
|
|
2514
2534
|
]);
|
|
2515
2535
|
return {
|
|
@@ -2524,7 +2544,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2524
2544
|
* Creates a new stream/vesting contract.
|
|
2525
2545
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
2526
2546
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
2527
|
-
* @param {
|
|
2547
|
+
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, native token handling, and compute settings
|
|
2528
2548
|
* @returns Create result
|
|
2529
2549
|
*/
|
|
2530
2550
|
async create(data, extParams) {
|
|
@@ -2534,10 +2554,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2534
2554
|
...extParams,
|
|
2535
2555
|
sender
|
|
2536
2556
|
});
|
|
2537
|
-
const { tx, hash, context } = await
|
|
2557
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, sender.publicKey, void 0, [
|
|
2538
2558
|
metadata
|
|
2539
2559
|
]);
|
|
2540
|
-
const signature = await
|
|
2560
|
+
const signature = await common.signAndExecuteTransaction(
|
|
2541
2561
|
this.connection,
|
|
2542
2562
|
sender,
|
|
2543
2563
|
tx,
|
|
@@ -2594,13 +2614,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2594
2614
|
common.invariant(metadataPubKey, "Metadata public key is required");
|
|
2595
2615
|
let tokenProgramId = streamTokenProgramId ? new web3_js.PublicKey(streamTokenProgramId) : void 0;
|
|
2596
2616
|
if (!tokenProgramId) {
|
|
2597
|
-
tokenProgramId = (await
|
|
2617
|
+
tokenProgramId = (await common.getMintAndProgram(this.connection, mintPublicKey)).tokenProgramId;
|
|
2598
2618
|
}
|
|
2599
2619
|
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
2600
2620
|
const streamflowProgramPublicKey = new web3_js.PublicKey(this.programId);
|
|
2601
2621
|
const escrowPDA = deriveEscrowPDA(streamflowProgramPublicKey, metadataPubKey);
|
|
2602
2622
|
const oracle = priceOracle ?? deriveTestOraclePDA(this.alignedProxyProgram.programId, mintPublicKey, sender.publicKey);
|
|
2603
|
-
const ixs =
|
|
2623
|
+
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
2604
2624
|
computePrice,
|
|
2605
2625
|
computeLimit: computeLimit ?? ALIGNED_COMPUTE_LIMIT
|
|
2606
2626
|
});
|
|
@@ -2612,11 +2632,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2612
2632
|
const encodedUIntArray = new TextEncoder().encode(streamName);
|
|
2613
2633
|
const streamNameArray = Array.from(encodedUIntArray);
|
|
2614
2634
|
const createIx = await this.alignedProxyProgram.methods.create({
|
|
2615
|
-
startTime: new
|
|
2635
|
+
startTime: new BN3__default.default(start),
|
|
2616
2636
|
netAmountDeposited: depositedAmount,
|
|
2617
|
-
period: new
|
|
2637
|
+
period: new BN3__default.default(period),
|
|
2618
2638
|
amountPerPeriod,
|
|
2619
|
-
cliff: new
|
|
2639
|
+
cliff: new BN3__default.default(cliff),
|
|
2620
2640
|
cliffAmount,
|
|
2621
2641
|
transferableBySender,
|
|
2622
2642
|
transferableByRecipient,
|
|
@@ -2625,15 +2645,15 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2625
2645
|
canTopup,
|
|
2626
2646
|
oracleType: !!oracleType ? { [oracleType]: {} } : { none: {} },
|
|
2627
2647
|
streamName: streamNameArray,
|
|
2628
|
-
minPrice: typeof minPrice === "number" ? common.getBN(minPrice,
|
|
2629
|
-
maxPrice: typeof maxPrice === "number" ? common.getBN(maxPrice,
|
|
2630
|
-
minPercentage: typeof minPercentage === "number" ? common.getBN(minPercentage,
|
|
2631
|
-
maxPercentage: typeof maxPercentage === "number" ? common.getBN(maxPercentage,
|
|
2632
|
-
tickSize: new
|
|
2648
|
+
minPrice: typeof minPrice === "number" ? common.getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW2) : minPrice,
|
|
2649
|
+
maxPrice: typeof maxPrice === "number" ? common.getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW2) : maxPrice,
|
|
2650
|
+
minPercentage: typeof minPercentage === "number" ? common.getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW2) : minPercentage,
|
|
2651
|
+
maxPercentage: typeof maxPercentage === "number" ? common.getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW2) : maxPercentage,
|
|
2652
|
+
tickSize: new BN3__default.default(tickSize || 1),
|
|
2633
2653
|
skipInitial: skipInitial ?? false,
|
|
2634
|
-
expiryTime: new
|
|
2635
|
-
expiryPercentage: typeof expiryPercentage === "number" ? common.getBN(expiryPercentage,
|
|
2636
|
-
floorPrice: typeof floorPrice === "number" ? common.getBN(floorPrice,
|
|
2654
|
+
expiryTime: new BN3__default.default(expiryTime ?? 0),
|
|
2655
|
+
expiryPercentage: typeof expiryPercentage === "number" ? common.getBN(expiryPercentage, ALIGNED_PRECISION_FACTOR_POW2) : expiryPercentage ?? new BN3__default.default(0),
|
|
2656
|
+
floorPrice: typeof floorPrice === "number" ? common.getBN(floorPrice, ALIGNED_PRECISION_FACTOR_POW2) : floorPrice ?? new BN3__default.default(0)
|
|
2637
2657
|
}).accountsPartial({
|
|
2638
2658
|
payer: sender.publicKey,
|
|
2639
2659
|
sender: sender.publicKey,
|
|
@@ -2655,7 +2675,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2655
2675
|
* Creates a new stream/vesting contract.
|
|
2656
2676
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
2657
2677
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
2658
|
-
* @param {
|
|
2678
|
+
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
2659
2679
|
* @returns Create stream instructions
|
|
2660
2680
|
*/
|
|
2661
2681
|
async prepareCreateStreamInstructions({
|
|
@@ -2681,7 +2701,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2681
2701
|
tokenProgramId: streamTokenProgramId
|
|
2682
2702
|
}, { sender, metadataPubKeys, isNative = false, computePrice, computeLimit }) {
|
|
2683
2703
|
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2684
|
-
const ixs =
|
|
2704
|
+
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
2685
2705
|
computePrice,
|
|
2686
2706
|
computeLimit
|
|
2687
2707
|
});
|
|
@@ -2694,22 +2714,22 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2694
2714
|
);
|
|
2695
2715
|
let tokenProgramId = streamTokenProgramId ? new web3_js.PublicKey(streamTokenProgramId) : void 0;
|
|
2696
2716
|
if (!tokenProgramId) {
|
|
2697
|
-
tokenProgramId = (await
|
|
2717
|
+
tokenProgramId = (await common.getMintAndProgram(this.connection, mintPublicKey)).tokenProgramId;
|
|
2698
2718
|
}
|
|
2699
|
-
const senderTokens = await
|
|
2700
|
-
const recipientTokens = await
|
|
2701
|
-
const streamflowTreasuryTokens = await
|
|
2719
|
+
const senderTokens = await common.ata(mintPublicKey, sender.publicKey, tokenProgramId);
|
|
2720
|
+
const recipientTokens = await common.ata(mintPublicKey, recipientPublicKey, tokenProgramId);
|
|
2721
|
+
const streamflowTreasuryTokens = await common.ata(mintPublicKey, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
2702
2722
|
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
2703
|
-
const partnerTokens = await
|
|
2723
|
+
const partnerTokens = await common.ata(mintPublicKey, partnerPublicKey, tokenProgramId);
|
|
2704
2724
|
ixs.push(
|
|
2705
2725
|
await createStreamInstruction(
|
|
2706
2726
|
{
|
|
2707
|
-
start: new
|
|
2727
|
+
start: new BN3__default.default(start),
|
|
2708
2728
|
depositedAmount,
|
|
2709
|
-
period: new
|
|
2729
|
+
period: new BN3__default.default(period),
|
|
2710
2730
|
amountPerPeriod,
|
|
2711
|
-
cliff: new
|
|
2712
|
-
cliffAmount: new
|
|
2731
|
+
cliff: new BN3__default.default(cliff),
|
|
2732
|
+
cliffAmount: new BN3__default.default(cliffAmount),
|
|
2713
2733
|
cancelableBySender,
|
|
2714
2734
|
cancelableByRecipient,
|
|
2715
2735
|
automaticWithdrawal,
|
|
@@ -2719,7 +2739,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2719
2739
|
canUpdateRate: !!canUpdateRate,
|
|
2720
2740
|
canPause: !!canPause,
|
|
2721
2741
|
name,
|
|
2722
|
-
withdrawFrequency: new
|
|
2742
|
+
withdrawFrequency: new BN3__default.default(automaticWithdrawal ? withdrawalFrequency : period)
|
|
2723
2743
|
},
|
|
2724
2744
|
this.programId,
|
|
2725
2745
|
{
|
|
@@ -2756,7 +2776,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2756
2776
|
*
|
|
2757
2777
|
* If you are not sure if you should use create or create_unchecked, go for create to be safer.
|
|
2758
2778
|
* @param {ICreateStreamData} data - Stream parameters including recipient, token, amount, schedule, and permissions
|
|
2759
|
-
* @param {
|
|
2779
|
+
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
2760
2780
|
* @returns Create result
|
|
2761
2781
|
*/
|
|
2762
2782
|
async createUnchecked(data, extParams) {
|
|
@@ -2764,14 +2784,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2764
2784
|
data,
|
|
2765
2785
|
extParams
|
|
2766
2786
|
);
|
|
2767
|
-
const { tx, hash, context } = await
|
|
2787
|
+
const { tx, hash, context } = await common.prepareTransaction(
|
|
2768
2788
|
this.connection,
|
|
2769
2789
|
ixs,
|
|
2770
2790
|
extParams.sender.publicKey,
|
|
2771
2791
|
void 0,
|
|
2772
2792
|
[metadata]
|
|
2773
2793
|
);
|
|
2774
|
-
const signature = await
|
|
2794
|
+
const signature = await common.signAndExecuteTransaction(
|
|
2775
2795
|
this.connection,
|
|
2776
2796
|
extParams.sender,
|
|
2777
2797
|
tx,
|
|
@@ -2824,26 +2844,26 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2824
2844
|
[buffer.Buffer.from("strm"), metadataPubKey.toBuffer()],
|
|
2825
2845
|
this.programId
|
|
2826
2846
|
);
|
|
2827
|
-
const { tokenProgramId } = await
|
|
2828
|
-
const senderTokens = await
|
|
2847
|
+
const { tokenProgramId } = await common.getMintAndProgram(this.connection, mintPublicKey);
|
|
2848
|
+
const senderTokens = await common.ata(mintPublicKey, sender.publicKey, tokenProgramId);
|
|
2829
2849
|
const partnerPublicKey = partner ? new web3_js.PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
2830
|
-
const ixs =
|
|
2850
|
+
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
2831
2851
|
computePrice,
|
|
2832
2852
|
computeLimit
|
|
2833
2853
|
});
|
|
2834
2854
|
if (isNative) {
|
|
2835
2855
|
const totalFee = await this.getTotalFee({ address: partnerPublicKey.toString() });
|
|
2836
2856
|
const totalAmount = calculateTotalAmountToDeposit(depositedAmount, totalFee);
|
|
2837
|
-
ixs.push(...await
|
|
2857
|
+
ixs.push(...await common.prepareWrappedAccount(this.connection, sender.publicKey, totalAmount));
|
|
2838
2858
|
}
|
|
2839
2859
|
const createInstruction = await createUncheckedStreamInstruction(
|
|
2840
2860
|
{
|
|
2841
|
-
start: new
|
|
2861
|
+
start: new BN3__default.default(start),
|
|
2842
2862
|
depositedAmount,
|
|
2843
|
-
period: new
|
|
2863
|
+
period: new BN3__default.default(period),
|
|
2844
2864
|
amountPerPeriod,
|
|
2845
|
-
cliff: new
|
|
2846
|
-
cliffAmount: new
|
|
2865
|
+
cliff: new BN3__default.default(cliff),
|
|
2866
|
+
cliffAmount: new BN3__default.default(cliffAmount),
|
|
2847
2867
|
cancelableBySender,
|
|
2848
2868
|
cancelableByRecipient,
|
|
2849
2869
|
automaticWithdrawal,
|
|
@@ -2853,7 +2873,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2853
2873
|
canUpdateRate: !!canUpdateRate,
|
|
2854
2874
|
canPause: !!canPause,
|
|
2855
2875
|
name,
|
|
2856
|
-
withdrawFrequency: new
|
|
2876
|
+
withdrawFrequency: new BN3__default.default(automaticWithdrawal ? withdrawalFrequency : period),
|
|
2857
2877
|
recipient: recipientPublicKey,
|
|
2858
2878
|
partner: partnerPublicKey
|
|
2859
2879
|
},
|
|
@@ -2879,7 +2899,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2879
2899
|
* Builds transaction instructions for creating multiple stream/vesting contracts without creating transactions.
|
|
2880
2900
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
2881
2901
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
2882
|
-
* @param {
|
|
2902
|
+
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2883
2903
|
* @returns Create multiple transaction instructions
|
|
2884
2904
|
*/
|
|
2885
2905
|
async buildCreateMultipleTransactionInstructions(data, extParams) {
|
|
@@ -2922,8 +2942,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2922
2942
|
true
|
|
2923
2943
|
);
|
|
2924
2944
|
if (isNative) {
|
|
2925
|
-
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new
|
|
2926
|
-
const nativeInstructions = await
|
|
2945
|
+
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN3__default.default(0));
|
|
2946
|
+
const nativeInstructions = await common.prepareWrappedAccount(
|
|
2927
2947
|
this.connection,
|
|
2928
2948
|
sender.publicKey,
|
|
2929
2949
|
totalDepositedAmount
|
|
@@ -2960,7 +2980,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2960
2980
|
* ```
|
|
2961
2981
|
*
|
|
2962
2982
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
2963
|
-
* @param {
|
|
2983
|
+
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender public key, native token handling, and custom instructions
|
|
2964
2984
|
* @returns Multiple transaction information
|
|
2965
2985
|
*/
|
|
2966
2986
|
async buildCreateMultipleTransactions(data, extParams) {
|
|
@@ -2969,11 +2989,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2969
2989
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
2970
2990
|
const batch = [];
|
|
2971
2991
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
2972
|
-
batch.push({ tx:
|
|
2992
|
+
batch.push({ tx: common.createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
|
|
2973
2993
|
}
|
|
2974
2994
|
let prepareTx;
|
|
2975
2995
|
if (prepareInstructions.length > 0) {
|
|
2976
|
-
prepareTx =
|
|
2996
|
+
prepareTx = common.createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash);
|
|
2977
2997
|
}
|
|
2978
2998
|
return {
|
|
2979
2999
|
transactions: batch,
|
|
@@ -2988,7 +3008,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
2988
3008
|
* Creates multiple stream/vesting contracts.
|
|
2989
3009
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
2990
3010
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
2991
|
-
* @param {
|
|
3011
|
+
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
2992
3012
|
* @returns Multiple transaction information
|
|
2993
3013
|
*/
|
|
2994
3014
|
async createMultiple(data, extParams) {
|
|
@@ -3003,11 +3023,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3003
3023
|
const batch = [];
|
|
3004
3024
|
const { value: hash, context } = await this.connection.getLatestBlockhashAndContext();
|
|
3005
3025
|
for (const { ixs, metadata, recipient } of instructionsBatch) {
|
|
3006
|
-
batch.push({ tx:
|
|
3026
|
+
batch.push({ tx: common.createVersionedTransaction(ixs, sender.publicKey, hash.blockhash, [metadata]), recipient });
|
|
3007
3027
|
}
|
|
3008
3028
|
if (prepareInstructions.length > 0) {
|
|
3009
3029
|
batch.push({
|
|
3010
|
-
tx:
|
|
3030
|
+
tx: common.createVersionedTransaction(prepareInstructions, sender.publicKey, hash.blockhash),
|
|
3011
3031
|
recipient: sender.publicKey.toBase58()
|
|
3012
3032
|
});
|
|
3013
3033
|
}
|
|
@@ -3021,13 +3041,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3021
3041
|
for (const batchTx of signedBatch) {
|
|
3022
3042
|
responses.push(
|
|
3023
3043
|
...await Promise.allSettled([
|
|
3024
|
-
|
|
3044
|
+
common.executeTransaction(this.connection, batchTx.tx, { hash, context }, this.schedulingParams)
|
|
3025
3045
|
])
|
|
3026
3046
|
);
|
|
3027
3047
|
}
|
|
3028
3048
|
} else {
|
|
3029
3049
|
responses.push(
|
|
3030
|
-
...await
|
|
3050
|
+
...await common.executeMultipleTransactions(
|
|
3031
3051
|
this.connection,
|
|
3032
3052
|
signedBatch.map((item) => item.tx),
|
|
3033
3053
|
{ hash, context },
|
|
@@ -3053,7 +3073,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3053
3073
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
3054
3074
|
* In most cases, createMultiple should be used instead.
|
|
3055
3075
|
* @param {ICreateMultipleStreamData} data - Stream base parameters and array of recipients with individual amounts and settings
|
|
3056
|
-
* @param {
|
|
3076
|
+
* @param {ICreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
3057
3077
|
* @returns Multiple transaction information
|
|
3058
3078
|
*/
|
|
3059
3079
|
async createMultipleSequential(data, extParams) {
|
|
@@ -3099,7 +3119,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3099
3119
|
for (const batchTx of signedBatch) {
|
|
3100
3120
|
responses.push(
|
|
3101
3121
|
...await Promise.allSettled([
|
|
3102
|
-
|
|
3122
|
+
common.executeTransaction(this.connection, batchTx.tx, { hash, context }, this.schedulingParams)
|
|
3103
3123
|
])
|
|
3104
3124
|
);
|
|
3105
3125
|
}
|
|
@@ -3119,7 +3139,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3119
3139
|
/**
|
|
3120
3140
|
* Attempts withdrawing from the specified stream.
|
|
3121
3141
|
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
3122
|
-
* @param {
|
|
3142
|
+
* @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
3123
3143
|
* @returns Transaction result
|
|
3124
3144
|
*/
|
|
3125
3145
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
@@ -3131,8 +3151,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3131
3151
|
);
|
|
3132
3152
|
const metadata = new web3_js.PublicKey(id);
|
|
3133
3153
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
|
|
3134
|
-
const { tx, hash, context } = await
|
|
3135
|
-
const signature = await
|
|
3154
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker.publicKey);
|
|
3155
|
+
const signature = await common.signAndExecuteTransaction(
|
|
3136
3156
|
this.connection,
|
|
3137
3157
|
extParams.invoker,
|
|
3138
3158
|
tx,
|
|
@@ -3148,12 +3168,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3148
3168
|
/**
|
|
3149
3169
|
* Creates Transaction Instructions for withdrawal
|
|
3150
3170
|
* @param {IWithdrawData} withdrawData - Withdrawal parameters including stream ID and amount to withdraw
|
|
3151
|
-
* @param {
|
|
3171
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
|
|
3152
3172
|
* @returns Transaction instructions
|
|
3153
3173
|
*/
|
|
3154
3174
|
async prepareWithdrawInstructions({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
3155
3175
|
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3156
|
-
const ixs =
|
|
3176
|
+
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
3157
3177
|
computePrice,
|
|
3158
3178
|
computeLimit
|
|
3159
3179
|
});
|
|
@@ -3162,9 +3182,9 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3162
3182
|
common.invariant(escrow?.data, "Couldn't get account info");
|
|
3163
3183
|
const data = decodeStream(escrow.data);
|
|
3164
3184
|
const { sender, recipient, mint, streamflowTreasury, partner, recipientTokens, escrowTokens } = data;
|
|
3165
|
-
const { tokenProgramId } = await
|
|
3166
|
-
const streamflowTreasuryTokens = await
|
|
3167
|
-
const partnerTokens = await
|
|
3185
|
+
const { tokenProgramId } = await common.getMintAndProgram(this.connection, mint);
|
|
3186
|
+
const streamflowTreasuryTokens = await common.ata(mint, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
3187
|
+
const partnerTokens = await common.ata(mint, partner, tokenProgramId);
|
|
3168
3188
|
const ataIx = await this.getCreateATAInstructions(
|
|
3169
3189
|
[sender, recipient, streamflowTreasury, partner],
|
|
3170
3190
|
mint,
|
|
@@ -3193,13 +3213,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3193
3213
|
/**
|
|
3194
3214
|
* Attempts canceling the specified stream.
|
|
3195
3215
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
3196
|
-
* @param {
|
|
3216
|
+
* @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
3197
3217
|
* @returns Transaction result
|
|
3198
3218
|
*/
|
|
3199
3219
|
async cancel(cancelData, extParams) {
|
|
3200
3220
|
const ixs = await this.prepareCancelInstructions(cancelData, extParams);
|
|
3201
|
-
const { tx, hash, context } = await
|
|
3202
|
-
const signature = await
|
|
3221
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
3222
|
+
const signature = await common.signAndExecuteTransaction(
|
|
3203
3223
|
this.connection,
|
|
3204
3224
|
extParams.invoker,
|
|
3205
3225
|
tx,
|
|
@@ -3215,7 +3235,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3215
3235
|
/**
|
|
3216
3236
|
* Creates Transaction Instructions for cancel
|
|
3217
3237
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
3218
|
-
* @param {
|
|
3238
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet address, token account validation, and compute settings
|
|
3219
3239
|
* @returns Transaction instructions
|
|
3220
3240
|
*/
|
|
3221
3241
|
async prepareCancelInstructions(cancelData, extParams) {
|
|
@@ -3232,7 +3252,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3232
3252
|
/**
|
|
3233
3253
|
* Creates Transaction Instructions for cancel
|
|
3234
3254
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
3235
|
-
* @param {
|
|
3255
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
3236
3256
|
* @returns Transaction instructions
|
|
3237
3257
|
*/
|
|
3238
3258
|
async prepareCancelAlignedUnlockInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
@@ -3242,8 +3262,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3242
3262
|
common.invariant(escrowAcc?.data, "Couldn't get account info");
|
|
3243
3263
|
const streamData = decodeStream(escrowAcc.data);
|
|
3244
3264
|
const { sender, recipient, mint, streamflowTreasury, partner, escrowTokens } = streamData;
|
|
3245
|
-
const { tokenProgramId } = await
|
|
3246
|
-
const ixs =
|
|
3265
|
+
const { tokenProgramId } = await common.getMintAndProgram(this.connection, mint);
|
|
3266
|
+
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
3247
3267
|
computePrice,
|
|
3248
3268
|
computeLimit: computeLimit ?? ALIGNED_COMPUTE_LIMIT
|
|
3249
3269
|
});
|
|
@@ -3271,7 +3291,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3271
3291
|
/**
|
|
3272
3292
|
* Creates Transaction Instructions for cancel
|
|
3273
3293
|
* @param {ICancelData} cancelData - Cancellation parameters including stream ID
|
|
3274
|
-
* @param {
|
|
3294
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
3275
3295
|
* @returns Transaction instructions
|
|
3276
3296
|
*/
|
|
3277
3297
|
async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
@@ -3281,10 +3301,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3281
3301
|
common.invariant(escrowAcc?.data, "Couldn't get account info");
|
|
3282
3302
|
const data = decodeStream(escrowAcc.data);
|
|
3283
3303
|
const { sender, recipient, partner, streamflowTreasury, mint, senderTokens, recipientTokens, escrowTokens } = data;
|
|
3284
|
-
const { tokenProgramId } = await
|
|
3285
|
-
const streamflowTreasuryTokens = await
|
|
3286
|
-
const partnerTokens = await
|
|
3287
|
-
const ixs =
|
|
3304
|
+
const { tokenProgramId } = await common.getMintAndProgram(this.connection, mint);
|
|
3305
|
+
const streamflowTreasuryTokens = await common.ata(mint, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
3306
|
+
const partnerTokens = await common.ata(mint, partner, tokenProgramId);
|
|
3307
|
+
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
3288
3308
|
computePrice,
|
|
3289
3309
|
computeLimit
|
|
3290
3310
|
});
|
|
@@ -3319,13 +3339,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3319
3339
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
3320
3340
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
3321
3341
|
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
3322
|
-
* @param {
|
|
3342
|
+
* @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
3323
3343
|
* @returns Transaction result
|
|
3324
3344
|
*/
|
|
3325
3345
|
async transfer({ id, newRecipient }, extParams) {
|
|
3326
3346
|
const ixs = await this.prepareTransferInstructions({ id, newRecipient }, extParams);
|
|
3327
|
-
const { tx, hash, context } = await
|
|
3328
|
-
const signature = await
|
|
3347
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
3348
|
+
const signature = await common.signAndExecuteTransaction(
|
|
3329
3349
|
this.connection,
|
|
3330
3350
|
extParams.invoker,
|
|
3331
3351
|
tx,
|
|
@@ -3342,12 +3362,12 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3342
3362
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
3343
3363
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
3344
3364
|
* @param {ITransferData} transferData - Transfer parameters including stream ID and new recipient address
|
|
3345
|
-
* @param {
|
|
3365
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
3346
3366
|
* @returns Transaction instructions
|
|
3347
3367
|
*/
|
|
3348
3368
|
async prepareTransferInstructions({ id, newRecipient }, { invoker, computePrice, computeLimit = 100001 }) {
|
|
3349
3369
|
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3350
|
-
const ixs =
|
|
3370
|
+
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
3351
3371
|
computePrice,
|
|
3352
3372
|
computeLimit
|
|
3353
3373
|
});
|
|
@@ -3356,8 +3376,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3356
3376
|
const escrow = await this.connection.getAccountInfo(stream);
|
|
3357
3377
|
common.invariant(escrow?.data, "Couldn't get account info");
|
|
3358
3378
|
const { mint } = decodeStream(escrow?.data);
|
|
3359
|
-
const { tokenProgramId } = await
|
|
3360
|
-
const newRecipientTokens = await
|
|
3379
|
+
const { tokenProgramId } = await common.getMintAndProgram(this.connection, mint);
|
|
3380
|
+
const newRecipientTokens = await common.ata(mint, newRecipientPublicKey, tokenProgramId);
|
|
3361
3381
|
ixs.push(
|
|
3362
3382
|
await transferStreamInstruction(this.programId, {
|
|
3363
3383
|
authority: invoker.publicKey,
|
|
@@ -3376,13 +3396,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3376
3396
|
/**
|
|
3377
3397
|
* Tops up stream account with specified amount.
|
|
3378
3398
|
* @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
|
|
3379
|
-
* @param {
|
|
3399
|
+
* @param {ITopUpStreamExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
|
|
3380
3400
|
* @returns Transaction result
|
|
3381
3401
|
*/
|
|
3382
3402
|
async topup({ id, amount }, extParams) {
|
|
3383
3403
|
const ixs = await this.prepareTopupInstructions({ id, amount }, extParams);
|
|
3384
|
-
const { tx, hash, context } = await
|
|
3385
|
-
const signature = await
|
|
3404
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
3405
|
+
const signature = await common.signAndExecuteTransaction(
|
|
3386
3406
|
this.connection,
|
|
3387
3407
|
extParams.invoker,
|
|
3388
3408
|
tx,
|
|
@@ -3398,14 +3418,14 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3398
3418
|
/**
|
|
3399
3419
|
* Create Transaction instructions for topup
|
|
3400
3420
|
* @param {ITopUpData} topupData - Top-up parameters including stream ID and amount to add
|
|
3401
|
-
* @param {
|
|
3421
|
+
* @param {ITopUpStreamExt} extParams - Transaction configuration including invoker wallet, native token handling, and compute settings
|
|
3402
3422
|
* @returns Transaction instructions
|
|
3403
3423
|
*/
|
|
3404
3424
|
async prepareTopupInstructions({ id, amount }, { invoker, isNative, computePrice, computeLimit }) {
|
|
3405
3425
|
if (!invoker.publicKey) {
|
|
3406
3426
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3407
3427
|
}
|
|
3408
|
-
const ixs =
|
|
3428
|
+
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
3409
3429
|
computePrice,
|
|
3410
3430
|
computeLimit
|
|
3411
3431
|
});
|
|
@@ -3415,11 +3435,11 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3415
3435
|
throw new Error("Couldn't get account info");
|
|
3416
3436
|
}
|
|
3417
3437
|
const { mint, partner, senderTokens, escrowTokens } = decodeStream(escrow?.data);
|
|
3418
|
-
const { tokenProgramId } = await
|
|
3419
|
-
const streamflowTreasuryTokens = await
|
|
3420
|
-
const partnerTokens = await
|
|
3438
|
+
const { tokenProgramId } = await common.getMintAndProgram(this.connection, mint);
|
|
3439
|
+
const streamflowTreasuryTokens = await common.ata(mint, STREAMFLOW_TREASURY_PUBLIC_KEY, tokenProgramId);
|
|
3440
|
+
const partnerTokens = await common.ata(mint, partner, tokenProgramId);
|
|
3421
3441
|
if (isNative) {
|
|
3422
|
-
ixs.push(...await
|
|
3442
|
+
ixs.push(...await common.prepareWrappedAccount(this.connection, invoker.publicKey, amount));
|
|
3423
3443
|
}
|
|
3424
3444
|
ixs.push(
|
|
3425
3445
|
await topupStreamInstruction(amount, this.programId, {
|
|
@@ -3481,7 +3501,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3481
3501
|
}
|
|
3482
3502
|
]);
|
|
3483
3503
|
const streamPubKeys = alignedOutgoingProgramAccounts.map((account) => account.account.stream);
|
|
3484
|
-
const streamAccounts = await
|
|
3504
|
+
const streamAccounts = await common.getMultipleAccountsInfoBatched(this.connection, streamPubKeys, TX_FINALITY_CONFIRMED);
|
|
3485
3505
|
streamAccounts.forEach((account, index) => {
|
|
3486
3506
|
if (account) {
|
|
3487
3507
|
const alignedData = alignedOutgoingProgramAccounts[index].account;
|
|
@@ -3496,7 +3516,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3496
3516
|
const alignedProxyPDAs = alignedStreamsPubKeys.map(
|
|
3497
3517
|
(streamPubKey) => deriveContractPDA(this.alignedProxyProgram.programId, new web3_js.PublicKey(streamPubKey))
|
|
3498
3518
|
);
|
|
3499
|
-
const alignedProxyAccounts = await
|
|
3519
|
+
const alignedProxyAccounts = await common.getMultipleAccountsInfoBatched(this.connection, alignedProxyPDAs);
|
|
3500
3520
|
alignedProxyAccounts.forEach((account, index) => {
|
|
3501
3521
|
if (account && account.data.length === ALIGNED_METADATA_ACC_SIZE) {
|
|
3502
3522
|
const alignedData = streamRecord[alignedStreamsPubKeys[index]];
|
|
@@ -3523,7 +3543,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3523
3543
|
let streams = {};
|
|
3524
3544
|
const shouldFetchAligned = type === "all" /* All */ || type === "vesting" /* Vesting */;
|
|
3525
3545
|
if (direction !== "incoming" /* Incoming */) {
|
|
3526
|
-
const outgoingStreamAccounts = await
|
|
3546
|
+
const outgoingStreamAccounts = await common.getProgramAccounts(
|
|
3527
3547
|
this.connection,
|
|
3528
3548
|
publicKey,
|
|
3529
3549
|
STREAM_STRUCT_OFFSET_SENDER,
|
|
@@ -3538,7 +3558,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3538
3558
|
}
|
|
3539
3559
|
}
|
|
3540
3560
|
if (direction !== "outgoing" /* Outgoing */) {
|
|
3541
|
-
const allIncomingAccounts = await
|
|
3561
|
+
const allIncomingAccounts = await common.getProgramAccounts(
|
|
3542
3562
|
this.connection,
|
|
3543
3563
|
publicKey,
|
|
3544
3564
|
STREAM_STRUCT_OFFSET_RECIPIENT,
|
|
@@ -3586,7 +3606,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3586
3606
|
/**
|
|
3587
3607
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
3588
3608
|
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
3589
|
-
* @param {
|
|
3609
|
+
* @param {IInteractStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
3590
3610
|
* @returns Transaction result
|
|
3591
3611
|
*/
|
|
3592
3612
|
async update(data, extParams) {
|
|
@@ -3594,8 +3614,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3594
3614
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3595
3615
|
}
|
|
3596
3616
|
const ixs = await this.prepareUpdateInstructions(data, extParams);
|
|
3597
|
-
const { tx, hash, context } = await
|
|
3598
|
-
const signature = await
|
|
3617
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, extParams.invoker.publicKey);
|
|
3618
|
+
const signature = await common.signAndExecuteTransaction(
|
|
3599
3619
|
this.connection,
|
|
3600
3620
|
extParams.invoker,
|
|
3601
3621
|
tx,
|
|
@@ -3614,7 +3634,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3614
3634
|
/**
|
|
3615
3635
|
* Create Transaction instructions for update
|
|
3616
3636
|
* @param {IUpdateData} data - Update parameters including stream ID and new settings
|
|
3617
|
-
* @param {
|
|
3637
|
+
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet and compute settings
|
|
3618
3638
|
* @returns Transaction instructions
|
|
3619
3639
|
*/
|
|
3620
3640
|
async prepareUpdateInstructions(data, { invoker, computePrice, computeLimit }) {
|
|
@@ -3622,7 +3642,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3622
3642
|
const streamPublicKey = new web3_js.PublicKey(data.id);
|
|
3623
3643
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
3624
3644
|
common.invariant(escrow, "Couldn't get account info");
|
|
3625
|
-
const ixs =
|
|
3645
|
+
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
3626
3646
|
computePrice,
|
|
3627
3647
|
computeLimit
|
|
3628
3648
|
});
|
|
@@ -3667,6 +3687,20 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3667
3687
|
async getDefaultStreamflowFee() {
|
|
3668
3688
|
return DEFAULT_STREAMFLOW_FEE;
|
|
3669
3689
|
}
|
|
3690
|
+
/**
|
|
3691
|
+
* Returns total fee percent, streamflow fees + partner fees
|
|
3692
|
+
* @param getFeesData structure with address for which we need to derive fee, either sender or partner usually
|
|
3693
|
+
* @param chainSpecificParams additional parameters required by chain client
|
|
3694
|
+
* @returns fee as floating number, so if fee is 0.99%, it will return 0.99
|
|
3695
|
+
*/
|
|
3696
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3697
|
+
async getTotalFee(getFeesData) {
|
|
3698
|
+
const fees = await this.getFees(getFeesData);
|
|
3699
|
+
if (fees) {
|
|
3700
|
+
return fees.partnerFee + fees.streamflowFee;
|
|
3701
|
+
}
|
|
3702
|
+
return this.getDefaultStreamflowFee();
|
|
3703
|
+
}
|
|
3670
3704
|
/**
|
|
3671
3705
|
* Extracts error code from an error
|
|
3672
3706
|
* @param {Error} err - Error
|
|
@@ -3676,6 +3710,13 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3676
3710
|
const logs = "logs" in err && Array.isArray(err.logs) ? err.logs : void 0;
|
|
3677
3711
|
return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
|
|
3678
3712
|
}
|
|
3713
|
+
/**
|
|
3714
|
+
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
3715
|
+
*/
|
|
3716
|
+
isAlignedUnlock(streamPublicKey, senderPublicKey) {
|
|
3717
|
+
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
3718
|
+
return senderPublicKey.equals(pda);
|
|
3719
|
+
}
|
|
3679
3720
|
/**
|
|
3680
3721
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
3681
3722
|
*/
|
|
@@ -3690,13 +3731,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3690
3731
|
}
|
|
3691
3732
|
return { metadata, metadataPubKey };
|
|
3692
3733
|
}
|
|
3693
|
-
/**
|
|
3694
|
-
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
3695
|
-
*/
|
|
3696
|
-
isAlignedUnlock(streamPublicKey, senderPublicKey) {
|
|
3697
|
-
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
3698
|
-
return senderPublicKey.equals(pda);
|
|
3699
|
-
}
|
|
3700
3734
|
/**
|
|
3701
3735
|
* Returns insrtuctions for creating associated token accounts for the provided owners
|
|
3702
3736
|
*/
|
|
@@ -3707,7 +3741,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
|
|
|
3707
3741
|
const uniqueOwners = Array.from(new Set(owners.map((owner) => owner.toBase58()))).map(
|
|
3708
3742
|
(pkString) => new web3_js.PublicKey(pkString)
|
|
3709
3743
|
);
|
|
3710
|
-
return
|
|
3744
|
+
return common.checkOrCreateAtaBatch(this.connection, uniqueOwners, mint, invoker, programId);
|
|
3711
3745
|
}
|
|
3712
3746
|
async applyCustomAfterInstructions(ixs, customInstructions, metadata) {
|
|
3713
3747
|
if (customInstructions?.after) {
|
|
@@ -4146,26 +4180,76 @@ Object.defineProperty(exports, "ContractError", {
|
|
|
4146
4180
|
enumerable: true,
|
|
4147
4181
|
get: function () { return common.ContractError; }
|
|
4148
4182
|
});
|
|
4149
|
-
Object.defineProperty(exports, "IChain", {
|
|
4150
|
-
enumerable: true,
|
|
4151
|
-
get: function () { return common.IChain; }
|
|
4152
|
-
});
|
|
4153
4183
|
Object.defineProperty(exports, "ICluster", {
|
|
4154
4184
|
enumerable: true,
|
|
4155
4185
|
get: function () { return common.ICluster; }
|
|
4156
4186
|
});
|
|
4187
|
+
Object.defineProperty(exports, "getBN", {
|
|
4188
|
+
enumerable: true,
|
|
4189
|
+
get: function () { return common.getBN; }
|
|
4190
|
+
});
|
|
4191
|
+
Object.defineProperty(exports, "getNumberFromBN", {
|
|
4192
|
+
enumerable: true,
|
|
4193
|
+
get: function () { return common.getNumberFromBN; }
|
|
4194
|
+
});
|
|
4195
|
+
exports.AIRDROP_AMOUNT = AIRDROP_AMOUNT;
|
|
4196
|
+
exports.AIRDROP_TEST_TOKEN = AIRDROP_TEST_TOKEN;
|
|
4197
|
+
exports.ALIGNED_COMPUTE_LIMIT = ALIGNED_COMPUTE_LIMIT;
|
|
4198
|
+
exports.ALIGNED_PRECISION_FACTOR_POW = ALIGNED_PRECISION_FACTOR_POW2;
|
|
4199
|
+
exports.ALIGNED_UNLOCKS_PROGRAM_ID = ALIGNED_UNLOCKS_PROGRAM_ID;
|
|
4157
4200
|
exports.AlignedContract = AlignedContract;
|
|
4201
|
+
exports.AlignedProxyErrorCode = AlignedProxyErrorCode;
|
|
4202
|
+
exports.CONTRACT_DISCRIMINATOR = CONTRACT_DISCRIMINATOR;
|
|
4203
|
+
exports.CONTRACT_SEED = CONTRACT_SEED;
|
|
4204
|
+
exports.CREATE_PARAMS_PADDING = CREATE_PARAMS_PADDING;
|
|
4158
4205
|
exports.Contract = Contract;
|
|
4206
|
+
exports.ContractErrorCode = ContractErrorCode;
|
|
4207
|
+
exports.DEFAULT_STREAMFLOW_FEE = DEFAULT_STREAMFLOW_FEE;
|
|
4208
|
+
exports.ESCROW_SEED = ESCROW_SEED;
|
|
4209
|
+
exports.FEES_METADATA_SEED = FEES_METADATA_SEED;
|
|
4210
|
+
exports.FEE_ORACLE_PUBLIC_KEY = FEE_ORACLE_PUBLIC_KEY;
|
|
4211
|
+
exports.MAX_SAFE_UNIX_TIME_VALUE = MAX_SAFE_UNIX_TIME_VALUE2;
|
|
4212
|
+
exports.ORIGINAL_CONTRACT_SENDER_OFFSET = ORIGINAL_CONTRACT_SENDER_OFFSET;
|
|
4213
|
+
exports.PARTNERS_SCHEMA = PARTNERS_SCHEMA;
|
|
4214
|
+
exports.PARTNER_ORACLE_PROGRAM_ID = PARTNER_ORACLE_PROGRAM_ID;
|
|
4215
|
+
exports.PARTNER_SCHEMA = PARTNER_SCHEMA;
|
|
4216
|
+
exports.PROGRAM_ID = PROGRAM_ID;
|
|
4217
|
+
exports.SOLANA_ERROR_MAP = SOLANA_ERROR_MAP;
|
|
4218
|
+
exports.SOLANA_ERROR_MATCH_REGEX = SOLANA_ERROR_MATCH_REGEX;
|
|
4219
|
+
exports.STREAMFLOW_TREASURY_PUBLIC_KEY = STREAMFLOW_TREASURY_PUBLIC_KEY;
|
|
4220
|
+
exports.STREAM_STRUCT_OFFSETS = STREAM_STRUCT_OFFSETS;
|
|
4221
|
+
exports.STREAM_STRUCT_OFFSET_CLOSED = STREAM_STRUCT_OFFSET_CLOSED;
|
|
4222
|
+
exports.STREAM_STRUCT_OFFSET_MINT = STREAM_STRUCT_OFFSET_MINT;
|
|
4223
|
+
exports.STREAM_STRUCT_OFFSET_RECIPIENT = STREAM_STRUCT_OFFSET_RECIPIENT;
|
|
4224
|
+
exports.STREAM_STRUCT_OFFSET_SENDER = STREAM_STRUCT_OFFSET_SENDER;
|
|
4159
4225
|
exports.SolanaStreamClient = SolanaStreamClient;
|
|
4226
|
+
exports.StreamDirection = StreamDirection;
|
|
4227
|
+
exports.StreamType = StreamType;
|
|
4228
|
+
exports.TEST_ORACLE_DISCRIMINATOR = TEST_ORACLE_DISCRIMINATOR;
|
|
4229
|
+
exports.TEST_ORACLE_SEED = TEST_ORACLE_SEED;
|
|
4230
|
+
exports.TX_FINALITY_CONFIRMED = TX_FINALITY_CONFIRMED;
|
|
4231
|
+
exports.WITHDRAWOR_PUBLIC_KEY = WITHDRAWOR_PUBLIC_KEY;
|
|
4232
|
+
exports.WITHDRAW_AVAILABLE_AMOUNT = WITHDRAW_AVAILABLE_AMOUNT;
|
|
4233
|
+
exports.buildStreamType = buildStreamType;
|
|
4234
|
+
exports.calculateTotalAmountToDeposit = calculateTotalAmountToDeposit;
|
|
4235
|
+
exports.calculateUnlockedAmount = calculateUnlockedAmount;
|
|
4160
4236
|
exports.cancelStreamInstruction = cancelStreamInstruction;
|
|
4161
|
-
exports.constants = constants_exports;
|
|
4162
4237
|
exports.createStreamInstruction = createStreamInstruction;
|
|
4163
4238
|
exports.createUncheckedStreamInstruction = createUncheckedStreamInstruction;
|
|
4239
|
+
exports.decodeEndTime = decodeEndTime;
|
|
4164
4240
|
exports.decodeStream = decodeStream;
|
|
4165
4241
|
exports.deriveContractPDA = deriveContractPDA;
|
|
4166
4242
|
exports.deriveEscrowPDA = deriveEscrowPDA;
|
|
4167
4243
|
exports.deriveTestOraclePDA = deriveTestOraclePDA;
|
|
4168
4244
|
exports.extractSolanaErrorCode = extractSolanaErrorCode;
|
|
4245
|
+
exports.handleContractError = handleContractError;
|
|
4246
|
+
exports.isAligned = isAligned;
|
|
4247
|
+
exports.isCliffCloseToDepositedAmount = isCliffCloseToDepositedAmount;
|
|
4248
|
+
exports.isCreateAlignedStreamData = isCreateAlignedStreamData;
|
|
4249
|
+
exports.isDynamicLock = isDynamicLock;
|
|
4250
|
+
exports.isPayment = isPayment;
|
|
4251
|
+
exports.isTokenLock = isTokenLock;
|
|
4252
|
+
exports.isVesting = isVesting;
|
|
4169
4253
|
exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;
|
|
4170
4254
|
exports.signAllTransactionWithRecipients = signAllTransactionWithRecipients;
|
|
4171
4255
|
exports.timelockIDL = timelockIDL_default;
|