@streamflow/stream 7.4.11 → 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.
|
@@ -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/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)) {
|
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",
|