@streamflow/stream 7.4.10 → 7.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/contractUtils.js +10 -3
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/solana/StreamClient.js +4 -4
- package/dist/cjs/solana/types.js +3 -0
- package/dist/esm/common/contractUtils.d.ts +13 -0
- package/dist/esm/common/contractUtils.js +8 -2
- package/dist/esm/common/types.d.ts +4 -4
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/solana/StreamClient.js +4 -4
- package/dist/esm/solana/types.js +3 -0
- package/package.json +4 -4
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.decodeEndTime = exports.buildStreamType = exports.isTokenLock = exports.isCreateAlignedStreamData = exports.isAligned = exports.isVesting = exports.isPayment = exports.isCliffCloseToDepositedAmount = exports.calculateUnlockedAmount = void 0;
|
|
6
|
+
exports.decodeEndTime = exports.buildStreamType = exports.isTokenLock = exports.isDynamicLock = exports.isCreateAlignedStreamData = exports.isAligned = exports.isVesting = exports.isPayment = exports.isCliffCloseToDepositedAmount = exports.calculateUnlockedAmount = void 0;
|
|
7
7
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
8
8
|
const types_js_1 = require("./types.js");
|
|
9
9
|
const constants_js_1 = require("./constants.js");
|
|
@@ -30,7 +30,9 @@ const isPayment = (streamData) => {
|
|
|
30
30
|
};
|
|
31
31
|
exports.isPayment = isPayment;
|
|
32
32
|
const isVesting = (streamData) => {
|
|
33
|
-
return !streamData.canTopup &&
|
|
33
|
+
return (!streamData.canTopup &&
|
|
34
|
+
!(0, exports.isCliffCloseToDepositedAmount)(streamData) &&
|
|
35
|
+
!(0, exports.isDynamicLock)(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage));
|
|
34
36
|
};
|
|
35
37
|
exports.isVesting = isVesting;
|
|
36
38
|
const isAligned = (stream) => {
|
|
@@ -41,6 +43,10 @@ const isCreateAlignedStreamData = (obj) => {
|
|
|
41
43
|
return "minPrice" in obj && "maxPrice" in obj && "minPercentage" in obj && "maxPercentage" in obj;
|
|
42
44
|
};
|
|
43
45
|
exports.isCreateAlignedStreamData = isCreateAlignedStreamData;
|
|
46
|
+
const isDynamicLock = (minPrice, maxPrice, minPercentage, maxPercentage) => {
|
|
47
|
+
return (!!minPrice && !!maxPrice && minPrice > 0 && maxPrice - minPrice <= 1 && minPercentage === 0 && maxPercentage === 100);
|
|
48
|
+
};
|
|
49
|
+
exports.isDynamicLock = isDynamicLock;
|
|
44
50
|
const isTokenLock = (streamData) => {
|
|
45
51
|
return (!streamData.canTopup &&
|
|
46
52
|
!streamData.automaticWithdrawal &&
|
|
@@ -48,7 +54,8 @@ const isTokenLock = (streamData) => {
|
|
|
48
54
|
!streamData.cancelableByRecipient &&
|
|
49
55
|
!streamData.transferableBySender &&
|
|
50
56
|
!streamData.transferableByRecipient &&
|
|
51
|
-
(0, exports.isCliffCloseToDepositedAmount)(streamData)
|
|
57
|
+
((0, exports.isCliffCloseToDepositedAmount)(streamData) ||
|
|
58
|
+
(0, exports.isDynamicLock)(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage)));
|
|
52
59
|
};
|
|
53
60
|
exports.isTokenLock = isTokenLock;
|
|
54
61
|
const buildStreamType = (streamData) => {
|
package/dist/cjs/index.js
CHANGED
|
@@ -37,6 +37,7 @@ exports.StreamflowSui = __importStar(require("./sui/index.js"));
|
|
|
37
37
|
__exportStar(require("./common/types.js"), exports);
|
|
38
38
|
__exportStar(require("./common/utils.js"), exports);
|
|
39
39
|
__exportStar(require("./common/constants.js"), exports);
|
|
40
|
+
__exportStar(require("./solana/constants.js"), exports);
|
|
40
41
|
__exportStar(require("./common/contractUtils.js"), exports);
|
|
41
42
|
var GenericStreamClient_js_1 = require("./common/GenericStreamClient.js");
|
|
42
43
|
Object.defineProperty(exports, "GenericStreamClient", { enumerable: true, get: function () { return __importDefault(GenericStreamClient_js_1).default; } });
|
|
@@ -174,10 +174,10 @@ class SolanaStreamClient extends BaseStreamClient_js_1.BaseStreamClient {
|
|
|
174
174
|
canTopup,
|
|
175
175
|
oracleType: (!!oracleType ? { [oracleType]: {} } : { none: {} }),
|
|
176
176
|
streamName: streamNameArray,
|
|
177
|
-
minPrice: (0, common_1.getBN)(minPrice, constants_js_1.ALIGNED_PRECISION_FACTOR_POW),
|
|
178
|
-
maxPrice: (0, common_1.getBN)(maxPrice, constants_js_1.ALIGNED_PRECISION_FACTOR_POW),
|
|
179
|
-
minPercentage: (0, common_1.getBN)(minPercentage, constants_js_1.ALIGNED_PRECISION_FACTOR_POW),
|
|
180
|
-
maxPercentage: (0, common_1.getBN)(maxPercentage, constants_js_1.ALIGNED_PRECISION_FACTOR_POW),
|
|
177
|
+
minPrice: minPrice instanceof bn_js_1.default ? minPrice : (0, common_1.getBN)(minPrice, constants_js_1.ALIGNED_PRECISION_FACTOR_POW),
|
|
178
|
+
maxPrice: maxPrice instanceof bn_js_1.default ? maxPrice : (0, common_1.getBN)(maxPrice, constants_js_1.ALIGNED_PRECISION_FACTOR_POW),
|
|
179
|
+
minPercentage: minPercentage instanceof bn_js_1.default ? minPercentage : (0, common_1.getBN)(minPercentage, constants_js_1.ALIGNED_PRECISION_FACTOR_POW),
|
|
180
|
+
maxPercentage: maxPercentage instanceof bn_js_1.default ? maxPercentage : (0, common_1.getBN)(maxPercentage, constants_js_1.ALIGNED_PRECISION_FACTOR_POW),
|
|
181
181
|
tickSize: new bn_js_1.default(tickSize || 1),
|
|
182
182
|
skipInitial: skipInitial ?? false,
|
|
183
183
|
})
|
package/dist/cjs/solana/types.js
CHANGED
|
@@ -80,6 +80,9 @@ class AlignedContract extends Contract {
|
|
|
80
80
|
this.sender = alignedProxy.sender.toBase58();
|
|
81
81
|
this.canceledAt = alignedProxy.streamCanceledTime.toNumber();
|
|
82
82
|
this.proxyAddress = stream.sender.toBase58();
|
|
83
|
+
// need to call this again since minPrice and maxPrice are used in determining the type
|
|
84
|
+
this.type = (0, contractUtils_js_1.buildStreamType)(this);
|
|
85
|
+
this.isAligned = true;
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
exports.AlignedContract = AlignedContract;
|
|
@@ -23,9 +23,14 @@ export declare const isVesting: (streamData: {
|
|
|
23
23
|
canTopup: boolean;
|
|
24
24
|
depositedAmount: BN;
|
|
25
25
|
cliffAmount: BN;
|
|
26
|
+
minPrice?: number;
|
|
27
|
+
maxPrice?: number;
|
|
28
|
+
minPercentage?: number;
|
|
29
|
+
maxPercentage?: number;
|
|
26
30
|
}) => boolean;
|
|
27
31
|
export declare const isAligned: (stream: Stream) => stream is AlignedStream;
|
|
28
32
|
export declare const isCreateAlignedStreamData: (obj: ICreateStreamData) => obj is ICreateAlignedStreamData;
|
|
33
|
+
export declare const isDynamicLock: (minPrice?: number, maxPrice?: number, minPercentage?: number, maxPercentage?: number) => boolean;
|
|
29
34
|
export declare const isTokenLock: (streamData: {
|
|
30
35
|
canTopup: boolean;
|
|
31
36
|
automaticWithdrawal: boolean;
|
|
@@ -35,6 +40,10 @@ export declare const isTokenLock: (streamData: {
|
|
|
35
40
|
transferableByRecipient: boolean;
|
|
36
41
|
depositedAmount: BN;
|
|
37
42
|
cliffAmount: BN;
|
|
43
|
+
minPrice?: number;
|
|
44
|
+
maxPrice?: number;
|
|
45
|
+
minPercentage?: number;
|
|
46
|
+
maxPercentage?: number;
|
|
38
47
|
}) => boolean;
|
|
39
48
|
export declare const buildStreamType: (streamData: {
|
|
40
49
|
canTopup: boolean;
|
|
@@ -45,6 +54,10 @@ export declare const buildStreamType: (streamData: {
|
|
|
45
54
|
transferableByRecipient: boolean;
|
|
46
55
|
depositedAmount: BN;
|
|
47
56
|
cliffAmount: BN;
|
|
57
|
+
minPrice?: number;
|
|
58
|
+
maxPrice?: number;
|
|
59
|
+
minPercentage?: number;
|
|
60
|
+
maxPercentage?: number;
|
|
48
61
|
}) => StreamType;
|
|
49
62
|
export declare const decodeEndTime: (endTime: BN) => number;
|
|
50
63
|
export {};
|
|
@@ -21,7 +21,9 @@ export const isPayment = (streamData) => {
|
|
|
21
21
|
return streamData.canTopup;
|
|
22
22
|
};
|
|
23
23
|
export const isVesting = (streamData) => {
|
|
24
|
-
return !streamData.canTopup &&
|
|
24
|
+
return (!streamData.canTopup &&
|
|
25
|
+
!isCliffCloseToDepositedAmount(streamData) &&
|
|
26
|
+
!isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage));
|
|
25
27
|
};
|
|
26
28
|
export const isAligned = (stream) => {
|
|
27
29
|
return "minPrice" in stream && "maxPrice" in stream && "minPercentage" in stream && "maxPercentage" in stream;
|
|
@@ -29,6 +31,9 @@ export const isAligned = (stream) => {
|
|
|
29
31
|
export const isCreateAlignedStreamData = (obj) => {
|
|
30
32
|
return "minPrice" in obj && "maxPrice" in obj && "minPercentage" in obj && "maxPercentage" in obj;
|
|
31
33
|
};
|
|
34
|
+
export const isDynamicLock = (minPrice, maxPrice, minPercentage, maxPercentage) => {
|
|
35
|
+
return (!!minPrice && !!maxPrice && minPrice > 0 && maxPrice - minPrice <= 1 && minPercentage === 0 && maxPercentage === 100);
|
|
36
|
+
};
|
|
32
37
|
export const isTokenLock = (streamData) => {
|
|
33
38
|
return (!streamData.canTopup &&
|
|
34
39
|
!streamData.automaticWithdrawal &&
|
|
@@ -36,7 +41,8 @@ export const isTokenLock = (streamData) => {
|
|
|
36
41
|
!streamData.cancelableByRecipient &&
|
|
37
42
|
!streamData.transferableBySender &&
|
|
38
43
|
!streamData.transferableByRecipient &&
|
|
39
|
-
isCliffCloseToDepositedAmount(streamData)
|
|
44
|
+
(isCliffCloseToDepositedAmount(streamData) ||
|
|
45
|
+
isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage)));
|
|
40
46
|
};
|
|
41
47
|
export const buildStreamType = (streamData) => {
|
|
42
48
|
if (isVesting(streamData)) {
|
|
@@ -32,10 +32,10 @@ export interface IBaseStreamConfig {
|
|
|
32
32
|
tokenProgramId?: string | PublicKey;
|
|
33
33
|
}
|
|
34
34
|
export type IAlignedStreamConfig = {
|
|
35
|
-
minPrice: number;
|
|
36
|
-
maxPrice: number;
|
|
37
|
-
minPercentage: number;
|
|
38
|
-
maxPercentage: number;
|
|
35
|
+
minPrice: number | BN;
|
|
36
|
+
maxPrice: number | BN;
|
|
37
|
+
minPercentage: number | BN;
|
|
38
|
+
maxPercentage: number | BN;
|
|
39
39
|
oracleType?: OracleTypeName;
|
|
40
40
|
priceOracle?: Address;
|
|
41
41
|
skipInitial?: boolean;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export * as StreamflowSui from "./sui/index.js";
|
|
|
5
5
|
export * from "./common/types.js";
|
|
6
6
|
export * from "./common/utils.js";
|
|
7
7
|
export * from "./common/constants.js";
|
|
8
|
+
export * from "./solana/constants.js";
|
|
8
9
|
export * from "./common/contractUtils.js";
|
|
9
10
|
export { default as GenericStreamClient } from "./common/GenericStreamClient.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -5,5 +5,6 @@ export * as StreamflowSui from "./sui/index.js";
|
|
|
5
5
|
export * from "./common/types.js";
|
|
6
6
|
export * from "./common/utils.js";
|
|
7
7
|
export * from "./common/constants.js";
|
|
8
|
+
export * from "./solana/constants.js";
|
|
8
9
|
export * from "./common/contractUtils.js";
|
|
9
10
|
export { default as GenericStreamClient } from "./common/GenericStreamClient.js";
|
|
@@ -150,10 +150,10 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
150
150
|
canTopup,
|
|
151
151
|
oracleType: (!!oracleType ? { [oracleType]: {} } : { none: {} }),
|
|
152
152
|
streamName: streamNameArray,
|
|
153
|
-
minPrice: getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW),
|
|
154
|
-
maxPrice: getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW),
|
|
155
|
-
minPercentage: getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW),
|
|
156
|
-
maxPercentage: getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
|
|
153
|
+
minPrice: minPrice instanceof BN ? minPrice : getBN(minPrice, ALIGNED_PRECISION_FACTOR_POW),
|
|
154
|
+
maxPrice: maxPrice instanceof BN ? maxPrice : getBN(maxPrice, ALIGNED_PRECISION_FACTOR_POW),
|
|
155
|
+
minPercentage: minPercentage instanceof BN ? minPercentage : getBN(minPercentage, ALIGNED_PRECISION_FACTOR_POW),
|
|
156
|
+
maxPercentage: maxPercentage instanceof BN ? maxPercentage : getBN(maxPercentage, ALIGNED_PRECISION_FACTOR_POW),
|
|
157
157
|
tickSize: new BN(tickSize || 1),
|
|
158
158
|
skipInitial: skipInitial ?? false,
|
|
159
159
|
})
|
package/dist/esm/solana/types.js
CHANGED
|
@@ -125,5 +125,8 @@ export class AlignedContract extends Contract {
|
|
|
125
125
|
this.sender = alignedProxy.sender.toBase58();
|
|
126
126
|
this.canceledAt = alignedProxy.streamCanceledTime.toNumber();
|
|
127
127
|
this.proxyAddress = stream.sender.toBase58();
|
|
128
|
+
// need to call this again since minPrice and maxPrice are used in determining the type
|
|
129
|
+
this.type = buildStreamType(this);
|
|
130
|
+
this.isAligned = true;
|
|
128
131
|
}
|
|
129
132
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.12",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"lint": "eslint --fix .",
|
|
43
43
|
"prepublishOnly": "pnpm run lint && pnpm run test run && pnpm run build"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "dd0616c525178e41474e627a3ab9f5d18a4a6676",
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@streamflow/eslint-config": "7.4.
|
|
47
|
+
"@streamflow/eslint-config": "7.4.12",
|
|
48
48
|
"@types/bn.js": "5.1.1",
|
|
49
49
|
"@types/ethereum-checksum-address": "^0.0.0",
|
|
50
50
|
"date-fns": "2.28.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@solana/spl-token": "0.4.9",
|
|
60
60
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
61
61
|
"@solana/web3.js": "1.95.4",
|
|
62
|
-
"@streamflow/common": "7.4.
|
|
62
|
+
"@streamflow/common": "7.4.12",
|
|
63
63
|
"@suiet/wallet-kit": "^0.3.3",
|
|
64
64
|
"aptos": "1.21.0",
|
|
65
65
|
"bn.js": "5.2.1",
|