@streamflow/stream 7.0.0-alpha.12 → 7.0.0-alpha.13
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 +10 -5
- package/dist/cjs/common/constants.js +2 -1
- package/dist/cjs/common/contractUtils.js +17 -1
- package/dist/cjs/common/types.js +30 -1
- package/dist/cjs/solana/StreamClient.js +244 -99
- package/dist/cjs/solana/constants.js +29 -1
- package/dist/cjs/solana/descriptor/idl/streamflow_aligned_unlocks.json +1471 -0
- package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.js +2 -0
- package/dist/cjs/solana/index.js +2 -1
- package/dist/cjs/solana/lib/derive-accounts.js +17 -0
- package/dist/cjs/solana/{utils.js → lib/utils.js} +2 -2
- package/dist/cjs/solana/types.js +25 -2
- package/dist/esm/aptos/types.d.ts +2 -2
- package/dist/esm/common/constants.d.ts +1 -0
- package/dist/esm/common/constants.js +1 -0
- package/dist/esm/common/contractUtils.d.ts +4 -1
- package/dist/esm/common/contractUtils.js +13 -0
- package/dist/esm/common/types.d.ts +104 -49
- package/dist/esm/common/types.js +29 -0
- package/dist/esm/evm/types.d.ts +2 -2
- package/dist/esm/solana/StreamClient.d.ts +20 -14
- package/dist/esm/solana/StreamClient.js +247 -101
- package/dist/esm/solana/constants.d.ts +14 -0
- package/dist/esm/solana/constants.js +29 -1
- package/dist/esm/solana/descriptor/idl/streamflow_aligned_unlocks.json +1471 -0
- package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.d.ts +1272 -0
- package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.js +1 -0
- package/dist/esm/solana/index.d.ts +2 -1
- package/dist/esm/solana/index.js +2 -1
- package/dist/esm/solana/lib/derive-accounts.d.ts +4 -0
- package/dist/esm/solana/lib/derive-accounts.js +11 -0
- package/dist/esm/solana/{utils.d.ts → lib/utils.d.ts} +1 -1
- package/dist/esm/solana/{utils.js → lib/utils.js} +2 -2
- package/dist/esm/solana/types.d.ts +31 -3
- package/dist/esm/solana/types.js +30 -2
- package/dist/esm/sui/types.d.ts +2 -2
- package/package.json +5 -4
package/dist/cjs/solana/index.js
CHANGED
|
@@ -31,7 +31,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.timelockIDL = exports.constants = void 0;
|
|
33
33
|
__exportStar(require("./StreamClient.js"), exports);
|
|
34
|
-
__exportStar(require("./utils.js"), exports);
|
|
34
|
+
__exportStar(require("./lib/utils.js"), exports);
|
|
35
|
+
__exportStar(require("./lib/derive-accounts.js"), exports);
|
|
35
36
|
__exportStar(require("./types.js"), exports);
|
|
36
37
|
__exportStar(require("./instructions.js"), exports);
|
|
37
38
|
exports.constants = __importStar(require("./constants.js"));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deriveTestOraclePDA = exports.deriveEscrowPDA = exports.deriveContractPDA = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const deriveContractPDA = (programId, streamMetadata) => {
|
|
7
|
+
return web3_js_1.PublicKey.findProgramAddressSync([constants_1.CONTRACT_SEED, streamMetadata.toBuffer()], programId)[0];
|
|
8
|
+
};
|
|
9
|
+
exports.deriveContractPDA = deriveContractPDA;
|
|
10
|
+
const deriveEscrowPDA = (programId, streamMetadata) => {
|
|
11
|
+
return web3_js_1.PublicKey.findProgramAddressSync([constants_1.ESCROW_SEED, streamMetadata.toBuffer()], programId)[0];
|
|
12
|
+
};
|
|
13
|
+
exports.deriveEscrowPDA = deriveEscrowPDA;
|
|
14
|
+
const deriveTestOraclePDA = (programId, mint, creator) => {
|
|
15
|
+
return web3_js_1.PublicKey.findProgramAddressSync([constants_1.TEST_ORACLE_SEED, mint.toBuffer(), creator.toBuffer()], programId)[0];
|
|
16
|
+
};
|
|
17
|
+
exports.deriveTestOraclePDA = deriveTestOraclePDA;
|
|
@@ -7,8 +7,8 @@ exports.extractSolanaErrorCode = exports.sendAndConfirmStreamRawTransaction = ex
|
|
|
7
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
8
8
|
const solana_1 = require("@streamflow/common/solana");
|
|
9
9
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
10
|
-
const layout_js_1 = require("
|
|
11
|
-
const constants_js_1 = require("
|
|
10
|
+
const layout_js_1 = require("../layout.js");
|
|
11
|
+
const constants_js_1 = require("../constants.js");
|
|
12
12
|
const decoder = new TextDecoder("utf-8");
|
|
13
13
|
const LE = "le"; //little endian
|
|
14
14
|
const decodeStream = (buf) => {
|
package/dist/cjs/solana/types.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Contract = void 0;
|
|
3
|
+
exports.AlignedContract = exports.Contract = exports.ContractError = exports.ICluster = exports.IChain = void 0;
|
|
4
4
|
const contractUtils_js_1 = require("../common/contractUtils.js");
|
|
5
5
|
const utils_js_1 = require("../common/utils.js");
|
|
6
|
+
const constants_js_1 = require("./constants.js");
|
|
7
|
+
var common_1 = require("@streamflow/common");
|
|
8
|
+
Object.defineProperty(exports, "IChain", { enumerable: true, get: function () { return common_1.IChain; } });
|
|
9
|
+
Object.defineProperty(exports, "ICluster", { enumerable: true, get: function () { return common_1.ICluster; } });
|
|
10
|
+
Object.defineProperty(exports, "ContractError", { enumerable: true, get: function () { return common_1.ContractError; } });
|
|
6
11
|
class Contract {
|
|
7
12
|
constructor(stream) {
|
|
8
13
|
this.magic = stream.magic.toNumber();
|
|
@@ -10,7 +15,8 @@ class Contract {
|
|
|
10
15
|
this.createdAt = stream.createdAt.toNumber();
|
|
11
16
|
this.withdrawnAmount = stream.withdrawnAmount;
|
|
12
17
|
this.canceledAt = stream.canceledAt.toNumber();
|
|
13
|
-
|
|
18
|
+
// for aligned contracts end time can be an invalid timeValue
|
|
19
|
+
this.end = (0, contractUtils_js_1.decodeEndTime)(stream.end);
|
|
14
20
|
this.lastWithdrawnAt = stream.lastWithdrawnAt.toNumber();
|
|
15
21
|
this.sender = stream.sender.toBase58();
|
|
16
22
|
this.senderTokens = stream.senderTokens.toBase58();
|
|
@@ -48,6 +54,7 @@ class Contract {
|
|
|
48
54
|
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
49
55
|
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
50
56
|
this.type = (0, contractUtils_js_1.buildStreamType)(this);
|
|
57
|
+
this.isAligned = false;
|
|
51
58
|
}
|
|
52
59
|
unlocked(currentTimestamp) {
|
|
53
60
|
return (0, contractUtils_js_1.calculateUnlockedAmount)({
|
|
@@ -60,3 +67,19 @@ class Contract {
|
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
69
|
exports.Contract = Contract;
|
|
70
|
+
class AlignedContract extends Contract {
|
|
71
|
+
constructor(stream, alignedProxy) {
|
|
72
|
+
super(stream);
|
|
73
|
+
this.minPrice = (0, utils_js_1.getNumberFromBN)(alignedProxy.minPrice, constants_js_1.ALIGNED_PRECISION_FACTOR_POW);
|
|
74
|
+
this.maxPrice = (0, utils_js_1.getNumberFromBN)(alignedProxy.maxPrice, constants_js_1.ALIGNED_PRECISION_FACTOR_POW);
|
|
75
|
+
this.minPercentage = (0, utils_js_1.getNumberFromBN)(alignedProxy.minPercentage, constants_js_1.ALIGNED_PRECISION_FACTOR_POW);
|
|
76
|
+
this.maxPercentage = (0, utils_js_1.getNumberFromBN)(alignedProxy.maxPercentage, constants_js_1.ALIGNED_PRECISION_FACTOR_POW);
|
|
77
|
+
this.oracleType = (Object.keys(alignedProxy.priceOracleType).find((key) => !!key) || "none");
|
|
78
|
+
this.tickSize = alignedProxy.tickSize.toNumber();
|
|
79
|
+
this.priceOracle = this.oracleType === "none" ? undefined : alignedProxy.priceOracle.toBase58();
|
|
80
|
+
this.sender = alignedProxy.sender.toBase58();
|
|
81
|
+
this.canceledAt = alignedProxy.streamCanceledTime.toNumber();
|
|
82
|
+
this.proxyAddress = stream.sender.toBase58();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.AlignedContract = AlignedContract;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AptosAccount } from "aptos";
|
|
2
2
|
import { WalletContextState } from "@manahippo/aptos-wallet-adapter";
|
|
3
3
|
import BN from "bn.js";
|
|
4
|
-
import {
|
|
4
|
+
import { LinearStream, StreamType } from "../common/types.js";
|
|
5
5
|
export interface ICreateStreamAptosExt {
|
|
6
6
|
senderWallet: WalletContextState | AptosAccount;
|
|
7
7
|
}
|
|
@@ -59,7 +59,7 @@ export interface ConfigResource {
|
|
|
59
59
|
tx_fee: string;
|
|
60
60
|
withdrawor: string;
|
|
61
61
|
}
|
|
62
|
-
export declare class Contract implements
|
|
62
|
+
export declare class Contract implements LinearStream {
|
|
63
63
|
magic: number;
|
|
64
64
|
version: number;
|
|
65
65
|
createdAt: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import BN from "bn.js";
|
|
2
|
+
export const MAX_SAFE_UNIX_TIME_VALUE = 8640000000000;
|
|
2
3
|
export const BASE_FEE = 1009900; // Buffer to include usual fees when calculating stream amount
|
|
3
4
|
export const WITHDRAW_AVAILABLE_AMOUNT = new BN("18446744073709551615"); // Magical number to withdraw all available amount from a Contract
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BN from "bn.js";
|
|
2
|
-
import { StreamType } from "./types.js";
|
|
2
|
+
import { AlignedStream, ICreateAlignedStreamData, ICreateStreamData, Stream, StreamType } from "./types.js";
|
|
3
3
|
interface ICalculateUnlockedAmount {
|
|
4
4
|
depositedAmount: BN;
|
|
5
5
|
cliff: number;
|
|
@@ -24,6 +24,8 @@ export declare const isVesting: (streamData: {
|
|
|
24
24
|
depositedAmount: BN;
|
|
25
25
|
cliffAmount: BN;
|
|
26
26
|
}) => boolean;
|
|
27
|
+
export declare const isAligned: (stream: Stream) => stream is AlignedStream;
|
|
28
|
+
export declare const isCreateAlignedStreamData: (obj: ICreateStreamData) => obj is ICreateAlignedStreamData;
|
|
27
29
|
export declare const isTokenLock: (streamData: {
|
|
28
30
|
canTopup: boolean;
|
|
29
31
|
automaticWithdrawal: boolean;
|
|
@@ -44,4 +46,5 @@ export declare const buildStreamType: (streamData: {
|
|
|
44
46
|
depositedAmount: BN;
|
|
45
47
|
cliffAmount: BN;
|
|
46
48
|
}) => StreamType;
|
|
49
|
+
export declare const decodeEndTime: (endTime: BN) => number;
|
|
47
50
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BN from "bn.js";
|
|
2
2
|
import { StreamType } from "./types.js";
|
|
3
|
+
import { MAX_SAFE_UNIX_TIME_VALUE } from "./constants.js";
|
|
3
4
|
export const calculateUnlockedAmount = ({ depositedAmount, cliff, cliffAmount, end, currentTimestamp, lastRateChangeTime, period, amountPerPeriod, fundsUnlockedAtLastRateChange, }) => {
|
|
4
5
|
const deposited = depositedAmount;
|
|
5
6
|
if (currentTimestamp < cliff)
|
|
@@ -22,6 +23,12 @@ export const isPayment = (streamData) => {
|
|
|
22
23
|
export const isVesting = (streamData) => {
|
|
23
24
|
return !streamData.canTopup && !isCliffCloseToDepositedAmount(streamData);
|
|
24
25
|
};
|
|
26
|
+
export const isAligned = (stream) => {
|
|
27
|
+
return "minPrice" in stream && "maxPrice" in stream && "minPercentage" in stream && "maxPercentage" in stream;
|
|
28
|
+
};
|
|
29
|
+
export const isCreateAlignedStreamData = (obj) => {
|
|
30
|
+
return "minPrice" in obj && "maxPrice" in obj && "minPercentage" in obj && "maxPercentage" in obj;
|
|
31
|
+
};
|
|
25
32
|
export const isTokenLock = (streamData) => {
|
|
26
33
|
return (!streamData.canTopup &&
|
|
27
34
|
!streamData.automaticWithdrawal &&
|
|
@@ -40,3 +47,9 @@ export const buildStreamType = (streamData) => {
|
|
|
40
47
|
}
|
|
41
48
|
return StreamType.Payment;
|
|
42
49
|
};
|
|
50
|
+
export const decodeEndTime = (endTime) => {
|
|
51
|
+
if (endTime.gt(new BN(MAX_SAFE_UNIX_TIME_VALUE))) {
|
|
52
|
+
return MAX_SAFE_UNIX_TIME_VALUE;
|
|
53
|
+
}
|
|
54
|
+
return endTime.toNumber();
|
|
55
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Address } from "@coral-xyz/anchor";
|
|
1
2
|
import { TransactionInstruction } from "@solana/web3.js";
|
|
2
3
|
import { Types } from "aptos";
|
|
3
4
|
import BN from "bn.js";
|
|
@@ -9,7 +10,7 @@ export interface IRecipient {
|
|
|
9
10
|
cliffAmount: BN;
|
|
10
11
|
amountPerPeriod: BN;
|
|
11
12
|
}
|
|
12
|
-
export interface
|
|
13
|
+
export interface IBaseStreamConfig {
|
|
13
14
|
period: number;
|
|
14
15
|
start: number;
|
|
15
16
|
cliff: number;
|
|
@@ -25,10 +26,24 @@ export interface IStreamConfig {
|
|
|
25
26
|
canUpdateRate?: boolean;
|
|
26
27
|
partner?: string;
|
|
27
28
|
}
|
|
28
|
-
export type
|
|
29
|
-
|
|
29
|
+
export type IAlignedStreamConfig = {
|
|
30
|
+
minPrice: number;
|
|
31
|
+
maxPrice: number;
|
|
32
|
+
minPercentage: number;
|
|
33
|
+
maxPercentage: number;
|
|
34
|
+
oracleType?: OracleTypeName;
|
|
35
|
+
priceOracle?: Address;
|
|
36
|
+
skipInitial?: boolean;
|
|
37
|
+
tickSize?: number;
|
|
38
|
+
};
|
|
39
|
+
export type ICreateLinearStreamData = IBaseStreamConfig & IRecipient;
|
|
40
|
+
export type ICreateAlignedStreamData = ICreateLinearStreamData & IAlignedStreamConfig;
|
|
41
|
+
export type ICreateStreamData = ICreateLinearStreamData | ICreateAlignedStreamData;
|
|
42
|
+
export type ICreateMultipleLinearStreamData = IBaseStreamConfig & {
|
|
30
43
|
recipients: IRecipient[];
|
|
31
44
|
};
|
|
45
|
+
export type ICreateMultipleAlignedStreamData = ICreateMultipleLinearStreamData & IAlignedStreamConfig;
|
|
46
|
+
export type ICreateMultipleStreamData = ICreateMultipleLinearStreamData | ICreateMultipleAlignedStreamData;
|
|
32
47
|
export interface IInteractData {
|
|
33
48
|
id: string;
|
|
34
49
|
}
|
|
@@ -79,6 +94,7 @@ export interface IMultiTransactionResult {
|
|
|
79
94
|
metadataToRecipient: Record<MetadataId, IRecipient>;
|
|
80
95
|
errors: ICreateMultiError[];
|
|
81
96
|
}
|
|
97
|
+
export type OracleTypeName = "none" | "pyth" | "switchboard" | "test";
|
|
82
98
|
export declare enum StreamDirection {
|
|
83
99
|
Outgoing = "outgoing",
|
|
84
100
|
Incoming = "incoming",
|
|
@@ -129,6 +145,64 @@ export declare enum ContractErrorCode {
|
|
|
129
145
|
/** Aptos: user opt out from direct coin transfers feature and has not coin wallet registered */
|
|
130
146
|
ENO_RECIPIENT_COIN_ADDRESS = "ENO_RECIPIENT_COIN_ADDRESS"
|
|
131
147
|
}
|
|
148
|
+
export interface LinearStream {
|
|
149
|
+
magic: number;
|
|
150
|
+
version: number;
|
|
151
|
+
createdAt: number;
|
|
152
|
+
withdrawnAmount: BN;
|
|
153
|
+
canceledAt: number;
|
|
154
|
+
end: number;
|
|
155
|
+
lastWithdrawnAt: number;
|
|
156
|
+
sender: string;
|
|
157
|
+
senderTokens: string;
|
|
158
|
+
recipient: string;
|
|
159
|
+
recipientTokens: string;
|
|
160
|
+
mint: string;
|
|
161
|
+
escrowTokens: string;
|
|
162
|
+
streamflowTreasury: string;
|
|
163
|
+
streamflowTreasuryTokens: string;
|
|
164
|
+
streamflowFeeTotal: BN;
|
|
165
|
+
streamflowFeeWithdrawn: BN;
|
|
166
|
+
streamflowFeePercent: number;
|
|
167
|
+
partnerFeeTotal: BN;
|
|
168
|
+
partnerFeeWithdrawn: BN;
|
|
169
|
+
partnerFeePercent: number;
|
|
170
|
+
partner: string;
|
|
171
|
+
partnerTokens: string;
|
|
172
|
+
start: number;
|
|
173
|
+
depositedAmount: BN;
|
|
174
|
+
period: number;
|
|
175
|
+
amountPerPeriod: BN;
|
|
176
|
+
cliff: number;
|
|
177
|
+
cliffAmount: BN;
|
|
178
|
+
cancelableBySender: boolean;
|
|
179
|
+
cancelableByRecipient: boolean;
|
|
180
|
+
automaticWithdrawal: boolean;
|
|
181
|
+
transferableBySender: boolean;
|
|
182
|
+
transferableByRecipient: boolean;
|
|
183
|
+
canTopup: boolean;
|
|
184
|
+
name: string;
|
|
185
|
+
withdrawalFrequency: number;
|
|
186
|
+
closed: boolean;
|
|
187
|
+
currentPauseStart: number;
|
|
188
|
+
pauseCumulative: BN;
|
|
189
|
+
lastRateChangeTime: number;
|
|
190
|
+
fundsUnlockedAtLastRateChange: BN;
|
|
191
|
+
type: StreamType;
|
|
192
|
+
unlocked(currentTimestamp: number): BN;
|
|
193
|
+
remaining(decimals: number): number;
|
|
194
|
+
}
|
|
195
|
+
export type AlignedStreamData = {
|
|
196
|
+
minPrice: number;
|
|
197
|
+
maxPrice: number;
|
|
198
|
+
minPercentage: number;
|
|
199
|
+
maxPercentage: number;
|
|
200
|
+
oracleType: OracleTypeName;
|
|
201
|
+
priceOracle: string | undefined;
|
|
202
|
+
tickSize: number;
|
|
203
|
+
};
|
|
204
|
+
export type AlignedStream = LinearStream & AlignedStreamData;
|
|
205
|
+
export type Stream = LinearStream | AlignedStream;
|
|
132
206
|
/**
|
|
133
207
|
* Error codes raised by Solana protocol specifically
|
|
134
208
|
*/
|
|
@@ -180,50 +254,31 @@ export declare enum SolanaContractErrorCode {
|
|
|
180
254
|
/** Meta account is not rent exempt */
|
|
181
255
|
MetadataNotRentExempt = "MetadataNotRentExempt"
|
|
182
256
|
}
|
|
183
|
-
export
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
amountPerPeriod: BN;
|
|
211
|
-
cliff: number;
|
|
212
|
-
cliffAmount: BN;
|
|
213
|
-
cancelableBySender: boolean;
|
|
214
|
-
cancelableByRecipient: boolean;
|
|
215
|
-
automaticWithdrawal: boolean;
|
|
216
|
-
transferableBySender: boolean;
|
|
217
|
-
transferableByRecipient: boolean;
|
|
218
|
-
canTopup: boolean;
|
|
219
|
-
name: string;
|
|
220
|
-
withdrawalFrequency: number;
|
|
221
|
-
closed: boolean;
|
|
222
|
-
currentPauseStart: number;
|
|
223
|
-
pauseCumulative: BN;
|
|
224
|
-
lastRateChangeTime: number;
|
|
225
|
-
fundsUnlockedAtLastRateChange: BN;
|
|
226
|
-
type: StreamType;
|
|
227
|
-
unlocked(currentTimestamp: number): BN;
|
|
228
|
-
remaining(decimals: number): number;
|
|
257
|
+
export declare enum SolanaAlignedProxyErrorCode {
|
|
258
|
+
/** Authority does not have permission for this action */
|
|
259
|
+
Unauthorized = "Unauthorized",
|
|
260
|
+
/** Arithmetic error */
|
|
261
|
+
ArithmeticError = "ArithmeticError",
|
|
262
|
+
/** Mint has unsupported Token Extensions */
|
|
263
|
+
UnsupportedTokenExtensions = "UnsupportedTokenExtensions",
|
|
264
|
+
/** Provided period is too short, should be equal or more than 30 seconds */
|
|
265
|
+
PeriodTooShort = "PeriodTooShort",
|
|
266
|
+
/** Provided percentage tick size is invalid */
|
|
267
|
+
InvalidTickSize = "InvalidTickSize",
|
|
268
|
+
/** Provided percentage bounds are invalid */
|
|
269
|
+
InvalidPercentageBoundaries = "InvalidPercentageBoundaries",
|
|
270
|
+
/** Provided price bounds are invalid */
|
|
271
|
+
InvalidPriceBoundaries = "InvalidPriceBoundaries",
|
|
272
|
+
/** Unsupported price oracle */
|
|
273
|
+
UnsupportedOracle = "UnsupportedOracle",
|
|
274
|
+
/** Invalid oracle account */
|
|
275
|
+
InvalidOracleAccount = "InvalidOracleAccount",
|
|
276
|
+
/** Invalid oracle price */
|
|
277
|
+
InvalidOraclePrice = "InvalidOraclePrice",
|
|
278
|
+
/** Invalid Stream Metadata */
|
|
279
|
+
InvalidStreamMetadata = "InvalidStreamMetadata",
|
|
280
|
+
/** Release amount has already been updated in this period */
|
|
281
|
+
AmountAlreadyUpdated = "AmountAlreadyUpdated",
|
|
282
|
+
/** All funds are already unlocked */
|
|
283
|
+
AllFundsUnlocked = "AllFundsUnlocked"
|
|
229
284
|
}
|
package/dist/esm/common/types.js
CHANGED
|
@@ -104,3 +104,32 @@ export var SolanaContractErrorCode;
|
|
|
104
104
|
/** Meta account is not rent exempt */
|
|
105
105
|
SolanaContractErrorCode["MetadataNotRentExempt"] = "MetadataNotRentExempt";
|
|
106
106
|
})(SolanaContractErrorCode || (SolanaContractErrorCode = {}));
|
|
107
|
+
export var SolanaAlignedProxyErrorCode;
|
|
108
|
+
(function (SolanaAlignedProxyErrorCode) {
|
|
109
|
+
/** Authority does not have permission for this action */
|
|
110
|
+
SolanaAlignedProxyErrorCode["Unauthorized"] = "Unauthorized";
|
|
111
|
+
/** Arithmetic error */
|
|
112
|
+
SolanaAlignedProxyErrorCode["ArithmeticError"] = "ArithmeticError";
|
|
113
|
+
/** Mint has unsupported Token Extensions */
|
|
114
|
+
SolanaAlignedProxyErrorCode["UnsupportedTokenExtensions"] = "UnsupportedTokenExtensions";
|
|
115
|
+
/** Provided period is too short, should be equal or more than 30 seconds */
|
|
116
|
+
SolanaAlignedProxyErrorCode["PeriodTooShort"] = "PeriodTooShort";
|
|
117
|
+
/** Provided percentage tick size is invalid */
|
|
118
|
+
SolanaAlignedProxyErrorCode["InvalidTickSize"] = "InvalidTickSize";
|
|
119
|
+
/** Provided percentage bounds are invalid */
|
|
120
|
+
SolanaAlignedProxyErrorCode["InvalidPercentageBoundaries"] = "InvalidPercentageBoundaries";
|
|
121
|
+
/** Provided price bounds are invalid */
|
|
122
|
+
SolanaAlignedProxyErrorCode["InvalidPriceBoundaries"] = "InvalidPriceBoundaries";
|
|
123
|
+
/** Unsupported price oracle */
|
|
124
|
+
SolanaAlignedProxyErrorCode["UnsupportedOracle"] = "UnsupportedOracle";
|
|
125
|
+
/** Invalid oracle account */
|
|
126
|
+
SolanaAlignedProxyErrorCode["InvalidOracleAccount"] = "InvalidOracleAccount";
|
|
127
|
+
/** Invalid oracle price */
|
|
128
|
+
SolanaAlignedProxyErrorCode["InvalidOraclePrice"] = "InvalidOraclePrice";
|
|
129
|
+
/** Invalid Stream Metadata */
|
|
130
|
+
SolanaAlignedProxyErrorCode["InvalidStreamMetadata"] = "InvalidStreamMetadata";
|
|
131
|
+
/** Release amount has already been updated in this period */
|
|
132
|
+
SolanaAlignedProxyErrorCode["AmountAlreadyUpdated"] = "AmountAlreadyUpdated";
|
|
133
|
+
/** All funds are already unlocked */
|
|
134
|
+
SolanaAlignedProxyErrorCode["AllFundsUnlocked"] = "AllFundsUnlocked";
|
|
135
|
+
})(SolanaAlignedProxyErrorCode || (SolanaAlignedProxyErrorCode = {}));
|
package/dist/esm/evm/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BN from "bn.js";
|
|
2
2
|
import { BigNumber as BigNumberEvm } from "ethers";
|
|
3
|
-
import {
|
|
3
|
+
import { LinearStream, StreamType } from "../common/types.js";
|
|
4
4
|
export interface StreamAbiResult {
|
|
5
5
|
amount: BigNumberEvm;
|
|
6
6
|
amount_per_period: BigNumberEvm;
|
|
@@ -48,7 +48,7 @@ export interface FeesAbiResult {
|
|
|
48
48
|
streamflow_fee: BigNumberEvm;
|
|
49
49
|
partner_fee: BigNumberEvm;
|
|
50
50
|
}
|
|
51
|
-
export declare class EvmContract implements
|
|
51
|
+
export declare class EvmContract implements LinearStream {
|
|
52
52
|
magic: number;
|
|
53
53
|
version: number;
|
|
54
54
|
createdAt: number;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import PQueue from "p-queue";
|
|
2
2
|
import { Connection, Keypair, PublicKey, TransactionInstruction, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
3
3
|
import { IProgramAccount } from "@streamflow/common/solana";
|
|
4
|
-
import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt, ISearchStreams } from "./types.js";
|
|
5
|
-
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types.js";
|
|
4
|
+
import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt, ISearchStreams, ICreateStreamInstructions } from "./types.js";
|
|
5
|
+
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream, ICreateAlignedStreamData } from "../common/types.js";
|
|
6
6
|
import { BaseStreamClient } from "../common/BaseStreamClient.js";
|
|
7
7
|
export declare class SolanaStreamClient extends BaseStreamClient {
|
|
8
8
|
private connection;
|
|
9
9
|
private programId;
|
|
10
10
|
private commitment;
|
|
11
11
|
private sendThrottler;
|
|
12
|
+
private alignedProxyProgram;
|
|
12
13
|
/**
|
|
13
14
|
* Create Stream instance
|
|
14
15
|
*/
|
|
@@ -21,15 +22,13 @@ export declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
21
22
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
22
23
|
*/
|
|
23
24
|
create(data: ICreateStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateResult>;
|
|
25
|
+
prepareCreateInstructions(streamParams: ICreateStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
|
|
26
|
+
prepareCreateAlignedUnlockInstructions(streamParams: ICreateAlignedStreamData, extParams: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
|
|
24
27
|
/**
|
|
25
28
|
* Creates a new stream/vesting contract.
|
|
26
29
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
27
30
|
*/
|
|
28
|
-
|
|
29
|
-
ixs: TransactionInstruction[];
|
|
30
|
-
metadata: Keypair | undefined;
|
|
31
|
-
metadataPubKey: PublicKey;
|
|
32
|
-
}>;
|
|
31
|
+
prepareCreateStreamInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: ICreateStreamSolanaExt): Promise<ICreateStreamInstructions>;
|
|
33
32
|
/**
|
|
34
33
|
* Creates a new stream/vesting contract using unchecked instruction.
|
|
35
34
|
*
|
|
@@ -53,7 +52,7 @@ export declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
53
52
|
* Creates multiple stream/vesting contracts.
|
|
54
53
|
* All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
|
|
55
54
|
*/
|
|
56
|
-
createMultiple(data: ICreateMultipleStreamData,
|
|
55
|
+
createMultiple(data: ICreateMultipleStreamData, extParams: ICreateStreamSolanaExt): Promise<IMultiTransactionResult>;
|
|
57
56
|
/**
|
|
58
57
|
* Attempts withdrawing from the specified stream.
|
|
59
58
|
*/
|
|
@@ -65,11 +64,13 @@ export declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
65
64
|
/**
|
|
66
65
|
* Attempts canceling the specified stream.
|
|
67
66
|
*/
|
|
68
|
-
cancel(
|
|
67
|
+
cancel(cancelData: ICancelData, extParams: IInteractStreamSolanaExt): Promise<ITransactionResult>;
|
|
68
|
+
prepareCancelInstructions(cancelData: ICancelData, extParams: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
|
|
69
|
+
prepareCancelAlignedUnlockInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
|
|
69
70
|
/**
|
|
70
71
|
* Creates Transaction Instructions for cancel
|
|
71
72
|
*/
|
|
72
|
-
|
|
73
|
+
prepareCancelStreamInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IInteractStreamSolanaExt): Promise<TransactionInstruction[]>;
|
|
73
74
|
/**
|
|
74
75
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
75
76
|
* Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
|
|
@@ -92,6 +93,11 @@ export declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
92
93
|
* Fetch stream data by its id (address).
|
|
93
94
|
*/
|
|
94
95
|
getOne({ id }: IGetOneData): Promise<Stream>;
|
|
96
|
+
/**
|
|
97
|
+
* Fetch all aligned outgoing streams/contracts by the provided public key.
|
|
98
|
+
*/
|
|
99
|
+
private getOutgoingAlignedStreams;
|
|
100
|
+
private getIncomingAlignedStreams;
|
|
95
101
|
/**
|
|
96
102
|
* Fetch streams/contracts by providing direction.
|
|
97
103
|
* Streams are sorted by start time in ascending order.
|
|
@@ -109,14 +115,14 @@ export declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
109
115
|
getFees({ address }: IGetFeesData): Promise<IFees | null>;
|
|
110
116
|
getDefaultStreamflowFee(): Promise<number>;
|
|
111
117
|
extractErrorCode(err: Error): string | null;
|
|
112
|
-
/**
|
|
113
|
-
* Forms instructions from params, creates a raw transaction and fetch recent blockhash.
|
|
114
|
-
*/
|
|
115
|
-
private prepareStreamInstructions;
|
|
116
118
|
/**
|
|
117
119
|
* Utility function to generate metadata for a Contract or return existing Pubkey
|
|
118
120
|
*/
|
|
119
121
|
private getOrCreateStreamMetadata;
|
|
122
|
+
/**
|
|
123
|
+
* Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
|
|
124
|
+
*/
|
|
125
|
+
private isAlignedUnlock;
|
|
120
126
|
/**
|
|
121
127
|
* Utility function that checks whether associated token accounts still exist and adds instructions to add them if not
|
|
122
128
|
*/
|