@streamflow/stream 5.0.0 → 5.1.0
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 +236 -126
- package/dist/aptos/types.d.ts +1 -45
- package/dist/aptos/types.js +12 -1
- package/dist/common/BaseStreamClient.d.ts +1 -2
- package/dist/common/GenericStreamClient.d.ts +16 -11
- package/dist/common/GenericStreamClient.js +14 -56
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +4 -0
- package/dist/common/contractUtils.d.ts +13 -1
- package/dist/common/contractUtils.js +2 -1
- package/dist/common/types.d.ts +45 -0
- package/dist/evm/StreamClient.d.ts +1 -2
- package/dist/evm/StreamClient.js +1 -1
- package/dist/evm/types.d.ts +1 -45
- package/dist/evm/types.js +12 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -2
- package/dist/solana/StreamClient.d.ts +4 -4
- package/dist/solana/constants.d.ts +0 -1
- package/dist/solana/constants.js +1 -2
- package/dist/solana/instructions.js +1 -1
- package/dist/solana/types.d.ts +1 -46
- package/dist/solana/types.js +12 -1
- package/dist/solana/utils.d.ts +2 -1
- package/dist/sui/StreamClient.d.ts +78 -0
- package/dist/sui/StreamClient.js +542 -0
- package/dist/sui/constants.d.ts +4 -0
- package/dist/sui/constants.js +23 -0
- package/dist/sui/index.d.ts +2 -0
- package/dist/sui/index.js +23 -0
- package/dist/sui/types.d.ts +137 -0
- package/dist/sui/types.js +163 -0
- package/package.json +4 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
2
2
|
import { Signer } from "ethers";
|
|
3
|
-
import SolanaStreamClient from "../solana/StreamClient";
|
|
4
|
-
import AptosStreamClient from "../aptos/StreamClient";
|
|
5
3
|
import { BaseStreamClient } from "./BaseStreamClient";
|
|
6
|
-
import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IUpdateData, IWithdrawData, ITransactionResult, IMultiTransactionResult, ICreateResult, IGetAllData } from "./types";
|
|
7
|
-
import {
|
|
8
|
-
import { ICreateStreamAptosExt, ITransactionAptosExt } from "../aptos";
|
|
4
|
+
import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateStreamData, IGetOneData, ITopUpData, ITransferData, IUpdateData, IWithdrawData, ITransactionResult, IMultiTransactionResult, ICreateResult, IGetAllData, Stream } from "./types";
|
|
5
|
+
import { AptosStreamClient, ICreateStreamAptosExt, ITransactionAptosExt } from "../aptos";
|
|
9
6
|
import { EvmStreamClient } from "../evm";
|
|
7
|
+
import { SolanaStreamClient, ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "../solana";
|
|
8
|
+
import { ICreateStreamSuiExt, ITransactionSuiExt, ISuiIdParameters, SuiStreamClient } from "../sui";
|
|
10
9
|
export interface SolanaStreamClientOptions {
|
|
11
10
|
chain: IChain.Solana;
|
|
12
11
|
clusterUrl: string;
|
|
@@ -28,12 +27,18 @@ export interface EvmStreamClientOptions {
|
|
|
28
27
|
cluster?: ICluster;
|
|
29
28
|
programId?: string;
|
|
30
29
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
export interface SuiStreamClientOptions {
|
|
31
|
+
chain: IChain.Sui;
|
|
32
|
+
clusterUrl: string;
|
|
33
|
+
cluster?: ICluster;
|
|
34
|
+
ids?: ISuiIdParameters;
|
|
35
|
+
}
|
|
36
|
+
declare type StreamClientOptions<T extends IChain> = T extends IChain.Solana ? SolanaStreamClientOptions : T extends IChain.Aptos ? AptosStreamClientOptions : T extends IChain.Sui ? SuiStreamClientOptions : EvmStreamClientOptions;
|
|
37
|
+
declare type StreamClientType<T extends IChain> = T extends IChain.Solana ? SolanaStreamClient : T extends IChain.Aptos ? AptosStreamClient : T extends IChain.Sui ? SuiStreamClient : EvmStreamClient;
|
|
38
|
+
declare type ChainSpecificParams<T, SolanaExt, AptosExt, SuiExt> = T extends SolanaStreamClient ? SolanaExt : T extends AptosStreamClient ? AptosExt : T extends SuiStreamClient ? SuiExt : undefined;
|
|
39
|
+
declare type CreateSpecificParams<T extends IChain> = ChainSpecificParams<StreamClientType<T>, ICreateStreamSolanaExt, ICreateStreamAptosExt, ICreateStreamSuiExt>;
|
|
40
|
+
declare type TopupSpecificParams<T extends IChain> = ChainSpecificParams<StreamClientType<T>, ITopUpStreamSolanaExt, ITransactionAptosExt, ITransactionSuiExt>;
|
|
41
|
+
declare type InteractSpecificParams<T extends IChain> = ChainSpecificParams<StreamClientType<T>, IInteractStreamSolanaExt, ITransactionAptosExt, ITransactionSuiExt>;
|
|
37
42
|
export default class GenericStreamClient<T extends IChain> extends BaseStreamClient {
|
|
38
43
|
nativeStreamClient: StreamClientType<T>;
|
|
39
44
|
chain: IChain;
|
|
@@ -14,15 +14,13 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
var StreamClient_1 = __importDefault(require("../solana/StreamClient"));
|
|
22
|
-
var StreamClient_2 = __importDefault(require("../aptos/StreamClient"));
|
|
23
18
|
var BaseStreamClient_1 = require("./BaseStreamClient");
|
|
24
19
|
var types_1 = require("./types");
|
|
20
|
+
var aptos_1 = require("../aptos");
|
|
25
21
|
var evm_1 = require("../evm");
|
|
22
|
+
var solana_1 = require("../solana");
|
|
23
|
+
var sui_1 = require("../sui");
|
|
26
24
|
var GenericStreamClient = /** @class */ (function (_super) {
|
|
27
25
|
__extends(GenericStreamClient, _super);
|
|
28
26
|
function GenericStreamClient(options) {
|
|
@@ -30,16 +28,18 @@ var GenericStreamClient = /** @class */ (function (_super) {
|
|
|
30
28
|
_this.chain = options.chain;
|
|
31
29
|
switch (options.chain) {
|
|
32
30
|
case types_1.IChain.Solana:
|
|
33
|
-
_this.nativeStreamClient = new
|
|
31
|
+
_this.nativeStreamClient = new solana_1.SolanaStreamClient(options.clusterUrl, options.cluster, options.commitment, options.programId);
|
|
34
32
|
break;
|
|
35
33
|
case types_1.IChain.Aptos:
|
|
36
|
-
_this.nativeStreamClient = new
|
|
34
|
+
_this.nativeStreamClient = new aptos_1.AptosStreamClient(options.clusterUrl, options.cluster, options.maxGas, options.programId);
|
|
37
35
|
break;
|
|
38
36
|
case types_1.IChain.BNB:
|
|
39
37
|
case types_1.IChain.Ethereum:
|
|
40
38
|
case types_1.IChain.Polygon:
|
|
41
39
|
_this.nativeStreamClient = new evm_1.EvmStreamClient(options.clusterUrl, options.chain, options.signer, options.cluster, options.programId);
|
|
42
40
|
break;
|
|
41
|
+
case types_1.IChain.Sui:
|
|
42
|
+
_this.nativeStreamClient = new sui_1.SuiStreamClient(options.clusterUrl, options.cluster, options.ids);
|
|
43
43
|
}
|
|
44
44
|
return _this;
|
|
45
45
|
}
|
|
@@ -47,73 +47,37 @@ var GenericStreamClient = /** @class */ (function (_super) {
|
|
|
47
47
|
* Creates a new stream/vesting contract.
|
|
48
48
|
*/
|
|
49
49
|
GenericStreamClient.prototype.create = function (streamData, chainSpecificParams) {
|
|
50
|
-
|
|
51
|
-
return this.nativeStreamClient.create(streamData, chainSpecificParams);
|
|
52
|
-
}
|
|
53
|
-
else if (this.nativeStreamClient instanceof StreamClient_2.default) {
|
|
54
|
-
return this.nativeStreamClient.create(streamData, chainSpecificParams);
|
|
55
|
-
}
|
|
56
|
-
return this.nativeStreamClient.create(streamData);
|
|
50
|
+
return this.nativeStreamClient.create(streamData, chainSpecificParams);
|
|
57
51
|
};
|
|
58
52
|
/**
|
|
59
53
|
* Creates multiple stream/vesting contracts.
|
|
60
54
|
*/
|
|
61
55
|
GenericStreamClient.prototype.createMultiple = function (multipleStreamData, chainSpecificParams) {
|
|
62
|
-
|
|
63
|
-
return this.nativeStreamClient.createMultiple(multipleStreamData, chainSpecificParams);
|
|
64
|
-
}
|
|
65
|
-
else if (this.nativeStreamClient instanceof StreamClient_2.default) {
|
|
66
|
-
return this.nativeStreamClient.createMultiple(multipleStreamData, chainSpecificParams);
|
|
67
|
-
}
|
|
68
|
-
return this.nativeStreamClient.createMultiple(multipleStreamData);
|
|
56
|
+
return this.nativeStreamClient.createMultiple(multipleStreamData, chainSpecificParams);
|
|
69
57
|
};
|
|
70
58
|
/**
|
|
71
59
|
* Attempts withdrawing from the specified stream.
|
|
72
60
|
*/
|
|
73
61
|
GenericStreamClient.prototype.withdraw = function (withdrawData, chainSpecificParams) {
|
|
74
|
-
|
|
75
|
-
return this.nativeStreamClient.withdraw(withdrawData, chainSpecificParams);
|
|
76
|
-
}
|
|
77
|
-
else if (this.nativeStreamClient instanceof StreamClient_2.default) {
|
|
78
|
-
return this.nativeStreamClient.withdraw(withdrawData, chainSpecificParams);
|
|
79
|
-
}
|
|
80
|
-
return this.nativeStreamClient.withdraw(withdrawData);
|
|
62
|
+
return this.nativeStreamClient.withdraw(withdrawData, chainSpecificParams);
|
|
81
63
|
};
|
|
82
64
|
/**
|
|
83
65
|
* Attempts canceling the specified stream.
|
|
84
66
|
*/
|
|
85
67
|
GenericStreamClient.prototype.cancel = function (cancelData, chainSpecificParams) {
|
|
86
|
-
|
|
87
|
-
return this.nativeStreamClient.cancel(cancelData, chainSpecificParams);
|
|
88
|
-
}
|
|
89
|
-
else if (this.nativeStreamClient instanceof StreamClient_2.default) {
|
|
90
|
-
return this.nativeStreamClient.cancel(cancelData, chainSpecificParams);
|
|
91
|
-
}
|
|
92
|
-
return this.nativeStreamClient.cancel(cancelData);
|
|
68
|
+
return this.nativeStreamClient.cancel(cancelData, chainSpecificParams);
|
|
93
69
|
};
|
|
94
70
|
/**
|
|
95
71
|
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
96
72
|
*/
|
|
97
73
|
GenericStreamClient.prototype.transfer = function (transferData, chainSpecificParams) {
|
|
98
|
-
|
|
99
|
-
return this.nativeStreamClient.transfer(transferData, chainSpecificParams);
|
|
100
|
-
}
|
|
101
|
-
else if (this.nativeStreamClient instanceof StreamClient_2.default) {
|
|
102
|
-
return this.nativeStreamClient.transfer(transferData, chainSpecificParams);
|
|
103
|
-
}
|
|
104
|
-
return this.nativeStreamClient.transfer(transferData);
|
|
74
|
+
return this.nativeStreamClient.transfer(transferData, chainSpecificParams);
|
|
105
75
|
};
|
|
106
76
|
/**
|
|
107
77
|
* Tops up stream account with specified amount.
|
|
108
78
|
*/
|
|
109
79
|
GenericStreamClient.prototype.topup = function (topupData, chainSpecificParams) {
|
|
110
|
-
|
|
111
|
-
return this.nativeStreamClient.topup(topupData, chainSpecificParams);
|
|
112
|
-
}
|
|
113
|
-
else if (this.nativeStreamClient instanceof StreamClient_2.default) {
|
|
114
|
-
return this.nativeStreamClient.topup(topupData, chainSpecificParams);
|
|
115
|
-
}
|
|
116
|
-
return this.nativeStreamClient.topup(topupData);
|
|
80
|
+
return this.nativeStreamClient.topup(topupData, chainSpecificParams);
|
|
117
81
|
};
|
|
118
82
|
/**
|
|
119
83
|
* Fetch stream data by its id (address).
|
|
@@ -131,13 +95,7 @@ var GenericStreamClient = /** @class */ (function (_super) {
|
|
|
131
95
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
132
96
|
*/
|
|
133
97
|
GenericStreamClient.prototype.update = function (updateData, chainSpecificParams) {
|
|
134
|
-
|
|
135
|
-
return this.nativeStreamClient.update(updateData, chainSpecificParams);
|
|
136
|
-
}
|
|
137
|
-
else if (this.nativeStreamClient instanceof StreamClient_2.default) {
|
|
138
|
-
return this.nativeStreamClient.update(updateData, chainSpecificParams);
|
|
139
|
-
}
|
|
140
|
-
return this.nativeStreamClient.update(updateData);
|
|
98
|
+
return this.nativeStreamClient.update(updateData, chainSpecificParams);
|
|
141
99
|
};
|
|
142
100
|
return GenericStreamClient;
|
|
143
101
|
}(BaseStreamClient_1.BaseStreamClient));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BASE_FEE = 1002500;
|
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
import BN from "bn.js";
|
|
2
|
-
|
|
2
|
+
interface ICalculateUnlockedAmount {
|
|
3
|
+
depositedAmount: BN;
|
|
4
|
+
cliff: number;
|
|
5
|
+
cliffAmount: BN;
|
|
6
|
+
end: number;
|
|
7
|
+
currentTimestamp: number;
|
|
8
|
+
lastRateChangeTime: number;
|
|
9
|
+
period: number;
|
|
10
|
+
amountPerPeriod: BN;
|
|
11
|
+
fundsUnlockedAtLastRateChange: BN;
|
|
12
|
+
}
|
|
13
|
+
export declare const calculateUnlockedAmount: ({ depositedAmount, cliff, cliffAmount, end, currentTimestamp, lastRateChangeTime, period, amountPerPeriod, fundsUnlockedAtLastRateChange, }: ICalculateUnlockedAmount) => BN;
|
|
14
|
+
export {};
|
|
@@ -5,7 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.calculateUnlockedAmount = void 0;
|
|
7
7
|
var bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
-
var calculateUnlockedAmount = function (
|
|
8
|
+
var calculateUnlockedAmount = function (_a) {
|
|
9
|
+
var depositedAmount = _a.depositedAmount, cliff = _a.cliff, cliffAmount = _a.cliffAmount, end = _a.end, currentTimestamp = _a.currentTimestamp, lastRateChangeTime = _a.lastRateChangeTime, period = _a.period, amountPerPeriod = _a.amountPerPeriod, fundsUnlockedAtLastRateChange = _a.fundsUnlockedAtLastRateChange;
|
|
9
10
|
var deposited = depositedAmount;
|
|
10
11
|
if (currentTimestamp < cliff)
|
|
11
12
|
return new bn_js_1.default(0);
|
package/dist/common/types.d.ts
CHANGED
|
@@ -99,4 +99,49 @@ export declare enum IChain {
|
|
|
99
99
|
Polygon = "Polygon",
|
|
100
100
|
Sui = "Sui"
|
|
101
101
|
}
|
|
102
|
+
export interface Stream {
|
|
103
|
+
magic: number;
|
|
104
|
+
version: number;
|
|
105
|
+
createdAt: number;
|
|
106
|
+
withdrawnAmount: BN;
|
|
107
|
+
canceledAt: number;
|
|
108
|
+
end: number;
|
|
109
|
+
lastWithdrawnAt: number;
|
|
110
|
+
sender: string;
|
|
111
|
+
senderTokens: string;
|
|
112
|
+
recipient: string;
|
|
113
|
+
recipientTokens: string;
|
|
114
|
+
mint: string;
|
|
115
|
+
escrowTokens: string;
|
|
116
|
+
streamflowTreasury: string;
|
|
117
|
+
streamflowTreasuryTokens: string;
|
|
118
|
+
streamflowFeeTotal: BN;
|
|
119
|
+
streamflowFeeWithdrawn: BN;
|
|
120
|
+
streamflowFeePercent: number;
|
|
121
|
+
partnerFeeTotal: BN;
|
|
122
|
+
partnerFeeWithdrawn: BN;
|
|
123
|
+
partnerFeePercent: number;
|
|
124
|
+
partner: string;
|
|
125
|
+
partnerTokens: string;
|
|
126
|
+
start: number;
|
|
127
|
+
depositedAmount: BN;
|
|
128
|
+
period: number;
|
|
129
|
+
amountPerPeriod: BN;
|
|
130
|
+
cliff: number;
|
|
131
|
+
cliffAmount: BN;
|
|
132
|
+
cancelableBySender: boolean;
|
|
133
|
+
cancelableByRecipient: boolean;
|
|
134
|
+
automaticWithdrawal: boolean;
|
|
135
|
+
transferableBySender: boolean;
|
|
136
|
+
transferableByRecipient: boolean;
|
|
137
|
+
canTopup: boolean;
|
|
138
|
+
name: string;
|
|
139
|
+
withdrawalFrequency: number;
|
|
140
|
+
closed: boolean;
|
|
141
|
+
currentPauseStart: number;
|
|
142
|
+
pauseCumulative: BN;
|
|
143
|
+
lastRateChangeTime: number;
|
|
144
|
+
fundsUnlockedAtLastRateChange: BN;
|
|
145
|
+
unlocked(currentTimestamp: number, decimals: number): BN;
|
|
146
|
+
}
|
|
102
147
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
3
|
-
import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
4
|
-
import { Stream } from "../solana";
|
|
3
|
+
import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types";
|
|
5
4
|
export default class EvmStreamClient extends BaseStreamClient {
|
|
6
5
|
private programId;
|
|
7
6
|
private provider;
|
package/dist/evm/StreamClient.js
CHANGED
|
@@ -98,7 +98,7 @@ var types_1 = require("../common/types");
|
|
|
98
98
|
var constants_1 = require("./constants");
|
|
99
99
|
var abi_1 = __importDefault(require("./abi"));
|
|
100
100
|
var ercAbi_1 = __importDefault(require("./ercAbi"));
|
|
101
|
-
var constants_2 = require("../
|
|
101
|
+
var constants_2 = require("../common/constants");
|
|
102
102
|
var types_2 = require("./types");
|
|
103
103
|
var EvmStreamClient = /** @class */ (function (_super) {
|
|
104
104
|
__extends(EvmStreamClient, _super);
|
package/dist/evm/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BN from "bn.js";
|
|
2
2
|
import { BigNumber } from "ethers";
|
|
3
|
+
import { Stream } from "../common/types";
|
|
3
4
|
export interface StreamAbiResult {
|
|
4
5
|
amount: BigNumber;
|
|
5
6
|
amount_per_period: BigNumber;
|
|
@@ -42,51 +43,6 @@ export interface StreamAbiResult {
|
|
|
42
43
|
token: string;
|
|
43
44
|
withdrawn: BigNumber;
|
|
44
45
|
}
|
|
45
|
-
export interface Stream {
|
|
46
|
-
magic: number;
|
|
47
|
-
version: number;
|
|
48
|
-
createdAt: number;
|
|
49
|
-
withdrawnAmount: BN;
|
|
50
|
-
canceledAt: number;
|
|
51
|
-
end: number;
|
|
52
|
-
lastWithdrawnAt: number;
|
|
53
|
-
sender: string;
|
|
54
|
-
senderTokens: string;
|
|
55
|
-
recipient: string;
|
|
56
|
-
recipientTokens: string;
|
|
57
|
-
mint: string;
|
|
58
|
-
escrowTokens: string;
|
|
59
|
-
streamflowTreasury: string;
|
|
60
|
-
streamflowTreasuryTokens: string;
|
|
61
|
-
streamflowFeeTotal: BN;
|
|
62
|
-
streamflowFeeWithdrawn: BN;
|
|
63
|
-
streamflowFeePercent: number;
|
|
64
|
-
partnerFeeTotal: BN;
|
|
65
|
-
partnerFeeWithdrawn: BN;
|
|
66
|
-
partnerFeePercent: number;
|
|
67
|
-
partner: string;
|
|
68
|
-
partnerTokens: string;
|
|
69
|
-
start: number;
|
|
70
|
-
depositedAmount: BN;
|
|
71
|
-
period: number;
|
|
72
|
-
amountPerPeriod: BN;
|
|
73
|
-
cliff: number;
|
|
74
|
-
cliffAmount: BN;
|
|
75
|
-
cancelableBySender: boolean;
|
|
76
|
-
cancelableByRecipient: boolean;
|
|
77
|
-
automaticWithdrawal: boolean;
|
|
78
|
-
transferableBySender: boolean;
|
|
79
|
-
transferableByRecipient: boolean;
|
|
80
|
-
canTopup: boolean;
|
|
81
|
-
name: string;
|
|
82
|
-
withdrawalFrequency: number;
|
|
83
|
-
closed: boolean;
|
|
84
|
-
currentPauseStart: number;
|
|
85
|
-
pauseCumulative: BN;
|
|
86
|
-
lastRateChangeTime: number;
|
|
87
|
-
fundsUnlockedAtLastRateChange: BN;
|
|
88
|
-
unlocked(currentTimestamp: number, decimals: number): BN;
|
|
89
|
-
}
|
|
90
46
|
export declare class EvmContract implements Stream {
|
|
91
47
|
magic: number;
|
|
92
48
|
version: number;
|
package/dist/evm/types.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
15
|
};
|
|
@@ -53,7 +64,7 @@ var EvmContract = /** @class */ (function () {
|
|
|
53
64
|
this.fundsUnlockedAtLastRateChange = new bn_js_1.default(stream.funds_unlocked_at_last_rate_change.toString());
|
|
54
65
|
}
|
|
55
66
|
EvmContract.prototype.unlocked = function (currentTimestamp) {
|
|
56
|
-
return (0, contractUtils_1.calculateUnlockedAmount)(
|
|
67
|
+
return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
|
57
68
|
};
|
|
58
69
|
EvmContract.prototype.remaining = function (decimals) {
|
|
59
70
|
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * as StreamflowSolana from "./solana";
|
|
2
1
|
export * as StreamflowAptos from "./aptos";
|
|
3
2
|
export * as StreamflowEVM from "./evm";
|
|
3
|
+
export * as StreamflowSolana from "./solana";
|
|
4
|
+
export * as StreamflowSui from "./sui";
|
|
4
5
|
export * as Types from "./common/types";
|
|
5
6
|
export * from "./common/utils";
|
|
6
7
|
export { default as GenericStreamClient } from "./common/GenericStreamClient";
|
package/dist/index.js
CHANGED
|
@@ -29,10 +29,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.GenericStreamClient = exports.Types = exports.
|
|
33
|
-
exports.StreamflowSolana = __importStar(require("./solana"));
|
|
32
|
+
exports.GenericStreamClient = exports.Types = exports.StreamflowSui = exports.StreamflowSolana = exports.StreamflowEVM = exports.StreamflowAptos = void 0;
|
|
34
33
|
exports.StreamflowAptos = __importStar(require("./aptos"));
|
|
35
34
|
exports.StreamflowEVM = __importStar(require("./evm"));
|
|
35
|
+
exports.StreamflowSolana = __importStar(require("./solana"));
|
|
36
|
+
exports.StreamflowSui = __importStar(require("./sui"));
|
|
36
37
|
exports.Types = __importStar(require("./common/types"));
|
|
37
38
|
__exportStar(require("./common/utils"), exports);
|
|
38
39
|
var GenericStreamClient_1 = require("./common/GenericStreamClient");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Connection, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
2
|
-
import {
|
|
3
|
-
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
2
|
+
import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt } from "./types";
|
|
3
|
+
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types";
|
|
4
4
|
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
5
5
|
export default class SolanaStreamClient extends BaseStreamClient {
|
|
6
6
|
private connection;
|
|
@@ -53,12 +53,12 @@ export default class SolanaStreamClient extends BaseStreamClient {
|
|
|
53
53
|
/**
|
|
54
54
|
* Fetch stream data by its id (address).
|
|
55
55
|
*/
|
|
56
|
-
getOne({ id }: IGetOneData): Promise<
|
|
56
|
+
getOne({ id }: IGetOneData): Promise<Stream>;
|
|
57
57
|
/**
|
|
58
58
|
* Fetch streams/contracts by providing direction.
|
|
59
59
|
* Streams are sorted by start time in ascending order.
|
|
60
60
|
*/
|
|
61
|
-
get({ address, type, direction, }: IGetAllData): Promise<[string,
|
|
61
|
+
get({ address, type, direction, }: IGetAllData): Promise<[string, Stream][]>;
|
|
62
62
|
private sign;
|
|
63
63
|
/**
|
|
64
64
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
@@ -16,4 +16,3 @@ export declare const WITHDRAWOR_PUBLIC_KEY: PublicKey;
|
|
|
16
16
|
export declare const FEE_ORACLE_PUBLIC_KEY: PublicKey;
|
|
17
17
|
export declare const AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
|
|
18
18
|
export declare const AIRDROP_AMOUNT = 1;
|
|
19
|
-
export declare const BASE_FEE = 1002500;
|
package/dist/solana/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
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";
|
|
@@ -22,4 +22,3 @@ exports.WITHDRAWOR_PUBLIC_KEY = new web3_js_1.PublicKey("wdrwhnCv4pzW8beKsbPa4S2
|
|
|
22
22
|
exports.FEE_ORACLE_PUBLIC_KEY = new web3_js_1.PublicKey("B743wFVk2pCYhV91cn287e1xY7f1vt4gdY48hhNiuQmT");
|
|
23
23
|
exports.AIRDROP_TEST_TOKEN = "Gssm3vfi8s65R31SBdmQRq6cKeYojGgup7whkw4VCiQj";
|
|
24
24
|
exports.AIRDROP_AMOUNT = 1; // 1 SOL is the cap on the testnet
|
|
25
|
-
exports.BASE_FEE = 1002500; // Basic buffer for intermediary swaps
|
|
@@ -94,7 +94,7 @@ var bn_js_1 = __importDefault(require("bn.js"));
|
|
|
94
94
|
var js_sha256_1 = require("js-sha256");
|
|
95
95
|
var spl_token_1 = require("@solana/spl-token");
|
|
96
96
|
var Layout = __importStar(require("./layout"));
|
|
97
|
-
var constants_1 = require("
|
|
97
|
+
var constants_1 = require("../common/constants");
|
|
98
98
|
var createStreamInstruction = function (data, programId, accounts) {
|
|
99
99
|
var keys = [
|
|
100
100
|
{ pubkey: accounts.sender, isSigner: true, isWritable: true },
|
package/dist/solana/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
3
|
import { AccountInfo, Connection, PublicKey, Keypair, TransactionSignature, TransactionInstruction, Transaction } from "@solana/web3.js";
|
|
4
4
|
import BN from "bn.js";
|
|
5
|
-
import { IRecipient, StreamDirection, StreamType } from "../common/types";
|
|
5
|
+
import { IRecipient, Stream, StreamDirection, StreamType } from "../common/types";
|
|
6
6
|
export { WalletAdapterNetwork as Cluster } from "@solana/wallet-adapter-base";
|
|
7
7
|
export interface Account {
|
|
8
8
|
pubkey: PublicKey;
|
|
@@ -133,51 +133,6 @@ export interface GetAllParams {
|
|
|
133
133
|
type?: StreamType;
|
|
134
134
|
direction?: StreamDirection;
|
|
135
135
|
}
|
|
136
|
-
export interface Stream {
|
|
137
|
-
magic: number;
|
|
138
|
-
version: number;
|
|
139
|
-
createdAt: number;
|
|
140
|
-
withdrawnAmount: BN;
|
|
141
|
-
canceledAt: number;
|
|
142
|
-
end: number;
|
|
143
|
-
lastWithdrawnAt: number;
|
|
144
|
-
sender: string;
|
|
145
|
-
senderTokens: string;
|
|
146
|
-
recipient: string;
|
|
147
|
-
recipientTokens: string;
|
|
148
|
-
mint: string;
|
|
149
|
-
escrowTokens: string;
|
|
150
|
-
streamflowTreasury: string;
|
|
151
|
-
streamflowTreasuryTokens: string;
|
|
152
|
-
streamflowFeeTotal: BN;
|
|
153
|
-
streamflowFeeWithdrawn: BN;
|
|
154
|
-
streamflowFeePercent: number;
|
|
155
|
-
partnerFeeTotal: BN;
|
|
156
|
-
partnerFeeWithdrawn: BN;
|
|
157
|
-
partnerFeePercent: number;
|
|
158
|
-
partner: string;
|
|
159
|
-
partnerTokens: string;
|
|
160
|
-
start: number;
|
|
161
|
-
depositedAmount: BN;
|
|
162
|
-
period: number;
|
|
163
|
-
amountPerPeriod: BN;
|
|
164
|
-
cliff: number;
|
|
165
|
-
cliffAmount: BN;
|
|
166
|
-
cancelableBySender: boolean;
|
|
167
|
-
cancelableByRecipient: boolean;
|
|
168
|
-
automaticWithdrawal: boolean;
|
|
169
|
-
transferableBySender: boolean;
|
|
170
|
-
transferableByRecipient: boolean;
|
|
171
|
-
canTopup: boolean;
|
|
172
|
-
name: string;
|
|
173
|
-
withdrawalFrequency: number;
|
|
174
|
-
closed: boolean;
|
|
175
|
-
currentPauseStart: number;
|
|
176
|
-
pauseCumulative: BN;
|
|
177
|
-
lastRateChangeTime: number;
|
|
178
|
-
fundsUnlockedAtLastRateChange: BN;
|
|
179
|
-
unlocked(currentTimestamp: number): BN;
|
|
180
|
-
}
|
|
181
136
|
export declare class Contract implements Stream {
|
|
182
137
|
magic: number;
|
|
183
138
|
version: number;
|
package/dist/solana/types.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.TransferCancelOptions = exports.Contract = exports.Cluster = void 0;
|
|
4
15
|
var contractUtils_1 = require("../common/contractUtils");
|
|
@@ -52,7 +63,7 @@ var Contract = /** @class */ (function () {
|
|
|
52
63
|
this.fundsUnlockedAtLastRateChange = stream.fundsUnlockedAtLastRateChange;
|
|
53
64
|
}
|
|
54
65
|
Contract.prototype.unlocked = function (currentTimestamp) {
|
|
55
|
-
return (0, contractUtils_1.calculateUnlockedAmount)(
|
|
66
|
+
return (0, contractUtils_1.calculateUnlockedAmount)(__assign(__assign({}, this), { currentTimestamp: currentTimestamp }));
|
|
56
67
|
};
|
|
57
68
|
Contract.prototype.remaining = function (decimals) {
|
|
58
69
|
return (0, utils_1.getNumberFromBN)(this.depositedAmount.sub(this.withdrawnAmount), decimals);
|
package/dist/solana/utils.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
|
|
3
3
|
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
4
|
-
import {
|
|
4
|
+
import { DecodedStream, Account, BatchItem, BatchItemResult } from "./types";
|
|
5
|
+
import { Stream } from "../common/types";
|
|
5
6
|
export declare const decodeStream: (buf: Buffer) => DecodedStream;
|
|
6
7
|
export declare const formatDecodedStream: (stream: DecodedStream) => Stream;
|
|
7
8
|
/**
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { BaseStreamClient } from "../common/BaseStreamClient";
|
|
2
|
+
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetOneData, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData } from "../common/types";
|
|
3
|
+
import { Contract, ICreateStreamSuiExt, ITransactionSuiExt, ISuiIdParameters } from "./types";
|
|
4
|
+
export default class SuiStreamClient extends BaseStreamClient {
|
|
5
|
+
private programId;
|
|
6
|
+
private configId;
|
|
7
|
+
private feeTableId;
|
|
8
|
+
private client;
|
|
9
|
+
constructor(clusterUrl: string, cluster?: ICluster, ids?: ISuiIdParameters);
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new stream/vesting contract.
|
|
12
|
+
*/
|
|
13
|
+
create(streamData: ICreateStreamData, { senderWallet }: ICreateStreamSuiExt): Promise<ICreateResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates multiple stream/vesting contracts.
|
|
16
|
+
* We don't chain transactions in one Block so that one failed transaction does not revert all others.
|
|
17
|
+
*/
|
|
18
|
+
createMultiple(multipleStreamData: ICreateMultipleStreamData, { senderWallet }: ICreateStreamSuiExt): Promise<IMultiTransactionResult>;
|
|
19
|
+
/**
|
|
20
|
+
* Attempts withdrawing from the specified stream.
|
|
21
|
+
*/
|
|
22
|
+
withdraw(withdrawData: IWithdrawData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Attempts canceling the specified stream.
|
|
25
|
+
*/
|
|
26
|
+
cancel(cancelData: ICancelData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
|
|
29
|
+
*/
|
|
30
|
+
transfer(transferData: ITransferData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Tops up stream account with specified amount.
|
|
33
|
+
*/
|
|
34
|
+
topup(topupData: ITopUpData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Fetch stream data by its id (address).
|
|
37
|
+
*/
|
|
38
|
+
getOne({ id }: IGetOneData): Promise<Contract>;
|
|
39
|
+
get(): Promise<[string, Contract][]>;
|
|
40
|
+
/**
|
|
41
|
+
* Attempts updating the stream auto withdrawal params and amount per period
|
|
42
|
+
*/
|
|
43
|
+
update(updateData: IUpdateData, { senderWallet, tokenId }: ITransactionSuiExt): Promise<ITransactionResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Returns StreamClient protocol program ID.
|
|
46
|
+
*/
|
|
47
|
+
getProgramId(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Utility function to generate Transaction Block to create streams
|
|
50
|
+
*/
|
|
51
|
+
private generateCreateTransactions;
|
|
52
|
+
/**
|
|
53
|
+
* Returns all coins owned by a Wallet
|
|
54
|
+
* @param walletAddress wallet address
|
|
55
|
+
* @param coinType coin type
|
|
56
|
+
* @returns Array of Coin Structs
|
|
57
|
+
*/
|
|
58
|
+
private getAllCoins;
|
|
59
|
+
/**
|
|
60
|
+
* Utility function to split Coin object and use splitted object for stream operations.
|
|
61
|
+
* We do it like thid to mitigate risk of Transaction reverting in case Stream is created for Sui Coin object.
|
|
62
|
+
* This way we can safely pass splitted Sui Coin object in Stream payload and use another object for gas/withdrawal fees.
|
|
63
|
+
* @param txb current transanction block
|
|
64
|
+
* @param amount minimal amount of coins requried
|
|
65
|
+
* @param coinType coin type
|
|
66
|
+
* @param coins array of owned coins of the same type
|
|
67
|
+
* @returns Coin Object to use in a Move Call
|
|
68
|
+
*/
|
|
69
|
+
private splitCoinObjectForAmount;
|
|
70
|
+
/**
|
|
71
|
+
* Return previously splitted Coin Object to owner and merge it to to rebate storage fees
|
|
72
|
+
* @param txb current transanction block
|
|
73
|
+
* @param coinType coin type
|
|
74
|
+
* @param coinObject splitted object
|
|
75
|
+
* @param coins array of objects used in
|
|
76
|
+
*/
|
|
77
|
+
private returnSplittedCoinObject;
|
|
78
|
+
}
|