@streamflow/stream 7.0.0-alpha.1 → 7.0.0-alpha.3
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 +17 -18
- package/dist/cjs/__tests__/aptos/streamClient.spec.js +4 -4
- package/dist/cjs/aptos/index.js +3 -3
- package/dist/cjs/aptos/types.js +18 -18
- package/dist/cjs/common/GenericStreamClient.js +8 -8
- package/dist/cjs/common/constants.js +2 -2
- package/dist/cjs/common/contractUtils.js +6 -6
- package/dist/cjs/common/utils.js +18 -23
- package/dist/cjs/evm/StreamClient.js +7 -7
- package/dist/cjs/evm/types.js +12 -12
- package/dist/cjs/index.js +10 -10
- package/dist/cjs/solana/StreamClient.js +17 -17
- package/dist/cjs/solana/instructions.js +19 -18
- package/dist/cjs/solana/types.js +1 -1
- package/dist/cjs/solana/utils.js +38 -27
- package/dist/cjs/sui/StreamClient.js +1 -1
- package/dist/cjs/sui/types.js +12 -12
- 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.js +17 -17
- package/dist/esm/solana/instructions.d.ts +17 -17
- package/dist/esm/solana/instructions.js +19 -18
- package/dist/esm/solana/types.d.ts +36 -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 +5 -6
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
// Latest version of the SDK that does not use Anchor. It supports raw instructions.
|
|
2
|
-
import
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
3
|
import { Buffer } from "buffer";
|
|
4
4
|
import { ASSOCIATED_TOKEN_PROGRAM_ID, NATIVE_MINT } from "@solana/spl-token";
|
|
5
5
|
import { Connection, Keypair, PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY, TransactionMessage, VersionedTransaction, } from "@solana/web3.js";
|
|
@@ -82,12 +82,12 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
82
82
|
ixs.push(...(await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount)));
|
|
83
83
|
}
|
|
84
84
|
ixs.push(createStreamInstruction({
|
|
85
|
-
start:
|
|
85
|
+
start: BigNumber(start),
|
|
86
86
|
depositedAmount,
|
|
87
|
-
period:
|
|
87
|
+
period: BigNumber(period),
|
|
88
88
|
amountPerPeriod,
|
|
89
|
-
cliff:
|
|
90
|
-
cliffAmount,
|
|
89
|
+
cliff: BigNumber(cliff),
|
|
90
|
+
cliffAmount: BigNumber(cliffAmount),
|
|
91
91
|
cancelableBySender,
|
|
92
92
|
cancelableByRecipient,
|
|
93
93
|
automaticWithdrawal,
|
|
@@ -97,7 +97,7 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
97
97
|
canUpdateRate: !!canUpdateRate,
|
|
98
98
|
canPause: !!canPause,
|
|
99
99
|
name,
|
|
100
|
-
withdrawFrequency:
|
|
100
|
+
withdrawFrequency: BigNumber(automaticWithdrawal ? withdrawalFrequency : period),
|
|
101
101
|
}, this.programId, {
|
|
102
102
|
sender: sender.publicKey,
|
|
103
103
|
senderTokens,
|
|
@@ -172,12 +172,12 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
172
172
|
ixs.push(...(await prepareWrappedAccount(this.connection, sender.publicKey, totalAmount)));
|
|
173
173
|
}
|
|
174
174
|
const createInstruction = createUncheckedStreamInstruction({
|
|
175
|
-
start:
|
|
175
|
+
start: BigNumber(start),
|
|
176
176
|
depositedAmount,
|
|
177
|
-
period:
|
|
177
|
+
period: BigNumber(period),
|
|
178
178
|
amountPerPeriod,
|
|
179
|
-
cliff:
|
|
180
|
-
cliffAmount,
|
|
179
|
+
cliff: BigNumber(cliff),
|
|
180
|
+
cliffAmount: BigNumber(cliffAmount),
|
|
181
181
|
cancelableBySender,
|
|
182
182
|
cancelableByRecipient,
|
|
183
183
|
automaticWithdrawal,
|
|
@@ -187,7 +187,7 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
187
187
|
canUpdateRate: !!canUpdateRate,
|
|
188
188
|
canPause: !!canPause,
|
|
189
189
|
name,
|
|
190
|
-
withdrawFrequency:
|
|
190
|
+
withdrawFrequency: BigNumber(automaticWithdrawal ? withdrawalFrequency : period),
|
|
191
191
|
recipient: recipientPublicKey,
|
|
192
192
|
partner: partnerPublicKey,
|
|
193
193
|
}, this.programId, {
|
|
@@ -252,7 +252,7 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
252
252
|
batch.push({ tx, recipient });
|
|
253
253
|
}
|
|
254
254
|
if (isNative) {
|
|
255
|
-
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.
|
|
255
|
+
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.plus(acc), BigNumber(0));
|
|
256
256
|
const nativeInstructions = await prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
|
|
257
257
|
const messageV0 = new TransactionMessage({
|
|
258
258
|
payerKey: sender.publicKey,
|
|
@@ -624,12 +624,12 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
624
624
|
const partnerPublicKey = partner ? new PublicKey(partner) : WITHDRAWOR_PUBLIC_KEY;
|
|
625
625
|
const partnerTokens = await ata(mintPublicKey, partnerPublicKey, tokenProgramId);
|
|
626
626
|
ixs.push(createStreamInstruction({
|
|
627
|
-
start:
|
|
627
|
+
start: BigNumber(start),
|
|
628
628
|
depositedAmount: recipient.amount,
|
|
629
|
-
period:
|
|
629
|
+
period: BigNumber(period),
|
|
630
630
|
amountPerPeriod: recipient.amountPerPeriod,
|
|
631
|
-
cliff:
|
|
632
|
-
cliffAmount: recipient.cliffAmount,
|
|
631
|
+
cliff: BigNumber(cliff),
|
|
632
|
+
cliffAmount: BigNumber(recipient.cliffAmount),
|
|
633
633
|
cancelableBySender,
|
|
634
634
|
cancelableByRecipient,
|
|
635
635
|
automaticWithdrawal,
|
|
@@ -639,7 +639,7 @@ export class SolanaStreamClient extends BaseStreamClient {
|
|
|
639
639
|
canUpdateRate: !!canUpdateRate,
|
|
640
640
|
canPause: !!canPause,
|
|
641
641
|
name: recipient.name,
|
|
642
|
-
withdrawFrequency:
|
|
642
|
+
withdrawFrequency: BigNumber(automaticWithdrawal ? withdrawalFrequency : period),
|
|
643
643
|
}, this.programId, {
|
|
644
644
|
sender: sender.publicKey,
|
|
645
645
|
senderTokens,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
-
import
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
3
|
import { IUpdateData } from "../common/types.js";
|
|
4
4
|
interface CreateStreamData {
|
|
5
|
-
start:
|
|
6
|
-
depositedAmount:
|
|
7
|
-
period:
|
|
8
|
-
amountPerPeriod:
|
|
9
|
-
cliff:
|
|
10
|
-
cliffAmount:
|
|
5
|
+
start: BigNumber;
|
|
6
|
+
depositedAmount: BigNumber;
|
|
7
|
+
period: BigNumber;
|
|
8
|
+
amountPerPeriod: BigNumber;
|
|
9
|
+
cliff: BigNumber;
|
|
10
|
+
cliffAmount: BigNumber;
|
|
11
11
|
cancelableBySender: boolean;
|
|
12
12
|
cancelableByRecipient: boolean;
|
|
13
13
|
automaticWithdrawal: boolean;
|
|
@@ -17,7 +17,7 @@ interface CreateStreamData {
|
|
|
17
17
|
canUpdateRate: boolean;
|
|
18
18
|
canPause: boolean;
|
|
19
19
|
name: string;
|
|
20
|
-
withdrawFrequency:
|
|
20
|
+
withdrawFrequency: BigNumber;
|
|
21
21
|
}
|
|
22
22
|
interface CreateStreamAccounts {
|
|
23
23
|
sender: PublicKey;
|
|
@@ -41,12 +41,12 @@ interface CreateStreamAccounts {
|
|
|
41
41
|
}
|
|
42
42
|
export declare const createStreamInstruction: (data: CreateStreamData, programId: PublicKey, accounts: CreateStreamAccounts) => TransactionInstruction;
|
|
43
43
|
interface CreateUncheckedStreamData {
|
|
44
|
-
start:
|
|
45
|
-
depositedAmount:
|
|
46
|
-
period:
|
|
47
|
-
amountPerPeriod:
|
|
48
|
-
cliff:
|
|
49
|
-
cliffAmount:
|
|
44
|
+
start: BigNumber;
|
|
45
|
+
depositedAmount: BigNumber;
|
|
46
|
+
period: BigNumber;
|
|
47
|
+
amountPerPeriod: BigNumber;
|
|
48
|
+
cliff: BigNumber;
|
|
49
|
+
cliffAmount: BigNumber;
|
|
50
50
|
cancelableBySender: boolean;
|
|
51
51
|
cancelableByRecipient: boolean;
|
|
52
52
|
automaticWithdrawal: boolean;
|
|
@@ -56,7 +56,7 @@ interface CreateUncheckedStreamData {
|
|
|
56
56
|
canUpdateRate: boolean;
|
|
57
57
|
canPause: boolean;
|
|
58
58
|
name: string;
|
|
59
|
-
withdrawFrequency:
|
|
59
|
+
withdrawFrequency: BigNumber;
|
|
60
60
|
recipient: PublicKey;
|
|
61
61
|
partner: PublicKey;
|
|
62
62
|
}
|
|
@@ -88,7 +88,7 @@ interface WithdrawAccounts {
|
|
|
88
88
|
mint: PublicKey;
|
|
89
89
|
tokenProgram: PublicKey;
|
|
90
90
|
}
|
|
91
|
-
export declare const withdrawStreamInstruction: (amount:
|
|
91
|
+
export declare const withdrawStreamInstruction: (amount: BigNumber, programId: PublicKey, { authority, recipient, recipientTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, }: WithdrawAccounts) => TransactionInstruction;
|
|
92
92
|
interface UpdateAccounts {
|
|
93
93
|
authority: PublicKey;
|
|
94
94
|
metadata: PublicKey;
|
|
@@ -138,5 +138,5 @@ interface TopupAccounts {
|
|
|
138
138
|
withdrawor: PublicKey;
|
|
139
139
|
systemProgram: PublicKey;
|
|
140
140
|
}
|
|
141
|
-
export declare const topupStreamInstruction: (amount:
|
|
141
|
+
export declare const topupStreamInstruction: (amount: BigNumber, programId: PublicKey, { sender, senderTokens, metadata, escrowTokens, streamflowTreasury, streamflowTreasuryTokens, partner, partnerTokens, mint, tokenProgram, withdrawor, systemProgram, }: TopupAccounts) => TransactionInstruction;
|
|
142
142
|
export {};
|