@streamflow/stream 7.0.0-alpha.1 → 7.0.0-alpha.11
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 +65 -68
- package/dist/cjs/__tests__/aptos/streamClient.spec.js +83 -134
- package/dist/cjs/__tests__/common/GenericStreamClient.spec.js +9 -9
- package/dist/cjs/aptos/StreamClient.js +162 -367
- package/dist/cjs/aptos/constants.js +7 -8
- package/dist/cjs/aptos/index.js +3 -3
- package/dist/cjs/aptos/types.js +32 -41
- package/dist/cjs/aptos/utils.js +4 -4
- package/dist/cjs/aptos/wallet.js +20 -75
- package/dist/cjs/common/BaseStreamClient.js +11 -59
- package/dist/cjs/common/GenericStreamClient.js +46 -72
- package/dist/cjs/common/constants.js +2 -2
- package/dist/cjs/common/contractUtils.js +16 -17
- package/dist/cjs/common/utils.js +34 -84
- package/dist/cjs/evm/StreamClient.js +198 -456
- package/dist/cjs/evm/constants.js +19 -20
- package/dist/cjs/evm/types.js +25 -34
- package/dist/cjs/evm/utils.js +2 -2
- package/dist/cjs/index.js +10 -10
- package/dist/cjs/solana/StreamClient.js +608 -1090
- package/dist/cjs/solana/constants.js +16 -11
- package/dist/cjs/solana/instructions.js +76 -80
- package/dist/cjs/solana/layout.js +7 -8
- package/dist/cjs/solana/types.js +15 -25
- package/dist/cjs/solana/utils.js +77 -154
- package/dist/cjs/sui/StreamClient.js +325 -571
- package/dist/cjs/sui/constants.js +19 -20
- package/dist/cjs/sui/types.js +28 -62
- package/dist/cjs/sui/utils.js +7 -7
- package/dist/cjs/sui/wallet.js +13 -63
- package/dist/esm/__tests__/aptos/streamClient.spec.js +4 -4
- package/dist/esm/aptos/index.d.ts +3 -3
- package/dist/esm/aptos/index.js +3 -3
- package/dist/esm/aptos/types.d.ts +12 -12
- package/dist/esm/aptos/types.js +13 -13
- package/dist/esm/common/GenericStreamClient.d.ts +4 -4
- package/dist/esm/common/GenericStreamClient.js +4 -4
- package/dist/esm/common/constants.d.ts +2 -2
- package/dist/esm/common/constants.js +2 -2
- package/dist/esm/common/contractUtils.d.ts +14 -14
- package/dist/esm/common/contractUtils.js +6 -6
- package/dist/esm/common/types.d.ts +19 -19
- package/dist/esm/common/utils.d.ts +11 -11
- package/dist/esm/common/utils.js +16 -19
- package/dist/esm/evm/StreamClient.d.ts +2 -2
- package/dist/esm/evm/StreamClient.js +7 -7
- package/dist/esm/evm/types.d.ts +37 -37
- package/dist/esm/evm/types.js +13 -13
- package/dist/esm/index.d.ts +9 -9
- package/dist/esm/index.js +9 -9
- package/dist/esm/solana/StreamClient.d.ts +3 -1
- package/dist/esm/solana/StreamClient.js +38 -22
- package/dist/esm/solana/constants.d.ts +3 -0
- package/dist/esm/solana/constants.js +6 -0
- package/dist/esm/solana/instructions.d.ts +17 -17
- package/dist/esm/solana/instructions.js +19 -18
- package/dist/esm/solana/types.d.ts +41 -36
- package/dist/esm/solana/types.js +2 -2
- package/dist/esm/solana/utils.d.ts +2 -0
- package/dist/esm/solana/utils.js +32 -26
- package/dist/esm/sui/StreamClient.js +1 -1
- package/dist/esm/sui/types.d.ts +12 -12
- package/dist/esm/sui/types.js +13 -13
- package/package.json +10 -11
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { TransactionInstruction } from "@solana/web3.js";
|
|
2
2
|
import { Types } from "aptos";
|
|
3
|
-
import
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
4
|
export { IChain, ICluster, ContractError } from "@streamflow/common";
|
|
5
5
|
export interface IRecipient {
|
|
6
6
|
recipient: string;
|
|
7
|
-
amount:
|
|
7
|
+
amount: BigNumber;
|
|
8
8
|
name: string;
|
|
9
|
-
cliffAmount:
|
|
10
|
-
amountPerPeriod:
|
|
9
|
+
cliffAmount: BigNumber;
|
|
10
|
+
amountPerPeriod: BigNumber;
|
|
11
11
|
}
|
|
12
12
|
export interface IStreamConfig {
|
|
13
13
|
period: number;
|
|
@@ -33,19 +33,19 @@ export interface IInteractData {
|
|
|
33
33
|
id: string;
|
|
34
34
|
}
|
|
35
35
|
export interface IWithdrawData extends IInteractData {
|
|
36
|
-
amount?:
|
|
36
|
+
amount?: BigNumber;
|
|
37
37
|
}
|
|
38
38
|
export interface IUpdateData extends IInteractData {
|
|
39
39
|
enableAutomaticWithdrawal?: boolean;
|
|
40
|
-
withdrawFrequency?:
|
|
41
|
-
amountPerPeriod?:
|
|
40
|
+
withdrawFrequency?: BigNumber;
|
|
41
|
+
amountPerPeriod?: BigNumber;
|
|
42
42
|
}
|
|
43
43
|
export type ICancelData = IInteractData;
|
|
44
44
|
export interface ITransferData extends IInteractData {
|
|
45
45
|
newRecipient: string;
|
|
46
46
|
}
|
|
47
47
|
export interface ITopUpData extends IInteractData {
|
|
48
|
-
amount:
|
|
48
|
+
amount: BigNumber;
|
|
49
49
|
}
|
|
50
50
|
export type IGetOneData = IInteractData;
|
|
51
51
|
export interface IGetFeesData {
|
|
@@ -184,7 +184,7 @@ export interface Stream {
|
|
|
184
184
|
magic: number;
|
|
185
185
|
version: number;
|
|
186
186
|
createdAt: number;
|
|
187
|
-
withdrawnAmount:
|
|
187
|
+
withdrawnAmount: BigNumber;
|
|
188
188
|
canceledAt: number;
|
|
189
189
|
end: number;
|
|
190
190
|
lastWithdrawnAt: number;
|
|
@@ -196,20 +196,20 @@ export interface Stream {
|
|
|
196
196
|
escrowTokens: string;
|
|
197
197
|
streamflowTreasury: string;
|
|
198
198
|
streamflowTreasuryTokens: string;
|
|
199
|
-
streamflowFeeTotal:
|
|
200
|
-
streamflowFeeWithdrawn:
|
|
199
|
+
streamflowFeeTotal: BigNumber;
|
|
200
|
+
streamflowFeeWithdrawn: BigNumber;
|
|
201
201
|
streamflowFeePercent: number;
|
|
202
|
-
partnerFeeTotal:
|
|
203
|
-
partnerFeeWithdrawn:
|
|
202
|
+
partnerFeeTotal: BigNumber;
|
|
203
|
+
partnerFeeWithdrawn: BigNumber;
|
|
204
204
|
partnerFeePercent: number;
|
|
205
205
|
partner: string;
|
|
206
206
|
partnerTokens: string;
|
|
207
207
|
start: number;
|
|
208
|
-
depositedAmount:
|
|
208
|
+
depositedAmount: BigNumber;
|
|
209
209
|
period: number;
|
|
210
|
-
amountPerPeriod:
|
|
210
|
+
amountPerPeriod: BigNumber;
|
|
211
211
|
cliff: number;
|
|
212
|
-
cliffAmount:
|
|
212
|
+
cliffAmount: BigNumber;
|
|
213
213
|
cancelableBySender: boolean;
|
|
214
214
|
cancelableByRecipient: boolean;
|
|
215
215
|
automaticWithdrawal: boolean;
|
|
@@ -220,10 +220,10 @@ export interface Stream {
|
|
|
220
220
|
withdrawalFrequency: number;
|
|
221
221
|
closed: boolean;
|
|
222
222
|
currentPauseStart: number;
|
|
223
|
-
pauseCumulative:
|
|
223
|
+
pauseCumulative: BigNumber;
|
|
224
224
|
lastRateChangeTime: number;
|
|
225
|
-
fundsUnlockedAtLastRateChange:
|
|
225
|
+
fundsUnlockedAtLastRateChange: BigNumber;
|
|
226
226
|
type: StreamType;
|
|
227
|
-
unlocked(currentTimestamp: number):
|
|
227
|
+
unlocked(currentTimestamp: number): BigNumber;
|
|
228
228
|
remaining(decimals: number): number;
|
|
229
229
|
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
2
|
/**
|
|
3
|
-
* Used for
|
|
4
|
-
* Get
|
|
5
|
-
* @param {
|
|
3
|
+
* Used for token amounts conversion from their Big Number representation to number.
|
|
4
|
+
* Get value in the highest units from BigNumber representation of the same value in the smallest units.
|
|
5
|
+
* @param {BigNumber} value - Big Number representation of value in the smallest units.
|
|
6
6
|
* @param {number} decimals - Number of decimals the token has.
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const getNumberFromBigNumber: (bigNum: BigNumber, decimals: number) => number;
|
|
9
9
|
/**
|
|
10
|
-
* Used for token amounts
|
|
11
|
-
* Get
|
|
12
|
-
* @param {
|
|
10
|
+
* Used for conversion of token amounts to their Big Number representation.
|
|
11
|
+
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
12
|
+
* @param {number} value - Number of tokens you want to convert to its BigNumber representation.
|
|
13
13
|
* @param {number} decimals - Number of decimals the token has.
|
|
14
14
|
*/
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const getScaledBigNumber: (value: number | string | BigNumber, decimals: number) => BigNumber;
|
|
16
16
|
/**
|
|
17
17
|
* Calculate total amount of a Contract including all fees.
|
|
18
|
-
* - first we convert fee floating to a
|
|
18
|
+
* - first we convert fee floating to a BigNumber with up to 4 decimals precision
|
|
19
19
|
* - then we reverse the fee with `FEE_MULTIPLIER` to safely multiply it by depositedAmount
|
|
20
20
|
* to receive a total number and not percentage of depositedAmount
|
|
21
21
|
* @param depositedAmount deposited raw tokens
|
|
22
22
|
* @param totalFee sum of all fees in percentage as floating number, e.g. 0.99% should be supplied as 0.99
|
|
23
23
|
* @returns total tokens amount that Contract will retrieve from the Sender
|
|
24
24
|
*/
|
|
25
|
-
export declare const calculateTotalAmountToDeposit: (depositedAmount:
|
|
25
|
+
export declare const calculateTotalAmountToDeposit: (depositedAmount: BigNumber, totalFee: number) => BigNumber;
|
|
26
26
|
/**
|
|
27
27
|
* Used to make on chain calls to the contract and wrap raised errors if any
|
|
28
28
|
* @param func function that interacts with the contract
|
package/dist/esm/common/utils.js
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
2
|
import { ContractError } from "./types.js";
|
|
3
3
|
const FEE_PRECISION = 4;
|
|
4
4
|
const FEE_NORMALIZER = 10 ** FEE_PRECISION;
|
|
5
|
-
const FEE_MULTIPLIER =
|
|
5
|
+
const FEE_MULTIPLIER = BigNumber(10 ** 6);
|
|
6
6
|
/**
|
|
7
|
-
* Used for
|
|
8
|
-
* Get
|
|
9
|
-
* @param {
|
|
7
|
+
* Used for token amounts conversion from their Big Number representation to number.
|
|
8
|
+
* Get value in the highest units from BigNumber representation of the same value in the smallest units.
|
|
9
|
+
* @param {BigNumber} value - Big Number representation of value in the smallest units.
|
|
10
10
|
* @param {number} decimals - Number of decimals the token has.
|
|
11
11
|
*/
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
const integerPart = new BN(Math.trunc(value));
|
|
15
|
-
const decimalE = new BN(decimalPart * 1e9);
|
|
16
|
-
const sum = integerPart.mul(new BN(1e9)).add(decimalE);
|
|
17
|
-
const resultE = sum.mul(new BN(10).pow(new BN(decimals)));
|
|
18
|
-
return resultE.div(new BN(1e9));
|
|
12
|
+
export const getNumberFromBigNumber = (bigNum, decimals) => {
|
|
13
|
+
return bigNum.div(BigNumber(10).pow(decimals)).toNumber();
|
|
19
14
|
};
|
|
20
15
|
/**
|
|
21
|
-
* Used for token amounts
|
|
22
|
-
* Get
|
|
23
|
-
* @param {
|
|
16
|
+
* Used for conversion of token amounts to their Big Number representation.
|
|
17
|
+
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
18
|
+
* @param {number} value - Number of tokens you want to convert to its BigNumber representation.
|
|
24
19
|
* @param {number} decimals - Number of decimals the token has.
|
|
25
20
|
*/
|
|
26
|
-
export const
|
|
21
|
+
export const getScaledBigNumber = (value, decimals) => {
|
|
22
|
+
return new BigNumber(value).times(new BigNumber(10).pow(decimals));
|
|
23
|
+
};
|
|
27
24
|
/**
|
|
28
25
|
* Calculate total amount of a Contract including all fees.
|
|
29
|
-
* - first we convert fee floating to a
|
|
26
|
+
* - first we convert fee floating to a BigNumber with up to 4 decimals precision
|
|
30
27
|
* - then we reverse the fee with `FEE_MULTIPLIER` to safely multiply it by depositedAmount
|
|
31
28
|
* to receive a total number and not percentage of depositedAmount
|
|
32
29
|
* @param depositedAmount deposited raw tokens
|
|
@@ -34,8 +31,8 @@ export const getNumberFromBN = (value, decimals) => value.gt(new BN(2 ** 53 - 1)
|
|
|
34
31
|
* @returns total tokens amount that Contract will retrieve from the Sender
|
|
35
32
|
*/
|
|
36
33
|
export const calculateTotalAmountToDeposit = (depositedAmount, totalFee) => {
|
|
37
|
-
const totalFeeNormalized =
|
|
38
|
-
return depositedAmount.
|
|
34
|
+
const totalFeeNormalized = BigNumber(totalFee).times(FEE_NORMALIZER);
|
|
35
|
+
return depositedAmount.times(totalFeeNormalized.plus(FEE_MULTIPLIER)).div(FEE_MULTIPLIER);
|
|
39
36
|
};
|
|
40
37
|
/**
|
|
41
38
|
* Used to make on chain calls to the contract and wrap raised errors if any
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
|
-
import
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
3
|
import { BaseStreamClient } from "../common/BaseStreamClient.js";
|
|
4
4
|
import { ICancelData, IChain, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetFeesData, IGetAllData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types.js";
|
|
5
5
|
export default class EvmStreamClient extends BaseStreamClient {
|
|
@@ -25,7 +25,7 @@ export default class EvmStreamClient extends BaseStreamClient {
|
|
|
25
25
|
* Returns StreamClient protocol program ID.
|
|
26
26
|
*/
|
|
27
27
|
getProgramId(): string;
|
|
28
|
-
approveTokens(tokenId: string, amount:
|
|
28
|
+
approveTokens(tokenId: string, amount: BigNumber): Promise<void>;
|
|
29
29
|
private generateMultiPayloads;
|
|
30
30
|
private getFeeParams;
|
|
31
31
|
private formatMetadataId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
|
-
import
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
3
|
import { toChecksumAddress } from "ethereum-checksum-address";
|
|
4
4
|
import { BaseStreamClient } from "../common/BaseStreamClient.js";
|
|
5
5
|
import { IChain, ICluster, StreamDirection, } from "../common/types.js";
|
|
@@ -49,7 +49,7 @@ export default class EvmStreamClient extends BaseStreamClient {
|
|
|
49
49
|
};
|
|
50
50
|
const fees = await this.readContract.getWithdrawalFees(...this.getFeeParams(multiParams));
|
|
51
51
|
const args = (await this.generateMultiPayloads(multiParams))[0];
|
|
52
|
-
const sum = streamData.amount.
|
|
52
|
+
const sum = streamData.amount.times(BigNumber(BASE_FEE)).div(BigNumber(1000000));
|
|
53
53
|
await this.approveTokens(streamData.tokenId, sum);
|
|
54
54
|
const result = await this.writeContract.create(...args, {
|
|
55
55
|
value: fees.value,
|
|
@@ -66,9 +66,9 @@ export default class EvmStreamClient extends BaseStreamClient {
|
|
|
66
66
|
const fees = await this.readContract.getWithdrawalFees(...this.getFeeParams(multipleStreamData));
|
|
67
67
|
const args = await this.generateMultiPayloads(multipleStreamData);
|
|
68
68
|
const sum = multipleStreamData.recipients
|
|
69
|
-
.reduce((acc, v) => acc.
|
|
70
|
-
.
|
|
71
|
-
.div(
|
|
69
|
+
.reduce((acc, v) => acc.plus(v.amount), BigNumber(0))
|
|
70
|
+
.times(BigNumber(BASE_FEE))
|
|
71
|
+
.div(BigNumber(1000000));
|
|
72
72
|
await this.approveTokens(multipleStreamData.tokenId, sum);
|
|
73
73
|
const creationPromises = args.map((item) => this.writeContract.create(...item, { value: fees.value }));
|
|
74
74
|
const signatures = [];
|
|
@@ -120,7 +120,7 @@ export default class EvmStreamClient extends BaseStreamClient {
|
|
|
120
120
|
}
|
|
121
121
|
async topup(topupData) {
|
|
122
122
|
const fees = await this.readContract.getTopUpWithdrawalFees(topupData.id, topupData.amount.toString());
|
|
123
|
-
const sum = topupData.amount.
|
|
123
|
+
const sum = topupData.amount.times(BigNumber(BASE_FEE)).div(BigNumber(1000000));
|
|
124
124
|
const stream = await this.getOne({ id: topupData.id });
|
|
125
125
|
await this.approveTokens(stream.mint, sum);
|
|
126
126
|
const result = await this.writeContract.topUp(topupData.id, topupData.amount.toString(), {
|
|
@@ -185,7 +185,7 @@ export default class EvmStreamClient extends BaseStreamClient {
|
|
|
185
185
|
const tokenContract = new ethers.Contract(tokenId, ercAbi, this.signer);
|
|
186
186
|
const address = await this.signer.getAddress();
|
|
187
187
|
const allowance = await tokenContract.allowance(address, this.programId);
|
|
188
|
-
if (
|
|
188
|
+
if (BigNumber(allowance.toString()).gte(amount)) {
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
191
|
const approvalTx = await tokenContract.approve(this.programId, amount.toString());
|
package/dist/esm/evm/types.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BigNumber } from "ethers";
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { BigNumber as BigNumberEvm } from "ethers";
|
|
3
3
|
import { Stream, StreamType } from "../common/types.js";
|
|
4
4
|
export interface StreamAbiResult {
|
|
5
|
-
amount:
|
|
6
|
-
amount_per_period:
|
|
7
|
-
canceled_at:
|
|
8
|
-
cliff_amount:
|
|
5
|
+
amount: BigNumberEvm;
|
|
6
|
+
amount_per_period: BigNumberEvm;
|
|
7
|
+
canceled_at: BigNumberEvm;
|
|
8
|
+
cliff_amount: BigNumberEvm;
|
|
9
9
|
closed: boolean;
|
|
10
|
-
created:
|
|
11
|
-
current_pause_start:
|
|
12
|
-
end:
|
|
10
|
+
created: BigNumberEvm;
|
|
11
|
+
current_pause_start: BigNumberEvm;
|
|
12
|
+
end: BigNumberEvm;
|
|
13
13
|
fees: {
|
|
14
|
-
streamflow_fee_percentage:
|
|
15
|
-
streamflow_fee:
|
|
16
|
-
streamflow_fee_withdrawn:
|
|
17
|
-
partner_fee_percentage:
|
|
18
|
-
partner_fee:
|
|
19
|
-
partner_fee_withdrawn:
|
|
20
|
-
tx_fee:
|
|
14
|
+
streamflow_fee_percentage: BigNumberEvm;
|
|
15
|
+
streamflow_fee: BigNumberEvm;
|
|
16
|
+
streamflow_fee_withdrawn: BigNumberEvm;
|
|
17
|
+
partner_fee_percentage: BigNumberEvm;
|
|
18
|
+
partner_fee: BigNumberEvm;
|
|
19
|
+
partner_fee_withdrawn: BigNumberEvm;
|
|
20
|
+
tx_fee: BigNumberEvm;
|
|
21
21
|
};
|
|
22
|
-
funds_unlocked_at_last_rate_change:
|
|
23
|
-
last_rate_change_time:
|
|
24
|
-
last_withdrawn_at:
|
|
22
|
+
funds_unlocked_at_last_rate_change: BigNumberEvm;
|
|
23
|
+
last_rate_change_time: BigNumberEvm;
|
|
24
|
+
last_withdrawn_at: BigNumberEvm;
|
|
25
25
|
meta: {
|
|
26
26
|
automatic_withdrawal: boolean;
|
|
27
27
|
can_topup: boolean;
|
|
@@ -32,27 +32,27 @@ export interface StreamAbiResult {
|
|
|
32
32
|
pausable: boolean;
|
|
33
33
|
transferable_by_recipient: boolean;
|
|
34
34
|
transferable_by_sender: boolean;
|
|
35
|
-
withdrawal_frequency:
|
|
35
|
+
withdrawal_frequency: BigNumberEvm;
|
|
36
36
|
};
|
|
37
|
-
pause_cumulative:
|
|
38
|
-
period:
|
|
37
|
+
pause_cumulative: BigNumberEvm;
|
|
38
|
+
period: BigNumberEvm;
|
|
39
39
|
recipient: string;
|
|
40
40
|
sender: string;
|
|
41
41
|
partner: string;
|
|
42
|
-
start:
|
|
42
|
+
start: BigNumberEvm;
|
|
43
43
|
token: string;
|
|
44
|
-
withdrawn:
|
|
44
|
+
withdrawn: BigNumberEvm;
|
|
45
45
|
}
|
|
46
46
|
export interface FeesAbiResult {
|
|
47
47
|
exists: boolean;
|
|
48
|
-
streamflow_fee:
|
|
49
|
-
partner_fee:
|
|
48
|
+
streamflow_fee: BigNumberEvm;
|
|
49
|
+
partner_fee: BigNumberEvm;
|
|
50
50
|
}
|
|
51
51
|
export declare class EvmContract implements Stream {
|
|
52
52
|
magic: number;
|
|
53
53
|
version: number;
|
|
54
54
|
createdAt: number;
|
|
55
|
-
withdrawnAmount:
|
|
55
|
+
withdrawnAmount: BigNumber;
|
|
56
56
|
canceledAt: number;
|
|
57
57
|
end: number;
|
|
58
58
|
lastWithdrawnAt: number;
|
|
@@ -64,20 +64,20 @@ export declare class EvmContract implements Stream {
|
|
|
64
64
|
escrowTokens: string;
|
|
65
65
|
streamflowTreasury: string;
|
|
66
66
|
streamflowTreasuryTokens: string;
|
|
67
|
-
streamflowFeeTotal:
|
|
68
|
-
streamflowFeeWithdrawn:
|
|
67
|
+
streamflowFeeTotal: BigNumber;
|
|
68
|
+
streamflowFeeWithdrawn: BigNumber;
|
|
69
69
|
streamflowFeePercent: number;
|
|
70
|
-
partnerFeeTotal:
|
|
71
|
-
partnerFeeWithdrawn:
|
|
70
|
+
partnerFeeTotal: BigNumber;
|
|
71
|
+
partnerFeeWithdrawn: BigNumber;
|
|
72
72
|
partnerFeePercent: number;
|
|
73
73
|
partner: string;
|
|
74
74
|
partnerTokens: string;
|
|
75
75
|
start: number;
|
|
76
|
-
depositedAmount:
|
|
76
|
+
depositedAmount: BigNumber;
|
|
77
77
|
period: number;
|
|
78
|
-
amountPerPeriod:
|
|
78
|
+
amountPerPeriod: BigNumber;
|
|
79
79
|
cliff: number;
|
|
80
|
-
cliffAmount:
|
|
80
|
+
cliffAmount: BigNumber;
|
|
81
81
|
cancelableBySender: boolean;
|
|
82
82
|
cancelableByRecipient: boolean;
|
|
83
83
|
automaticWithdrawal: boolean;
|
|
@@ -88,11 +88,11 @@ export declare class EvmContract implements Stream {
|
|
|
88
88
|
withdrawalFrequency: number;
|
|
89
89
|
closed: boolean;
|
|
90
90
|
currentPauseStart: number;
|
|
91
|
-
pauseCumulative:
|
|
91
|
+
pauseCumulative: BigNumber;
|
|
92
92
|
lastRateChangeTime: number;
|
|
93
|
-
fundsUnlockedAtLastRateChange:
|
|
93
|
+
fundsUnlockedAtLastRateChange: BigNumber;
|
|
94
94
|
type: StreamType;
|
|
95
95
|
constructor(stream: StreamAbiResult);
|
|
96
|
-
unlocked(currentTimestamp: number):
|
|
96
|
+
unlocked(currentTimestamp: number): BigNumber;
|
|
97
97
|
remaining(decimals: number): number;
|
|
98
98
|
}
|
package/dist/esm/evm/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
2
|
import { buildStreamType, calculateUnlockedAmount } from "../common/contractUtils.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getNumberFromBigNumber } from "../common/utils.js";
|
|
4
4
|
export class EvmContract {
|
|
5
5
|
magic;
|
|
6
6
|
version;
|
|
@@ -49,7 +49,7 @@ export class EvmContract {
|
|
|
49
49
|
this.magic = 0;
|
|
50
50
|
this.version = 0;
|
|
51
51
|
this.createdAt = stream.created.toNumber();
|
|
52
|
-
this.withdrawnAmount =
|
|
52
|
+
this.withdrawnAmount = BigNumber(stream.withdrawn.toString());
|
|
53
53
|
this.canceledAt = stream.canceled_at.toNumber();
|
|
54
54
|
this.end = stream.end.toNumber();
|
|
55
55
|
this.lastWithdrawnAt = stream.last_withdrawn_at.toNumber();
|
|
@@ -61,20 +61,20 @@ export class EvmContract {
|
|
|
61
61
|
this.escrowTokens = "";
|
|
62
62
|
this.streamflowTreasury = "";
|
|
63
63
|
this.streamflowTreasuryTokens = "";
|
|
64
|
-
this.streamflowFeeTotal =
|
|
65
|
-
this.streamflowFeeWithdrawn =
|
|
64
|
+
this.streamflowFeeTotal = BigNumber(stream.fees.streamflow_fee.toString());
|
|
65
|
+
this.streamflowFeeWithdrawn = BigNumber(stream.fees.streamflow_fee_withdrawn.toString());
|
|
66
66
|
this.streamflowFeePercent = stream.fees.streamflow_fee_percentage.toNumber() / 10000;
|
|
67
|
-
this.partnerFeeTotal =
|
|
68
|
-
this.partnerFeeWithdrawn =
|
|
67
|
+
this.partnerFeeTotal = BigNumber(0);
|
|
68
|
+
this.partnerFeeWithdrawn = BigNumber(0);
|
|
69
69
|
this.partnerFeePercent = 0;
|
|
70
70
|
this.partner = "";
|
|
71
71
|
this.partnerTokens = "";
|
|
72
72
|
this.start = stream.start.toNumber();
|
|
73
|
-
this.depositedAmount =
|
|
73
|
+
this.depositedAmount = BigNumber(stream.amount.toString());
|
|
74
74
|
this.period = stream.period.toNumber();
|
|
75
|
-
this.amountPerPeriod =
|
|
75
|
+
this.amountPerPeriod = BigNumber(stream.amount_per_period.toString());
|
|
76
76
|
this.cliff = stream.start.toNumber();
|
|
77
|
-
this.cliffAmount =
|
|
77
|
+
this.cliffAmount = BigNumber(stream.cliff_amount.toString());
|
|
78
78
|
this.cancelableBySender = stream.meta.cancelable_by_sender;
|
|
79
79
|
this.cancelableByRecipient = stream.meta.cancelable_by_recipient;
|
|
80
80
|
this.automaticWithdrawal = stream.meta.automatic_withdrawal;
|
|
@@ -85,9 +85,9 @@ export class EvmContract {
|
|
|
85
85
|
this.withdrawalFrequency = stream.meta.withdrawal_frequency.toNumber();
|
|
86
86
|
this.closed = stream.closed;
|
|
87
87
|
this.currentPauseStart = stream.current_pause_start.toNumber();
|
|
88
|
-
this.pauseCumulative =
|
|
88
|
+
this.pauseCumulative = BigNumber(stream.pause_cumulative.toString());
|
|
89
89
|
this.lastRateChangeTime = stream.last_rate_change_time.toNumber();
|
|
90
|
-
this.fundsUnlockedAtLastRateChange =
|
|
90
|
+
this.fundsUnlockedAtLastRateChange = BigNumber(stream.funds_unlocked_at_last_rate_change.toString());
|
|
91
91
|
this.type = buildStreamType(this);
|
|
92
92
|
}
|
|
93
93
|
unlocked(currentTimestamp) {
|
|
@@ -97,6 +97,6 @@ export class EvmContract {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
remaining(decimals) {
|
|
100
|
-
return
|
|
100
|
+
return getNumberFromBigNumber(this.depositedAmount.minus(this.withdrawnAmount), decimals);
|
|
101
101
|
}
|
|
102
102
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * as StreamflowAptos from "./aptos";
|
|
2
|
-
export * as StreamflowEVM from "./evm";
|
|
3
|
-
export * as StreamflowSolana from "./solana";
|
|
4
|
-
export * as StreamflowSui from "./sui";
|
|
5
|
-
export * from "./common/types";
|
|
6
|
-
export * from "./common/utils";
|
|
7
|
-
export * from "./common/constants";
|
|
8
|
-
export * from "./common/contractUtils";
|
|
9
|
-
export { default as GenericStreamClient } from "./common/GenericStreamClient";
|
|
1
|
+
export * as StreamflowAptos from "./aptos/index.js";
|
|
2
|
+
export * as StreamflowEVM from "./evm/index.js";
|
|
3
|
+
export * as StreamflowSolana from "./solana/index.js";
|
|
4
|
+
export * as StreamflowSui from "./sui/index.js";
|
|
5
|
+
export * from "./common/types.js";
|
|
6
|
+
export * from "./common/utils.js";
|
|
7
|
+
export * from "./common/constants.js";
|
|
8
|
+
export * from "./common/contractUtils.js";
|
|
9
|
+
export { default as GenericStreamClient } from "./common/GenericStreamClient.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * as StreamflowAptos from "./aptos";
|
|
2
|
-
export * as StreamflowEVM from "./evm";
|
|
3
|
-
export * as StreamflowSolana from "./solana";
|
|
4
|
-
export * as StreamflowSui from "./sui";
|
|
5
|
-
export * from "./common/types";
|
|
6
|
-
export * from "./common/utils";
|
|
7
|
-
export * from "./common/constants";
|
|
8
|
-
export * from "./common/contractUtils";
|
|
9
|
-
export { default as GenericStreamClient } from "./common/GenericStreamClient";
|
|
1
|
+
export * as StreamflowAptos from "./aptos/index.js";
|
|
2
|
+
export * as StreamflowEVM from "./evm/index.js";
|
|
3
|
+
export * as StreamflowSolana from "./solana/index.js";
|
|
4
|
+
export * as StreamflowSui from "./sui/index.js";
|
|
5
|
+
export * from "./common/types.js";
|
|
6
|
+
export * from "./common/utils.js";
|
|
7
|
+
export * from "./common/constants.js";
|
|
8
|
+
export * from "./common/contractUtils.js";
|
|
9
|
+
export { default as GenericStreamClient } from "./common/GenericStreamClient.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PQueue from "p-queue";
|
|
2
2
|
import { Connection, Keypair, PublicKey, TransactionInstruction, Commitment, ConnectionConfig } from "@solana/web3.js";
|
|
3
|
-
import {
|
|
3
|
+
import { IProgramAccount } from "@streamflow/common/solana";
|
|
4
|
+
import { ICreateStreamSolanaExt, IInteractStreamSolanaExt, ITopUpStreamSolanaExt, ISearchStreams } from "./types.js";
|
|
4
5
|
import { ICancelData, ICluster, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, IGetAllData, IGetFeesData, IGetOneData, IFees, IMultiTransactionResult, ITopUpData, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, Stream } from "../common/types.js";
|
|
5
6
|
import { BaseStreamClient } from "../common/BaseStreamClient.js";
|
|
6
7
|
export declare class SolanaStreamClient extends BaseStreamClient {
|
|
@@ -96,6 +97,7 @@ export declare class SolanaStreamClient extends BaseStreamClient {
|
|
|
96
97
|
* Streams are sorted by start time in ascending order.
|
|
97
98
|
*/
|
|
98
99
|
get({ address, type, direction, }: IGetAllData): Promise<[string, Stream][]>;
|
|
100
|
+
searchStreams(data: ISearchStreams): Promise<IProgramAccount<Stream>[]>;
|
|
99
101
|
/**
|
|
100
102
|
* Attempts updating the stream auto withdrawal params and amount per period
|
|
101
103
|
*/
|