@streamflow/stream 4.1.0-beta.12 → 4.1.0-beta.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/dist/aptos/types.d.ts +6 -0
- package/dist/aptos/types.js +7 -7
- package/dist/common/contractUtils.d.ts +2 -0
- package/dist/common/contractUtils.js +21 -0
- package/dist/evm/types.d.ts +7 -0
- package/dist/evm/types.js +7 -7
- package/dist/solana/constants.d.ts +1 -0
- package/dist/solana/constants.js +3 -1
- package/dist/solana/instructionTypes.d.ts +10 -0
- package/dist/solana/layout.js +12 -0
- package/dist/solana/types.d.ts +15 -0
- package/dist/solana/types.js +7 -11
- package/dist/solana/utils.js +10 -0
- package/package.json +1 -1
package/dist/aptos/types.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export interface StreamResource {
|
|
|
37
37
|
transferable_by_recipient: boolean;
|
|
38
38
|
transferable_by_sender: boolean;
|
|
39
39
|
withdrawal_frequency: string;
|
|
40
|
+
closed: boolean;
|
|
40
41
|
};
|
|
41
42
|
pause_cumulative: string;
|
|
42
43
|
period: string;
|
|
@@ -123,6 +124,11 @@ export declare class Contract implements Stream {
|
|
|
123
124
|
canTopup: boolean;
|
|
124
125
|
name: string;
|
|
125
126
|
withdrawalFrequency: number;
|
|
127
|
+
closed: boolean;
|
|
128
|
+
currentPauseStart: number;
|
|
129
|
+
pauseCumulative: BN;
|
|
130
|
+
lastRateChangeTime: number;
|
|
131
|
+
fundsUnlockedAtLastRateChange: BN;
|
|
126
132
|
constructor(stream: StreamResource, tokenId: string);
|
|
127
133
|
unlocked(currentTimestamp: number): BN;
|
|
128
134
|
remaining(decimals: number): number;
|
package/dist/aptos/types.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Contract = void 0;
|
|
7
7
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
8
|
var utils_1 = require("../common/utils");
|
|
9
|
+
var contractUtils_1 = require("../common/contractUtils");
|
|
9
10
|
var Contract = /** @class */ (function () {
|
|
10
11
|
function Contract(stream, tokenId) {
|
|
11
12
|
this.magic = 0;
|
|
@@ -46,15 +47,14 @@ var Contract = /** @class */ (function () {
|
|
|
46
47
|
var name = stream.meta.contract_name.replace("0x", "");
|
|
47
48
|
this.name = Buffer.from(name, "hex").toString("utf8");
|
|
48
49
|
this.withdrawalFrequency = parseInt(stream.meta.withdrawal_frequency);
|
|
50
|
+
this.closed = stream.meta.closed;
|
|
51
|
+
this.currentPauseStart = parseInt(stream.current_pause_start);
|
|
52
|
+
this.pauseCumulative = new bn_js_1.default(stream.pause_cumulative);
|
|
53
|
+
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
54
|
+
this.fundsUnlockedAtLastRateChange = new bn_js_1.default(stream.funds_unlocked_at_last_rate_change);
|
|
49
55
|
}
|
|
50
56
|
Contract.prototype.unlocked = function (currentTimestamp) {
|
|
51
|
-
|
|
52
|
-
if (currentTimestamp < this.cliff)
|
|
53
|
-
return new bn_js_1.default(0);
|
|
54
|
-
if (currentTimestamp > this.end)
|
|
55
|
-
return deposited;
|
|
56
|
-
var streamed = this.cliffAmount.add(new bn_js_1.default(Math.floor((currentTimestamp - this.cliff) / this.period)).mul(this.amountPerPeriod));
|
|
57
|
-
return streamed.lt(deposited) ? streamed : deposited;
|
|
57
|
+
return (0, contractUtils_1.calculateUnlocked)(this.depositedAmount, this.cliff, this.cliffAmount, this.end, currentTimestamp, this.lastRateChangeTime, this.period, this.amountPerPeriod, this.fundsUnlockedAtLastRateChange);
|
|
58
58
|
};
|
|
59
59
|
Contract.prototype.remaining = function (decimals) {
|
|
60
60
|
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.calculateUnlocked = void 0;
|
|
7
|
+
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
+
var calculateUnlocked = function (depositedAmount, cliff, cliffAmount, end, currentTimestamp, lastRateChangeTime, period, amountPerPeriod, fundsUnlockedAtLastRateChange) {
|
|
9
|
+
var deposited = depositedAmount;
|
|
10
|
+
if (currentTimestamp < cliff)
|
|
11
|
+
return new bn_js_1.default(0);
|
|
12
|
+
if (currentTimestamp > end)
|
|
13
|
+
return deposited;
|
|
14
|
+
var savedUnlockedFunds = lastRateChangeTime === 0 ? cliffAmount : fundsUnlockedAtLastRateChange;
|
|
15
|
+
var savedUnlockedFundsTime = lastRateChangeTime === 0 ? cliff : lastRateChangeTime;
|
|
16
|
+
var streamed = new bn_js_1.default(Math.floor((currentTimestamp - savedUnlockedFundsTime) / period))
|
|
17
|
+
.mul(amountPerPeriod)
|
|
18
|
+
.add(savedUnlockedFunds);
|
|
19
|
+
return streamed.lt(deposited) ? streamed : deposited;
|
|
20
|
+
};
|
|
21
|
+
exports.calculateUnlocked = calculateUnlocked;
|
package/dist/evm/types.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface StreamAbiResult {
|
|
|
32
32
|
transferable_by_recipient: boolean;
|
|
33
33
|
transferable_by_sender: boolean;
|
|
34
34
|
withdrawal_frequency: BigNumber;
|
|
35
|
+
closed: boolean;
|
|
35
36
|
};
|
|
36
37
|
pause_cumulative: BigNumber;
|
|
37
38
|
period: BigNumber;
|
|
@@ -41,6 +42,7 @@ export interface StreamAbiResult {
|
|
|
41
42
|
start: BigNumber;
|
|
42
43
|
token: string;
|
|
43
44
|
withdrawn: BigNumber;
|
|
45
|
+
unlocked(currentTimestamp: number): BN;
|
|
44
46
|
}
|
|
45
47
|
export interface Stream {
|
|
46
48
|
magic: number;
|
|
@@ -120,6 +122,11 @@ export declare class EvmContract implements Stream {
|
|
|
120
122
|
canTopup: boolean;
|
|
121
123
|
name: string;
|
|
122
124
|
withdrawalFrequency: number;
|
|
125
|
+
closed: boolean;
|
|
126
|
+
currentPauseStart: number;
|
|
127
|
+
pauseCumulative: BN;
|
|
128
|
+
lastRateChangeTime: number;
|
|
129
|
+
fundsUnlockedAtLastRateChange: BN;
|
|
123
130
|
constructor(stream: StreamAbiResult);
|
|
124
131
|
unlocked(currentTimestamp: number): BN;
|
|
125
132
|
remaining(decimals: number): number;
|
package/dist/evm/types.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.EvmContract = void 0;
|
|
7
7
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
8
|
var utils_1 = require("../common/utils");
|
|
9
|
+
var contractUtils_1 = require("../common/contractUtils");
|
|
9
10
|
var EvmContract = /** @class */ (function () {
|
|
10
11
|
function EvmContract(stream) {
|
|
11
12
|
this.magic = 0;
|
|
@@ -45,15 +46,14 @@ var EvmContract = /** @class */ (function () {
|
|
|
45
46
|
this.canTopup = stream.meta.can_topup;
|
|
46
47
|
this.name = stream.meta.contract_name;
|
|
47
48
|
this.withdrawalFrequency = stream.meta.withdrawal_frequency.toNumber();
|
|
49
|
+
this.closed = stream.meta.closed;
|
|
50
|
+
this.currentPauseStart = stream.current_pause_start.toNumber();
|
|
51
|
+
this.pauseCumulative = new bn_js_1.default(stream.pause_cumulative.toString());
|
|
52
|
+
this.lastRateChangeTime = stream.last_rate_change_time.toNumber();
|
|
53
|
+
this.fundsUnlockedAtLastRateChange = new bn_js_1.default(stream.funds_unlocked_at_last_rate_change.toString());
|
|
48
54
|
}
|
|
49
55
|
EvmContract.prototype.unlocked = function (currentTimestamp) {
|
|
50
|
-
|
|
51
|
-
if (currentTimestamp < this.cliff)
|
|
52
|
-
return new bn_js_1.default(0);
|
|
53
|
-
if (currentTimestamp > this.end)
|
|
54
|
-
return deposited;
|
|
55
|
-
var streamed = this.cliffAmount.add(new bn_js_1.default(Math.floor((currentTimestamp - this.cliff) / this.period)).mul(this.amountPerPeriod));
|
|
56
|
-
return streamed.lt(deposited) ? streamed : deposited;
|
|
56
|
+
return (0, contractUtils_1.calculateUnlocked)(this.depositedAmount, this.cliff, this.cliffAmount, this.end, currentTimestamp, this.lastRateChangeTime, this.period, this.amountPerPeriod, this.fundsUnlockedAtLastRateChange);
|
|
57
57
|
};
|
|
58
58
|
EvmContract.prototype.remaining = function (decimals) {
|
|
59
59
|
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
|
@@ -2,6 +2,7 @@ import { PublicKey } from "@solana/web3.js";
|
|
|
2
2
|
export declare const TX_FINALITY_CONFIRMED = "confirmed";
|
|
3
3
|
export declare const STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
4
4
|
export declare const STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
5
|
+
export declare const CREATE_PARAMS_PADDING = 126;
|
|
5
6
|
export declare const PROGRAM_ID: {
|
|
6
7
|
devnet: string;
|
|
7
8
|
mainnet: string;
|
package/dist/solana/constants.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.BASE_FEE = exports.AIRDROP_AMOUNT = exports.AIRDROP_TEST_TOKEN = exports.FEE_ORACLE_PUBLIC_KEY = exports.WITHDRAWOR_PUBLIC_KEY = exports.STREAMFLOW_TREASURY_PUBLIC_KEY = exports.STREAMFLOW_DEVNET_PROGRAM_ID = exports.STREAMFLOW_PROGRAM_ID = exports.PROGRAM_ID = exports.STREAM_STRUCT_OFFSET_RECIPIENT = exports.STREAM_STRUCT_OFFSET_SENDER = exports.TX_FINALITY_CONFIRMED = void 0;
|
|
4
|
+
exports.BASE_FEE = exports.AIRDROP_AMOUNT = exports.AIRDROP_TEST_TOKEN = exports.FEE_ORACLE_PUBLIC_KEY = exports.WITHDRAWOR_PUBLIC_KEY = exports.STREAMFLOW_TREASURY_PUBLIC_KEY = exports.STREAMFLOW_DEVNET_PROGRAM_ID = exports.STREAMFLOW_PROGRAM_ID = exports.PROGRAM_ID = exports.CREATE_PARAMS_PADDING = exports.STREAM_STRUCT_OFFSET_RECIPIENT = exports.STREAM_STRUCT_OFFSET_SENDER = exports.TX_FINALITY_CONFIRMED = void 0;
|
|
5
5
|
var web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
var types_1 = require("../common/types");
|
|
7
7
|
exports.TX_FINALITY_CONFIRMED = "confirmed";
|
|
8
8
|
exports.STREAM_STRUCT_OFFSET_SENDER = 49;
|
|
9
9
|
exports.STREAM_STRUCT_OFFSET_RECIPIENT = 113;
|
|
10
|
+
// Defined: https://github.com/streamflow-finance/protocol/blob/main/programs/protocol/src/state.rs#L25
|
|
11
|
+
exports.CREATE_PARAMS_PADDING = 126;
|
|
10
12
|
exports.PROGRAM_ID = (_a = {},
|
|
11
13
|
_a[types_1.ICluster.Devnet] = "HqDGZjaVRXJ9MGRQEw7qDc2rAr6iH1n1kAQdCZaCMfMZ",
|
|
12
14
|
_a[types_1.ICluster.Mainnet] = "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m",
|
|
@@ -36,6 +36,16 @@ export interface IStreamLayout {
|
|
|
36
36
|
can_topup: number;
|
|
37
37
|
stream_name: Uint8Array;
|
|
38
38
|
withdraw_frequency: Uint8Array;
|
|
39
|
+
ghost: Uint8Array;
|
|
40
|
+
pausable: number;
|
|
41
|
+
can_update_rate: number;
|
|
42
|
+
create_params_padding_length: number;
|
|
43
|
+
create_params_padding: number[];
|
|
44
|
+
closed: number;
|
|
45
|
+
current_pause_start: Uint8Array;
|
|
46
|
+
pause_cumulative: Uint8Array;
|
|
47
|
+
last_rate_change_time: Uint8Array;
|
|
48
|
+
funds_unlocked_at_last_rate_change: Uint8Array;
|
|
39
49
|
}
|
|
40
50
|
export interface ICreateStreamLayout {
|
|
41
51
|
start_time: Uint8Array;
|
package/dist/solana/layout.js
CHANGED
|
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.topupStreamLayout = exports.encodeUpdateStream = exports.withdrawStreamLayout = exports.createUncheckedStreamLayout = exports.createStreamLayout = exports.streamLayout = void 0;
|
|
27
27
|
var BufferLayout = __importStar(require("@solana/buffer-layout"));
|
|
28
|
+
var constants_1 = require("./constants");
|
|
28
29
|
/**
|
|
29
30
|
* Stream layout
|
|
30
31
|
*/
|
|
@@ -66,6 +67,17 @@ exports.streamLayout = BufferLayout.struct([
|
|
|
66
67
|
BufferLayout.u8("can_topup"),
|
|
67
68
|
BufferLayout.blob(64, "stream_name"),
|
|
68
69
|
BufferLayout.blob(8, "withdraw_frequency"),
|
|
70
|
+
// Unused, kept for backward compatibility™
|
|
71
|
+
BufferLayout.blob(4, "ghost"),
|
|
72
|
+
BufferLayout.u8("pausable"),
|
|
73
|
+
BufferLayout.u8("can_update_rate"),
|
|
74
|
+
BufferLayout.blob(4, "create_stream_params_padding_length"),
|
|
75
|
+
BufferLayout.seq(BufferLayout.u8(), constants_1.CREATE_PARAMS_PADDING, "create_params_padding"),
|
|
76
|
+
BufferLayout.u8("closed"),
|
|
77
|
+
BufferLayout.blob(8, "current_pause_start"),
|
|
78
|
+
BufferLayout.blob(8, "pause_cumulative"),
|
|
79
|
+
BufferLayout.blob(8, "last_rate_change_time"),
|
|
80
|
+
BufferLayout.blob(8, "funds_unlocked_at_last_rate_change"),
|
|
69
81
|
]);
|
|
70
82
|
/**
|
|
71
83
|
* Create stream instruction layout
|
package/dist/solana/types.d.ts
CHANGED
|
@@ -171,6 +171,11 @@ export interface Stream {
|
|
|
171
171
|
canTopup: boolean;
|
|
172
172
|
name: string;
|
|
173
173
|
withdrawalFrequency: number;
|
|
174
|
+
closed: boolean;
|
|
175
|
+
currentPauseStart: number;
|
|
176
|
+
pauseCumulative: BN;
|
|
177
|
+
lastRateChangeTime: number;
|
|
178
|
+
fundsUnlockedAtLastRateChange: BN;
|
|
174
179
|
unlocked(currentTimestamp: number): BN;
|
|
175
180
|
}
|
|
176
181
|
export declare class Contract implements Stream {
|
|
@@ -211,6 +216,11 @@ export declare class Contract implements Stream {
|
|
|
211
216
|
canTopup: boolean;
|
|
212
217
|
name: string;
|
|
213
218
|
withdrawalFrequency: number;
|
|
219
|
+
closed: boolean;
|
|
220
|
+
currentPauseStart: number;
|
|
221
|
+
pauseCumulative: BN;
|
|
222
|
+
lastRateChangeTime: number;
|
|
223
|
+
fundsUnlockedAtLastRateChange: BN;
|
|
214
224
|
constructor(stream: DecodedStream);
|
|
215
225
|
unlocked(currentTimestamp: number): BN;
|
|
216
226
|
remaining(decimals: number): number;
|
|
@@ -253,6 +263,11 @@ export interface DecodedStream {
|
|
|
253
263
|
canTopup: boolean;
|
|
254
264
|
name: string;
|
|
255
265
|
withdrawFrequency: BN;
|
|
266
|
+
closed: boolean;
|
|
267
|
+
currentPauseStart: BN;
|
|
268
|
+
pauseCumulative: BN;
|
|
269
|
+
lastRateChangeTime: BN;
|
|
270
|
+
fundsUnlockedAtLastRateChange: BN;
|
|
256
271
|
}
|
|
257
272
|
export interface TransactionResponse {
|
|
258
273
|
tx: TransactionSignature;
|
package/dist/solana/types.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.TransferCancelOptions = exports.Contract = exports.Cluster = void 0;
|
|
7
|
-
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
4
|
var utils_1 = require("../common/utils");
|
|
5
|
+
var contractUtils_1 = require("../common/contractUtils");
|
|
9
6
|
var wallet_adapter_base_1 = require("@solana/wallet-adapter-base");
|
|
10
7
|
Object.defineProperty(exports, "Cluster", { enumerable: true, get: function () { return wallet_adapter_base_1.WalletAdapterNetwork; } });
|
|
11
8
|
var Contract = /** @class */ (function () {
|
|
@@ -48,15 +45,14 @@ var Contract = /** @class */ (function () {
|
|
|
48
45
|
this.canTopup = stream.canTopup;
|
|
49
46
|
this.name = stream.name;
|
|
50
47
|
this.withdrawalFrequency = stream.withdrawFrequency.toNumber();
|
|
48
|
+
this.closed = stream.closed;
|
|
49
|
+
this.currentPauseStart = stream.currentPauseStart.toNumber();
|
|
50
|
+
this.pauseCumulative = stream.pauseCumulative;
|
|
51
|
+
this.lastRateChangeTime = stream.lastRateChangeTime.toNumber();
|
|
52
|
+
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
51
53
|
}
|
|
52
54
|
Contract.prototype.unlocked = function (currentTimestamp) {
|
|
53
|
-
|
|
54
|
-
if (currentTimestamp < this.cliff)
|
|
55
|
-
return new bn_js_1.default(0);
|
|
56
|
-
if (currentTimestamp > this.end)
|
|
57
|
-
return deposited;
|
|
58
|
-
var streamed = this.cliffAmount.add(new bn_js_1.default(Math.floor((currentTimestamp - this.cliff) / this.period)).mul(this.amountPerPeriod));
|
|
59
|
-
return streamed.lt(deposited) ? streamed : deposited;
|
|
55
|
+
return (0, contractUtils_1.calculateUnlocked)(this.depositedAmount, this.cliff, this.cliffAmount, this.end, currentTimestamp, this.lastRateChangeTime, this.period, this.amountPerPeriod, this.fundsUnlockedAtLastRateChange);
|
|
60
56
|
};
|
|
61
57
|
Contract.prototype.remaining = function (decimals) {
|
|
62
58
|
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
package/dist/solana/utils.js
CHANGED
|
@@ -98,6 +98,11 @@ var decodeStream = function (buf) {
|
|
|
98
98
|
canTopup: Boolean(raw.can_topup),
|
|
99
99
|
name: decoder.decode(raw.stream_name),
|
|
100
100
|
withdrawFrequency: new bn_js_1.default(raw.withdraw_frequency, LE),
|
|
101
|
+
closed: Boolean(raw.closed),
|
|
102
|
+
currentPauseStart: new bn_js_1.default(raw.current_pause_start, LE),
|
|
103
|
+
pauseCumulative: new bn_js_1.default(raw.pause_cumulative, LE),
|
|
104
|
+
lastRateChangeTime: new bn_js_1.default(raw.last_rate_change_time, LE),
|
|
105
|
+
fundsUnlockedAtLastRateChange: new bn_js_1.default(raw.funds_unlocked_at_last_rate_change, LE),
|
|
101
106
|
};
|
|
102
107
|
};
|
|
103
108
|
exports.decodeStream = decodeStream;
|
|
@@ -143,6 +148,11 @@ var formatDecodedStream = function (stream) {
|
|
|
143
148
|
canTopup: stream.canTopup,
|
|
144
149
|
name: stream.name,
|
|
145
150
|
withdrawalFrequency: stream.withdrawFrequency.toNumber(),
|
|
151
|
+
closed: stream.closed,
|
|
152
|
+
currentPauseStart: stream.currentPauseStart.toNumber(),
|
|
153
|
+
pauseCumulative: stream.pauseCumulative,
|
|
154
|
+
lastRateChangeTime: stream.lastRateChangeTime.toNumber(),
|
|
155
|
+
fundsUnlockedAtLastRateChange: stream.fundsUnlockedAtLastRateChange,
|
|
146
156
|
unlocked: function () {
|
|
147
157
|
return new bn_js_1.default(0);
|
|
148
158
|
},
|
package/package.json
CHANGED