@superfluid-finance/sdk-core 1.0.1-dev.ac1b585.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/LICENSE +9 -0
- package/README.md +487 -0
- package/dist/main/BatchCall.d.ts +53 -0
- package/dist/main/ConstantFlowAgreementV1.d.ts +74 -0
- package/dist/main/Framework.d.ts +75 -0
- package/dist/main/Host.d.ts +18 -0
- package/dist/main/InstantDistributionAgreementV1.d.ts +107 -0
- package/dist/main/Operation.d.ts +38 -0
- package/dist/main/Query.d.ts +24 -0
- package/dist/main/SFError.d.ts +13 -0
- package/dist/main/SuperToken.d.ts +191 -0
- package/dist/main/Token.d.ts +76 -0
- package/dist/main/constants.d.ts +10 -0
- package/dist/main/events.d.ts +254 -0
- package/dist/main/frameworkHelpers.d.ts +20 -0
- package/dist/main/index.d.ts +19 -0
- package/dist/main/index.js +10780 -0
- package/dist/main/interfaces.d.ts +309 -0
- package/dist/main/mapGetAllEventsQueryEvents.d.ts +3 -0
- package/dist/main/pagination.d.ts +31 -0
- package/dist/main/scripts/setup.d.ts +22 -0
- package/dist/main/subgraph/SubgraphClient.d.ts +16 -0
- package/dist/main/subgraph/queries/getAccountTokenSnapshots.generated.d.ts +41 -0
- package/dist/main/subgraph/queries/getAllEvents.generated.d.ts +578 -0
- package/dist/main/subgraph/queries/getIndexSubscriptions.generated.d.ts +42 -0
- package/dist/main/subgraph/queries/getIndexes.generated.d.ts +40 -0
- package/dist/main/subgraph/queries/getStreams.generated.d.ts +54 -0
- package/dist/main/subgraph/queries/getTokens.generated.d.ts +23 -0
- package/dist/main/subgraph/schema.generated.d.ts +6907 -0
- package/dist/main/typechain/ERC20WithTokenInfo.d.ts +159 -0
- package/dist/main/typechain/IConstantFlowAgreementV1.d.ts +305 -0
- package/dist/main/typechain/IInstantDistributionAgreementV1.d.ts +585 -0
- package/dist/main/typechain/IResolver.d.ts +57 -0
- package/dist/main/typechain/SuperToken.d.ts +1011 -0
- package/dist/main/typechain/Superfluid.d.ts +780 -0
- package/dist/main/typechain/SuperfluidLoader.d.ts +55 -0
- package/dist/main/typechain/TestToken.d.ts +207 -0
- package/dist/main/typechain/common.d.ts +21 -0
- package/dist/main/typechain/factories/ERC20WithTokenInfo__factory.d.ts +35 -0
- package/dist/main/typechain/factories/IConstantFlowAgreementV1__factory.d.ts +35 -0
- package/dist/main/typechain/factories/IInstantDistributionAgreementV1__factory.d.ts +35 -0
- package/dist/main/typechain/factories/IResolver__factory.d.ts +22 -0
- package/dist/main/typechain/factories/SuperToken__factory.d.ts +46 -0
- package/dist/main/typechain/factories/SuperfluidLoader__factory.d.ts +37 -0
- package/dist/main/typechain/factories/Superfluid__factory.d.ts +82 -0
- package/dist/main/typechain/factories/TestToken__factory.d.ts +46 -0
- package/dist/main/typechain/index.d.ts +16 -0
- package/dist/main/types.d.ts +2 -0
- package/dist/main/utils.d.ts +89 -0
- package/dist/main/validation.d.ts +8 -0
- package/dist/module/BatchCall.d.ts +53 -0
- package/dist/module/ConstantFlowAgreementV1.d.ts +74 -0
- package/dist/module/Framework.d.ts +75 -0
- package/dist/module/Host.d.ts +18 -0
- package/dist/module/InstantDistributionAgreementV1.d.ts +107 -0
- package/dist/module/Operation.d.ts +38 -0
- package/dist/module/Query.d.ts +24 -0
- package/dist/module/SFError.d.ts +13 -0
- package/dist/module/SuperToken.d.ts +191 -0
- package/dist/module/Token.d.ts +76 -0
- package/dist/module/constants.d.ts +10 -0
- package/dist/module/events.d.ts +254 -0
- package/dist/module/frameworkHelpers.d.ts +20 -0
- package/dist/module/index.d.ts +19 -0
- package/dist/module/index.js +10749 -0
- package/dist/module/interfaces.d.ts +309 -0
- package/dist/module/mapGetAllEventsQueryEvents.d.ts +3 -0
- package/dist/module/pagination.d.ts +31 -0
- package/dist/module/scripts/setup.d.ts +22 -0
- package/dist/module/subgraph/SubgraphClient.d.ts +16 -0
- package/dist/module/subgraph/queries/getAccountTokenSnapshots.generated.d.ts +41 -0
- package/dist/module/subgraph/queries/getAllEvents.generated.d.ts +578 -0
- package/dist/module/subgraph/queries/getIndexSubscriptions.generated.d.ts +42 -0
- package/dist/module/subgraph/queries/getIndexes.generated.d.ts +40 -0
- package/dist/module/subgraph/queries/getStreams.generated.d.ts +54 -0
- package/dist/module/subgraph/queries/getTokens.generated.d.ts +23 -0
- package/dist/module/subgraph/schema.generated.d.ts +6907 -0
- package/dist/module/typechain/ERC20WithTokenInfo.d.ts +159 -0
- package/dist/module/typechain/IConstantFlowAgreementV1.d.ts +305 -0
- package/dist/module/typechain/IInstantDistributionAgreementV1.d.ts +585 -0
- package/dist/module/typechain/IResolver.d.ts +57 -0
- package/dist/module/typechain/SuperToken.d.ts +1011 -0
- package/dist/module/typechain/Superfluid.d.ts +780 -0
- package/dist/module/typechain/SuperfluidLoader.d.ts +55 -0
- package/dist/module/typechain/TestToken.d.ts +207 -0
- package/dist/module/typechain/common.d.ts +21 -0
- package/dist/module/typechain/factories/ERC20WithTokenInfo__factory.d.ts +35 -0
- package/dist/module/typechain/factories/IConstantFlowAgreementV1__factory.d.ts +35 -0
- package/dist/module/typechain/factories/IInstantDistributionAgreementV1__factory.d.ts +35 -0
- package/dist/module/typechain/factories/IResolver__factory.d.ts +22 -0
- package/dist/module/typechain/factories/SuperToken__factory.d.ts +46 -0
- package/dist/module/typechain/factories/SuperfluidLoader__factory.d.ts +37 -0
- package/dist/module/typechain/factories/Superfluid__factory.d.ts +82 -0
- package/dist/module/typechain/factories/TestToken__factory.d.ts +46 -0
- package/dist/module/typechain/index.d.ts +16 -0
- package/dist/module/types.d.ts +2 -0
- package/dist/module/utils.d.ts +89 -0
- package/dist/module/validation.d.ts +8 -0
- package/dist/umd/BatchCall.d.ts +53 -0
- package/dist/umd/ConstantFlowAgreementV1.d.ts +74 -0
- package/dist/umd/Framework.d.ts +75 -0
- package/dist/umd/Host.d.ts +18 -0
- package/dist/umd/InstantDistributionAgreementV1.d.ts +107 -0
- package/dist/umd/Operation.d.ts +38 -0
- package/dist/umd/Query.d.ts +24 -0
- package/dist/umd/SFError.d.ts +13 -0
- package/dist/umd/SuperToken.d.ts +191 -0
- package/dist/umd/Token.d.ts +76 -0
- package/dist/umd/constants.d.ts +10 -0
- package/dist/umd/events.d.ts +254 -0
- package/dist/umd/frameworkHelpers.d.ts +20 -0
- package/dist/umd/index.d.ts +19 -0
- package/dist/umd/index.js +10782 -0
- package/dist/umd/interfaces.d.ts +309 -0
- package/dist/umd/mapGetAllEventsQueryEvents.d.ts +3 -0
- package/dist/umd/pagination.d.ts +31 -0
- package/dist/umd/scripts/setup.d.ts +22 -0
- package/dist/umd/subgraph/SubgraphClient.d.ts +16 -0
- package/dist/umd/subgraph/queries/getAccountTokenSnapshots.generated.d.ts +41 -0
- package/dist/umd/subgraph/queries/getAllEvents.generated.d.ts +578 -0
- package/dist/umd/subgraph/queries/getIndexSubscriptions.generated.d.ts +42 -0
- package/dist/umd/subgraph/queries/getIndexes.generated.d.ts +40 -0
- package/dist/umd/subgraph/queries/getStreams.generated.d.ts +54 -0
- package/dist/umd/subgraph/queries/getTokens.generated.d.ts +23 -0
- package/dist/umd/subgraph/schema.generated.d.ts +6907 -0
- package/dist/umd/typechain/ERC20WithTokenInfo.d.ts +159 -0
- package/dist/umd/typechain/IConstantFlowAgreementV1.d.ts +305 -0
- package/dist/umd/typechain/IInstantDistributionAgreementV1.d.ts +585 -0
- package/dist/umd/typechain/IResolver.d.ts +57 -0
- package/dist/umd/typechain/SuperToken.d.ts +1011 -0
- package/dist/umd/typechain/Superfluid.d.ts +780 -0
- package/dist/umd/typechain/SuperfluidLoader.d.ts +55 -0
- package/dist/umd/typechain/TestToken.d.ts +207 -0
- package/dist/umd/typechain/common.d.ts +21 -0
- package/dist/umd/typechain/factories/ERC20WithTokenInfo__factory.d.ts +35 -0
- package/dist/umd/typechain/factories/IConstantFlowAgreementV1__factory.d.ts +35 -0
- package/dist/umd/typechain/factories/IInstantDistributionAgreementV1__factory.d.ts +35 -0
- package/dist/umd/typechain/factories/IResolver__factory.d.ts +22 -0
- package/dist/umd/typechain/factories/SuperToken__factory.d.ts +46 -0
- package/dist/umd/typechain/factories/SuperfluidLoader__factory.d.ts +37 -0
- package/dist/umd/typechain/factories/Superfluid__factory.d.ts +82 -0
- package/dist/umd/typechain/factories/TestToken__factory.d.ts +46 -0
- package/dist/umd/typechain/index.d.ts +16 -0
- package/dist/umd/types.d.ts +2 -0
- package/dist/umd/utils.d.ts +89 -0
- package/dist/umd/validation.d.ts +8 -0
- package/package.json +76 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { JsonFragment } from "@ethersproject/abi";
|
|
2
|
+
import { ethers } from "ethers";
|
|
3
|
+
import { IIndexSubscription } from "./interfaces";
|
|
4
|
+
/**
|
|
5
|
+
* @dev Checks if address is a valid ethereum address and normalizes so it can be used by both subgraph and web3.
|
|
6
|
+
* @param address
|
|
7
|
+
* @returns The normalized address.
|
|
8
|
+
*/
|
|
9
|
+
export declare const normalizeAddress: (address?: string | undefined) => string;
|
|
10
|
+
export declare const isNullOrEmpty: (str: string | null | undefined) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* @dev Removes the 8-character signature hash from `callData`.
|
|
13
|
+
* @param callData
|
|
14
|
+
* @returns function parameters
|
|
15
|
+
*/
|
|
16
|
+
export declare const removeSigHashFromCallData: (callData: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* @dev A wrapper function for getting the ethers TransactionDescription object given fragments (e.g. ABI), callData and the value amount sent.
|
|
19
|
+
* @param fragments ABI
|
|
20
|
+
* @param data callData of a function
|
|
21
|
+
* @param value amount of ether sent
|
|
22
|
+
* @returns ethers.TransactionDescription object
|
|
23
|
+
*/
|
|
24
|
+
export declare const getTransactionDescription: (fragments: string | readonly (string | ethers.utils.Fragment | JsonFragment)[], data: string, value?: string | undefined) => ethers.utils.TransactionDescription;
|
|
25
|
+
/**
|
|
26
|
+
* @dev Gets the per second flow rate given an `amountPerYear` value.
|
|
27
|
+
* @param amountPerYear the amount you want to stream per year
|
|
28
|
+
* @returns flow rate per second
|
|
29
|
+
*/
|
|
30
|
+
export declare const getPerSecondFlowRateByYear: (amountPerYear: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* @dev Gets the per second flow rate given an `amountPerMonth` value.
|
|
33
|
+
* @param amountPerMonth the amount you want to stream per month
|
|
34
|
+
* @returns flow rate per second
|
|
35
|
+
*/
|
|
36
|
+
export declare const getPerSecondFlowRateByMonth: (amountPerMonth: string) => string;
|
|
37
|
+
/**
|
|
38
|
+
* @dev Gets the per second flow rate given an `amountPerDay` value.
|
|
39
|
+
* @param amountPerDay the amount you want to stream per day
|
|
40
|
+
* @returns flow rate per second
|
|
41
|
+
*/
|
|
42
|
+
export declare const getPerSecondFlowRateByDay: (amountPerDay: string) => string;
|
|
43
|
+
/**
|
|
44
|
+
* @dev The formula for calculating the flowed amount since updated using Subgraph data.
|
|
45
|
+
* @param netFlowRate the net flow rate of the user
|
|
46
|
+
* @param currentTimestamp the current timestamp
|
|
47
|
+
* @param updatedAtTimestamp the updated at timestamp of the `AccountTokenSnapshot` entity
|
|
48
|
+
* @returns the flowed amount since the updatedAt timestamp
|
|
49
|
+
*/
|
|
50
|
+
export declare const flowedAmountSinceUpdatedAt: ({ netFlowRate, currentTimestamp, updatedAtTimestamp, }: {
|
|
51
|
+
netFlowRate: string;
|
|
52
|
+
currentTimestamp: string;
|
|
53
|
+
updatedAtTimestamp: string;
|
|
54
|
+
}) => number;
|
|
55
|
+
/**
|
|
56
|
+
* @dev The formula for calculating the total amount distributed to the subscriber (pending or received).
|
|
57
|
+
* @param indexSubscriptions the index subscriptions of a single token from an account.
|
|
58
|
+
* @returns the total amount received since updated at (both pending and actually distributed)
|
|
59
|
+
*/
|
|
60
|
+
export declare const subscriptionTotalAmountDistributedSinceUpdated: (indexSubscriptions: IIndexSubscription[]) => number;
|
|
61
|
+
/**
|
|
62
|
+
* @dev The formula for calculating the total amount received (approved subscriptions).
|
|
63
|
+
* @param indexSubscriptions the index subscriptions of a single token from an account.
|
|
64
|
+
* @returns the total amount received since updated at (actually distributed into wallet)
|
|
65
|
+
*/
|
|
66
|
+
export declare const subscriptionTotalAmountReceivedSinceUpdated: (indexSubscriptions: IIndexSubscription[]) => number;
|
|
67
|
+
/**
|
|
68
|
+
* @dev The formula for calculating the total amount that is claimable.
|
|
69
|
+
* @param indexSubscriptions the index subscriptions of a single token from an account.
|
|
70
|
+
* @returns the total amount that can be claimed since updated at
|
|
71
|
+
*/
|
|
72
|
+
export declare const subscriptionTotalAmountClaimableSinceUpdatedAt: (indexSubscriptions: IIndexSubscription[]) => number;
|
|
73
|
+
export declare const getStringCurrentTimeInSeconds: () => number;
|
|
74
|
+
export declare const getSanitizedTimestamp: (timestamp: ethers.BigNumberish) => Date;
|
|
75
|
+
/**
|
|
76
|
+
* @dev The formula for calculating the balance until updated at of a user (claimable + received tokens from index)
|
|
77
|
+
* @param currentBalance the current balance until updated at from the `AccountTokenSnapshot` entity
|
|
78
|
+
* @param netFlowRate the net flow rate of the user
|
|
79
|
+
* @param currentTimestamp the current timestamp
|
|
80
|
+
* @param updatedAtTimestamp the updated at timestamp of the `AccountTokenSnapshot` entity
|
|
81
|
+
* @returns the balance since the updated at timestamp
|
|
82
|
+
*/
|
|
83
|
+
export declare const getBalance: ({ currentBalance, netFlowRate, currentTimestamp, updatedAtTimestamp, indexSubscriptions, }: {
|
|
84
|
+
currentBalance: string;
|
|
85
|
+
netFlowRate: string;
|
|
86
|
+
currentTimestamp: string;
|
|
87
|
+
updatedAtTimestamp: string;
|
|
88
|
+
indexSubscriptions: IIndexSubscription[];
|
|
89
|
+
}) => number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IEventFilter } from ".";
|
|
2
|
+
import { IAccountTokenSnapshotFilter, IIndexRequestFilter, IIndexSubscriptionRequestFilter, IStreamRequestFilter, ISuperTokenRequestFilter } from "./interfaces";
|
|
3
|
+
export declare const validateSuperTokenRequest: (filter: ISuperTokenRequestFilter) => void;
|
|
4
|
+
export declare const validateEventRequest: (filter: IEventFilter) => void;
|
|
5
|
+
export declare const validateIndexRequest: (filter: IIndexRequestFilter) => void;
|
|
6
|
+
export declare const validateIndexSubscriptionRequest: (filter: IIndexSubscriptionRequestFilter) => void;
|
|
7
|
+
export declare const validateStreamRequest: (filter: IStreamRequestFilter) => void;
|
|
8
|
+
export declare const validateAccountTokenSnapshotRequest: (filter: IAccountTokenSnapshotFilter) => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import Host from "./Host";
|
|
3
|
+
import { IConfig } from "./interfaces";
|
|
4
|
+
import Operation from "./Operation";
|
|
5
|
+
interface IBatchCallOptions {
|
|
6
|
+
config: IConfig;
|
|
7
|
+
operations: ReadonlyArray<Operation>;
|
|
8
|
+
}
|
|
9
|
+
interface OperationStruct {
|
|
10
|
+
readonly operationType: number;
|
|
11
|
+
readonly target: string;
|
|
12
|
+
readonly data: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @dev BatchCall Helper Class
|
|
16
|
+
* @description A helper class to create `BatchCall` objects which can be executed.
|
|
17
|
+
*/
|
|
18
|
+
export default class BatchCall {
|
|
19
|
+
options: IBatchCallOptions;
|
|
20
|
+
host: Host;
|
|
21
|
+
constructor(options: IBatchCallOptions);
|
|
22
|
+
/**
|
|
23
|
+
* @dev Gets the call agreement function arguments.
|
|
24
|
+
* @param callData callData of the function
|
|
25
|
+
* @returns {ethers.utils.Result} call agreement function arguments
|
|
26
|
+
*/
|
|
27
|
+
getCallAgreementFunctionArgs: (callData: string) => ethers.utils.Result;
|
|
28
|
+
/**
|
|
29
|
+
* @dev Given an `Operation` object, gets the `OperationStruct` object.
|
|
30
|
+
* @param operation an `Operation` object
|
|
31
|
+
* @param index the index of the `Operation` in the batchCall
|
|
32
|
+
* @returns {Promise<OperationStruct>} OperationStruct object for batchCall
|
|
33
|
+
*/
|
|
34
|
+
getOperationStruct: (operation: Operation, index: number) => Promise<OperationStruct>;
|
|
35
|
+
/**
|
|
36
|
+
* @dev Gets an array of `OperationStruct` objects to be passed to batchCall.
|
|
37
|
+
* @returns {Promise<OperationStruct>[]} array of operation struct promises
|
|
38
|
+
*/
|
|
39
|
+
get getOperationStructArrayPromises(): Promise<OperationStruct>[];
|
|
40
|
+
/**
|
|
41
|
+
* @dev Executes a batch call given the operations on this class.
|
|
42
|
+
* @param signer the signer of the transaction
|
|
43
|
+
* @returns {Promise<ethers.ContractTransaction>} ContractTransaction object
|
|
44
|
+
*/
|
|
45
|
+
exec: (signer: ethers.Signer) => Promise<ethers.ContractTransaction>;
|
|
46
|
+
/**
|
|
47
|
+
* @dev Executes a forward batch call given the operations on this class.
|
|
48
|
+
* @param signer the signer of the transaction
|
|
49
|
+
* @returns {Promise<ethers.ContractTransaction>} ContractTransaction object
|
|
50
|
+
*/
|
|
51
|
+
execForward: (signer: ethers.Signer) => Promise<ethers.ContractTransaction>;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { IAgreementV1Options, ICreateFlowParams, IDeleteFlowParams, IUpdateFlowParams, IGetFlowParams, IGetAccountFlowInfoParams, IWeb3FlowInfoParams, IWeb3FlowInfo } from "./interfaces";
|
|
2
|
+
import Operation from "./Operation";
|
|
3
|
+
import Host from "./Host";
|
|
4
|
+
/**
|
|
5
|
+
* @dev Constant Flow Agreement V1 Helper Class
|
|
6
|
+
* @description A helper class to interact with the CFAV1 contract.
|
|
7
|
+
*/
|
|
8
|
+
export default class ConstantFlowAgreementV1 {
|
|
9
|
+
readonly options: IAgreementV1Options;
|
|
10
|
+
readonly host: Host;
|
|
11
|
+
constructor(options: IAgreementV1Options);
|
|
12
|
+
private get cfaContract();
|
|
13
|
+
/**
|
|
14
|
+
* @dev Get the details of a flow.
|
|
15
|
+
* @param superToken the superToken of the agreement
|
|
16
|
+
* @param sender the sender of the flow
|
|
17
|
+
* @param receiver the receiver of the flow
|
|
18
|
+
* @param providerOrSigner a provider or signer object
|
|
19
|
+
* @returns {Promise<IWeb3FlowInfo>} Web3 Flow info object
|
|
20
|
+
*/
|
|
21
|
+
getFlow: ({ superToken, sender, receiver, providerOrSigner, }: IGetFlowParams) => Promise<IWeb3FlowInfo>;
|
|
22
|
+
/**
|
|
23
|
+
* @dev Get the flow info of an account (net flow).
|
|
24
|
+
* @param superToken the superToken of the agreement
|
|
25
|
+
* @param account the account we're querying
|
|
26
|
+
* @param providerOrSigner a provider or signer object
|
|
27
|
+
* @returns {Promise<IWeb3FlowInfo>} Web3 Flow info object
|
|
28
|
+
*/
|
|
29
|
+
getAccountFlowInfo: ({ superToken, account, providerOrSigner, }: IGetAccountFlowInfoParams) => Promise<IWeb3FlowInfo>;
|
|
30
|
+
/**
|
|
31
|
+
* @dev Get the net flow of an account.
|
|
32
|
+
* @param superToken the superToken of the agreement
|
|
33
|
+
* @param account the account we're querying
|
|
34
|
+
* @param providerOrSigner a provider or signer object
|
|
35
|
+
* @returns {Promise<string>} Web3 Flow info object
|
|
36
|
+
*/
|
|
37
|
+
getNetFlow: ({ superToken, account, providerOrSigner, }: IGetAccountFlowInfoParams) => Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* @dev Create a flow.
|
|
40
|
+
* @param flowRate The specified flow rate.
|
|
41
|
+
* @param receiver The receiver of the flow.
|
|
42
|
+
* @param superToken The token to be flowed.
|
|
43
|
+
* @param userData Extra user data provided.
|
|
44
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
45
|
+
*/
|
|
46
|
+
createFlow: ({ flowRate, receiver, superToken, userData, }: ICreateFlowParams) => Operation;
|
|
47
|
+
/**
|
|
48
|
+
* @dev Update a flow.
|
|
49
|
+
* @param flowRate The specified flow rate.
|
|
50
|
+
* @param receiver The receiver of the flow.
|
|
51
|
+
* @param superToken The token to be flowed.
|
|
52
|
+
* @param userData Extra user data provided.
|
|
53
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
54
|
+
*/
|
|
55
|
+
updateFlow: ({ flowRate, receiver, superToken, userData, }: IUpdateFlowParams) => Operation;
|
|
56
|
+
/**
|
|
57
|
+
* @dev Delete a flow.
|
|
58
|
+
* @param superToken The token to be flowed.
|
|
59
|
+
* @param sender The sender of the flow.
|
|
60
|
+
* @param receiver The receiver of the flow.
|
|
61
|
+
* @param userData Extra user data provided.
|
|
62
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
63
|
+
*/
|
|
64
|
+
deleteFlow: ({ superToken, sender, receiver, userData, }: IDeleteFlowParams) => Operation;
|
|
65
|
+
/**
|
|
66
|
+
* @dev Sanitizes flow info, converting BigNumber to string.
|
|
67
|
+
* @param timestamp last updated timestamp of flow
|
|
68
|
+
* @param flowRate the current flow rate
|
|
69
|
+
* @param deposit the deposit amount
|
|
70
|
+
* @param owedDeposit any owed depsit
|
|
71
|
+
* @returns {IWeb3FlowInfo} sanitized web3 flow info
|
|
72
|
+
*/
|
|
73
|
+
_sanitizeflowInfo: ({ timestamp, flowRate, deposit, owedDeposit, }: IWeb3FlowInfoParams) => IWeb3FlowInfo;
|
|
74
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { Signer } from "@ethersproject/abstract-signer";
|
|
3
|
+
import { IConfig, ISignerConstructorOptions } from "./interfaces";
|
|
4
|
+
import { DataMode } from "./types";
|
|
5
|
+
import BatchCall from "./BatchCall";
|
|
6
|
+
import ConstantFlowAgreementV1 from "./ConstantFlowAgreementV1";
|
|
7
|
+
import Host from "./Host";
|
|
8
|
+
import InstantDistributionAgreementV1 from "./InstantDistributionAgreementV1";
|
|
9
|
+
import SuperToken from "./SuperToken";
|
|
10
|
+
import Query from "./Query";
|
|
11
|
+
import Operation from "./Operation";
|
|
12
|
+
export interface IFrameworkOptions {
|
|
13
|
+
chainId?: number;
|
|
14
|
+
customSubgraphQueriesEndpoint?: string;
|
|
15
|
+
dataMode?: DataMode;
|
|
16
|
+
networkName?: string;
|
|
17
|
+
resolverAddress?: string;
|
|
18
|
+
protocolReleaseVersion?: string;
|
|
19
|
+
provider: ethers.providers.Provider;
|
|
20
|
+
}
|
|
21
|
+
export interface IFrameworkSettings {
|
|
22
|
+
chainId: number;
|
|
23
|
+
customSubgraphQueriesEndpoint: string;
|
|
24
|
+
dataMode: DataMode;
|
|
25
|
+
networkName: string;
|
|
26
|
+
protocolReleaseVersion: string;
|
|
27
|
+
provider: ethers.providers.Provider;
|
|
28
|
+
config: IConfig;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @dev Superfluid Framework Class
|
|
32
|
+
* @description The entrypoint for the SDK-core, `create` an instance of this for full functionality.
|
|
33
|
+
*/
|
|
34
|
+
export default class Framework {
|
|
35
|
+
readonly userInputOptions: IFrameworkOptions;
|
|
36
|
+
settings: IFrameworkSettings;
|
|
37
|
+
cfaV1: ConstantFlowAgreementV1;
|
|
38
|
+
host: Host;
|
|
39
|
+
idaV1: InstantDistributionAgreementV1;
|
|
40
|
+
query: Query;
|
|
41
|
+
private constructor();
|
|
42
|
+
/**
|
|
43
|
+
* @dev Creates the Framework object based on user provided `options`.
|
|
44
|
+
* @param options.chainId the chainId of your desired network (e.g. 137 = matic)
|
|
45
|
+
* @param options.customSubgraphQueriesEndpoint your custom subgraph endpoint
|
|
46
|
+
* @param options.dataMode the data mode you'd like the framework to use (SUBGRAPH_ONLY, SUBGRAPH_WEB3, WEB3_ONLY)
|
|
47
|
+
* @param options.networkName the desired network (e.g. "matic", "rinkeby", etc.)
|
|
48
|
+
* @param options.resolverAddress a custom resolver address (advanced use for testing)
|
|
49
|
+
* @param options.protocolReleaseVersion a custom release version (advanced use for testing)
|
|
50
|
+
* @param options.provider a provider object necessary for initializing the framework
|
|
51
|
+
* @returns `Framework` class
|
|
52
|
+
*/
|
|
53
|
+
static create: (options: IFrameworkOptions) => Promise<Framework>;
|
|
54
|
+
/**
|
|
55
|
+
* @dev Create a signer which can be used to sign transactions.
|
|
56
|
+
* @param options.web3Provider a Web3Provider object (e.g. client side - metamask, web3modal)
|
|
57
|
+
* @param options.provider an ethers Provider object (e.g. via Hardhat ethers)
|
|
58
|
+
* @param options.privateKey a test account private key
|
|
59
|
+
* @param options.signer a signer object (e.g. ethers.Wallet instance)
|
|
60
|
+
* @returns `ethers.Signer` object
|
|
61
|
+
*/
|
|
62
|
+
createSigner: (options: ISignerConstructorOptions) => Signer;
|
|
63
|
+
/**
|
|
64
|
+
* @dev Create a `BatchCall` class from the `Framework`.
|
|
65
|
+
* @param operations the list of operations to execute
|
|
66
|
+
* @returns `BatchCall` class
|
|
67
|
+
*/
|
|
68
|
+
batchCall: (operations: Operation[]) => BatchCall;
|
|
69
|
+
/**
|
|
70
|
+
* @dev Load a `SuperToken` class from the `Framework`.
|
|
71
|
+
* @param address the `SuperToken` address
|
|
72
|
+
* @returns `SuperToken` class
|
|
73
|
+
*/
|
|
74
|
+
loadSuperToken: (address: string) => Promise<SuperToken>;
|
|
75
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Operation from "./Operation";
|
|
2
|
+
import { Superfluid } from "./typechain";
|
|
3
|
+
/**
|
|
4
|
+
* @dev Host Helper Class
|
|
5
|
+
* @description A helper class which can be used as a standalone class to populate call agreement transactions.
|
|
6
|
+
*/
|
|
7
|
+
export default class Host {
|
|
8
|
+
hostContract: Superfluid;
|
|
9
|
+
constructor(hostAddress: string);
|
|
10
|
+
/**
|
|
11
|
+
* @dev Creates an Operation of the `callAgreement` function on the host contract.
|
|
12
|
+
* @param agreementAddress the agreement address (cfa or ida address)
|
|
13
|
+
* @param callData the encoded callData for the function
|
|
14
|
+
* @param userData any additional user data
|
|
15
|
+
* @returns {Operation} an `Operation` class
|
|
16
|
+
*/
|
|
17
|
+
populateCallAgreementTxnAndReturnOperation: (agreementAddress: string, callData: string, userData: string | undefined) => Operation;
|
|
18
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { IAgreementV1Options, IBaseIDAParams, IBaseSubscriptionParams, IDistributeParams, IGetIndexParams, IGetSubscriptionParams, IUpdateIndexValueParams, IUpdateSubscriptionUnitsParams, IWeb3Index, IWeb3Subscription } from "./interfaces";
|
|
2
|
+
import Operation from "./Operation";
|
|
3
|
+
import Host from "./Host";
|
|
4
|
+
/**
|
|
5
|
+
* @dev Instant Distribution Agreement V1 Helper Class
|
|
6
|
+
* @description A helper class to interact with the IDAV1 contract.
|
|
7
|
+
*/
|
|
8
|
+
export default class InstantDistributionAgreementV1 {
|
|
9
|
+
readonly options: IAgreementV1Options;
|
|
10
|
+
readonly host: Host;
|
|
11
|
+
constructor(options: IAgreementV1Options);
|
|
12
|
+
private get idaContract();
|
|
13
|
+
/**
|
|
14
|
+
* @dev Get the details of a `Subscription`.
|
|
15
|
+
* @param superToken the superToken of the agreement
|
|
16
|
+
* @param publisher the address of the publisher of the index
|
|
17
|
+
* @param indexId the index id
|
|
18
|
+
* @param subscriber the subscriber's address
|
|
19
|
+
* @param providerOrSigner a provider or signer object
|
|
20
|
+
* @returns {Promise<IWeb3Subscription>} Web3 Subscription object
|
|
21
|
+
*/
|
|
22
|
+
getSubscription: ({ superToken, publisher, indexId, subscriber, providerOrSigner, }: IGetSubscriptionParams) => Promise<IWeb3Subscription>;
|
|
23
|
+
/**
|
|
24
|
+
* @dev Get the details of an `Index`.
|
|
25
|
+
* @param superToken the superToken of the agreement
|
|
26
|
+
* @param publisher the address of the publisher of the index
|
|
27
|
+
* @param indexId the index id
|
|
28
|
+
* @param providerOrSigner a provider or signer object
|
|
29
|
+
* @returns {Promise<IWeb3Index>} Web3 Index object
|
|
30
|
+
*/
|
|
31
|
+
getIndex: ({ superToken, publisher, indexId, providerOrSigner, }: IGetIndexParams) => Promise<IWeb3Index>;
|
|
32
|
+
/**
|
|
33
|
+
* @dev Creates an IDA Index.
|
|
34
|
+
* @param indexId The id of the index.
|
|
35
|
+
* @param superToken The address of the `index` superToken.
|
|
36
|
+
* @param userData Extra user data provided.
|
|
37
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
38
|
+
*/
|
|
39
|
+
createIndex: ({ indexId, superToken, userData, }: IBaseIDAParams) => Operation;
|
|
40
|
+
/**
|
|
41
|
+
* @dev Distributes `amount` of `superToken` to an index
|
|
42
|
+
* @param indexId The id of the index.
|
|
43
|
+
* @param amount The amount of `superToken` to be distributed.
|
|
44
|
+
* @param superToken The superToken to be distributed.
|
|
45
|
+
* @param userData Extra user data provided.
|
|
46
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
47
|
+
*/
|
|
48
|
+
distribute: ({ indexId, amount, superToken, userData, }: IDistributeParams) => Operation;
|
|
49
|
+
/**
|
|
50
|
+
* @dev Updates the `indexValue` of an index.
|
|
51
|
+
* @description NOTE: It has the same effect as `distribute`, but is closer to the low level data structure of the index.
|
|
52
|
+
* @param indexId The id of the index.
|
|
53
|
+
* @param indexValue The new indexValue.
|
|
54
|
+
* @param superToken The superToken to be distributed.
|
|
55
|
+
* @param userData Extra user data provided.
|
|
56
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
57
|
+
*/
|
|
58
|
+
updateIndexValue: ({ indexId, indexValue, superToken, userData, }: IUpdateIndexValueParams) => Operation;
|
|
59
|
+
/**
|
|
60
|
+
* @dev Updates the `units` allocated to a Subscription.
|
|
61
|
+
* @param indexId The id of the index.
|
|
62
|
+
* @param superToken The superToken of the index.
|
|
63
|
+
* @param subscriber The subscriber address whose units you want to update.
|
|
64
|
+
* @param units The amount of units you want to update to.
|
|
65
|
+
* @param userData Extra user data provided.
|
|
66
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
67
|
+
*/
|
|
68
|
+
updateSubscriptionUnits: ({ indexId, superToken, subscriber, units, userData, }: IUpdateSubscriptionUnitsParams) => Operation;
|
|
69
|
+
/**
|
|
70
|
+
* @dev Approves a Subscription, so the Subscriber won't need to claim tokens when the Publisher distributes.
|
|
71
|
+
* @param indexId The id of the index.
|
|
72
|
+
* @param superToken The superToken of the index.
|
|
73
|
+
* @param publisher The publisher of the index you want to approve.
|
|
74
|
+
* @param userData Extra user data provided.
|
|
75
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
76
|
+
*/
|
|
77
|
+
approveSubscription: ({ indexId, superToken, publisher, userData, }: IBaseIDAParams) => Operation;
|
|
78
|
+
/**
|
|
79
|
+
* @dev Revokes a Subscription, so the Subscriber will need to claim tokens when the Publisher distributres.
|
|
80
|
+
* @param indexId The id of the index.
|
|
81
|
+
* @param superToken The superToken of the index.
|
|
82
|
+
* @param subscriber The subscriber address whose subscription you want to revoke.
|
|
83
|
+
* @param userData Extra user data provided.
|
|
84
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
85
|
+
*/
|
|
86
|
+
revokeSubscription: ({ indexId, superToken, publisher, userData, }: IBaseIDAParams) => Operation;
|
|
87
|
+
/**
|
|
88
|
+
* @dev Deletes a Subscription by setting the `units` allocated to the Subscriber to 0.
|
|
89
|
+
* @param indexId The id of the index.
|
|
90
|
+
* @param superToken The superToken of the index.
|
|
91
|
+
* @param subscriber The subscriber address whose subscription you want to delete.
|
|
92
|
+
* @param publisher The publisher address of the index you are targetting.
|
|
93
|
+
* @param userData Extra user data provided.
|
|
94
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
95
|
+
*/
|
|
96
|
+
deleteSubscription: ({ indexId, superToken, subscriber, publisher, userData, }: IBaseSubscriptionParams) => Operation;
|
|
97
|
+
/**
|
|
98
|
+
* @dev Claims any pending tokens allocated to the Subscription (unapproved).
|
|
99
|
+
* @param indexId The id of the index.
|
|
100
|
+
* @param superToken The superToken of the index.
|
|
101
|
+
* @param subscriber The subscriber address whose subscription you want to delete.
|
|
102
|
+
* @param publisher The publisher address of the index you are targetting.
|
|
103
|
+
* @param userData Extra user data provided.
|
|
104
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
105
|
+
*/
|
|
106
|
+
claim: ({ indexId, superToken, subscriber, publisher, userData, }: IBaseSubscriptionParams) => Operation;
|
|
107
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { TransactionRequest } from "@ethersproject/abstract-provider";
|
|
2
|
+
import { ethers } from "ethers";
|
|
3
|
+
export declare type OperationType = "UNSUPPORTED" | "ERC20_APPROVE" | "ERC20_TRANSFER_FROM" | "SUPERTOKEN_UPGRADE" | "SUPERTOKEN_DOWNGRADE" | "SUPERFLUID_CALL_AGREEMENT" | "CALL_APP_ACTION";
|
|
4
|
+
/**
|
|
5
|
+
* @dev Operation Helper Class
|
|
6
|
+
* @description A helper class to create `Operation` objects which can be executed or batched.
|
|
7
|
+
*/
|
|
8
|
+
export default class Operation {
|
|
9
|
+
readonly populateTransactionPromise: Promise<ethers.PopulatedTransaction>;
|
|
10
|
+
readonly type: OperationType;
|
|
11
|
+
constructor(txn: Promise<ethers.PopulatedTransaction>, type: OperationType);
|
|
12
|
+
/**
|
|
13
|
+
* @dev Executes the operation via the provided signer.
|
|
14
|
+
* @description Populates all fields of the transaction, signs it and sends it to the network.
|
|
15
|
+
* @param signer The signer of the transacation
|
|
16
|
+
* @returns {ethers.providers.TransactionResponse} A TransactionResponse object which can be awaited
|
|
17
|
+
*/
|
|
18
|
+
exec: (signer: ethers.Signer) => Promise<ethers.providers.TransactionResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* @dev Get the populated transaction by awaiting `populateTransactionPromise`.
|
|
21
|
+
* @description Note that we need to populate the txn with the signer.
|
|
22
|
+
* @returns {Promise<TransactionRequest>}
|
|
23
|
+
*/
|
|
24
|
+
getPopulatedTransactionRequest: (signer: ethers.Signer) => Promise<TransactionRequest>;
|
|
25
|
+
/**
|
|
26
|
+
* @dev Signs the populated transaction via the provided signer (what you intend on sending to the network).
|
|
27
|
+
* @param signer The signer of the transacation
|
|
28
|
+
* @returns {Promise<string>} Fully serialized, signed transaction
|
|
29
|
+
*/
|
|
30
|
+
getSignedTransaction: (signer: ethers.Signer) => Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* @dev Gets the transaction hash of the transaction.
|
|
33
|
+
* @description Calculates this by getting the keccak256 hash of the signedTxn.
|
|
34
|
+
* @param signer The signer of the transacation
|
|
35
|
+
* @returns {Promise<string>} The transaction hash of the transaction
|
|
36
|
+
*/
|
|
37
|
+
getTransactionHash: (signer: ethers.Signer) => Promise<string>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IAccountTokenSnapshotFilter, IIndex, IIndexRequestFilter, IIndexSubscription, IIndexSubscriptionRequestFilter, ILightAccountTokenSnapshot, IStream, IStreamRequestFilter, ISuperToken, ISuperTokenRequestFilter } from "./interfaces";
|
|
2
|
+
import { DataMode } from "./types";
|
|
3
|
+
import { PagedResult, Paging } from "./pagination";
|
|
4
|
+
import { AccountEvents, AllEvents, IEventFilter } from "./events";
|
|
5
|
+
export interface IQueryOptions {
|
|
6
|
+
readonly customSubgraphQueriesEndpoint: string;
|
|
7
|
+
readonly dataMode: DataMode;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @dev Query Helper Class
|
|
11
|
+
* @description A helper class to create `Query` objects which can be used to query different data.
|
|
12
|
+
*/
|
|
13
|
+
export default class Query {
|
|
14
|
+
options: IQueryOptions;
|
|
15
|
+
private subgraphClient;
|
|
16
|
+
constructor(options: IQueryOptions);
|
|
17
|
+
listAllSuperTokens: (filter: ISuperTokenRequestFilter, paging?: Paging) => Promise<PagedResult<ISuperToken>>;
|
|
18
|
+
listIndexes: (filter: IIndexRequestFilter, paging?: Paging) => Promise<PagedResult<IIndex>>;
|
|
19
|
+
listIndexSubscriptions: (filter: IIndexSubscriptionRequestFilter, paging?: Paging) => Promise<PagedResult<IIndexSubscription>>;
|
|
20
|
+
listStreams: (filter: IStreamRequestFilter, paging?: Paging) => Promise<PagedResult<IStream>>;
|
|
21
|
+
listUserInteractedSuperTokens: (filter: IAccountTokenSnapshotFilter, paging?: Paging) => Promise<PagedResult<ILightAccountTokenSnapshot>>;
|
|
22
|
+
listEvents: (filter: IEventFilter, paging?: Paging) => Promise<PagedResult<AllEvents>>;
|
|
23
|
+
on(callback: (events: AccountEvents[], unsubscribe: () => void) => void, ms: number, account: string, timeout?: number): () => void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare type ErrorType = "FRAMEWORK_INITIALIZATION" | "SUPERTOKEN_INITIALIZATION" | "CREATE_SIGNER" | "SUPERTOKEN_READ" | "SUBGRAPH_ERROR" | "CFAV1_READ" | "IDAV1_READ" | "INVALID_ADDRESS" | "INVALID_OBJECT" | "EXECUTE_TRANSACTION" | "POPULATE_TRANSACTION" | "SIGN_TRANSACTION" | "UNSUPPORTED_OPERATION" | "MISSING_TRANSACTION_PROPERTIES" | "BATCH_CALL_ERROR" | "NETWORK_MISMATCH" | "UNSUPPORTED_WEB_3_ONLY";
|
|
2
|
+
interface ISFErrorProps {
|
|
3
|
+
type: ErrorType;
|
|
4
|
+
customMessage: string;
|
|
5
|
+
errorObject?: any;
|
|
6
|
+
}
|
|
7
|
+
export default class SFError {
|
|
8
|
+
readonly type: ErrorType;
|
|
9
|
+
readonly message: string;
|
|
10
|
+
readonly errorObject?: any;
|
|
11
|
+
constructor(props: ISFErrorProps);
|
|
12
|
+
}
|
|
13
|
+
export {};
|