@superfluid-finance/sdk-core 1.0.1-dev.c4f51ea.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/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/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/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,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 {};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { IConfig, IRealtimeBalanceOfParams, ISuperTokenBaseIDAParams, ISuperTokenCreateFlowParams, ISuperTokenDeleteFlowParams, ISuperTokenDistributeParams, ISuperTokenGetFlowInfoParams, ISuperTokenGetFlowParams, ISuperTokenGetIndexParams, ISuperTokenGetSubscriptionParams, ISuperTokenPublisherOperationParams, ISuperTokenPubSubParams, ISuperTokenUpdateFlowParams, ISuperTokenUpdateIndexValueParams, ISuperTokenUpdateSubscriptionUnitsParams, IWeb3FlowInfo, IWeb3Index, IWeb3RealTimeBalanceOf, IWeb3Subscription } from "./interfaces";
|
|
3
|
+
import Operation from "./Operation";
|
|
4
|
+
import ConstantFlowAgreementV1 from "./ConstantFlowAgreementV1";
|
|
5
|
+
import InstantDistributionAgreementV1 from "./InstantDistributionAgreementV1";
|
|
6
|
+
import Token from "./Token";
|
|
7
|
+
export interface ITokenSettings {
|
|
8
|
+
readonly address: string;
|
|
9
|
+
readonly config: IConfig;
|
|
10
|
+
readonly chainId: number;
|
|
11
|
+
readonly networkName: string;
|
|
12
|
+
readonly underlyingTokenAddress: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ITokenOptions {
|
|
15
|
+
readonly address: string;
|
|
16
|
+
readonly config: IConfig;
|
|
17
|
+
readonly provider: ethers.providers.Provider;
|
|
18
|
+
readonly chainId?: number;
|
|
19
|
+
readonly networkName?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @dev SuperToken Helper Class
|
|
23
|
+
* @description A helper class to create `SuperToken` objects which can interact with the `SuperToken` contract as well as the CFAV1 and IDAV1 contracts of the desired `SuperToken`.
|
|
24
|
+
*/
|
|
25
|
+
export default class SuperToken extends Token {
|
|
26
|
+
readonly options: ITokenOptions;
|
|
27
|
+
readonly settings: ITokenSettings;
|
|
28
|
+
readonly cfaV1: ConstantFlowAgreementV1;
|
|
29
|
+
readonly idaV1: InstantDistributionAgreementV1;
|
|
30
|
+
readonly underlyingToken: Token;
|
|
31
|
+
private constructor();
|
|
32
|
+
static create: (options: ITokenOptions) => Promise<SuperToken>;
|
|
33
|
+
private get superTokenContract();
|
|
34
|
+
/**
|
|
35
|
+
* @dev Returns the real time balance of `address`.
|
|
36
|
+
* @param account the target address
|
|
37
|
+
* @param timestamp the timestamp you'd like to see the data
|
|
38
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
39
|
+
* @returns {Promise<IWeb3RealTimeBalanceOf>} real time balance of data
|
|
40
|
+
*/
|
|
41
|
+
realtimeBalanceOf: ({ providerOrSigner, account, timestamp, }: IRealtimeBalanceOfParams) => Promise<IWeb3RealTimeBalanceOf>;
|
|
42
|
+
/**
|
|
43
|
+
* @dev Downgrade `amount` SuperToken's.
|
|
44
|
+
* @param amount The amount to be downgraded.
|
|
45
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
46
|
+
*/
|
|
47
|
+
downgrade: ({ amount }: {
|
|
48
|
+
amount: string;
|
|
49
|
+
}) => Operation;
|
|
50
|
+
/**
|
|
51
|
+
* @dev Upgrade `amount` SuperToken's.
|
|
52
|
+
* @param amount The amount to be upgraded.
|
|
53
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
54
|
+
*/
|
|
55
|
+
upgrade: ({ amount }: {
|
|
56
|
+
amount: string;
|
|
57
|
+
}) => Operation;
|
|
58
|
+
/**
|
|
59
|
+
* @dev Get the details of a flow.
|
|
60
|
+
* @param sender the sender of the flow
|
|
61
|
+
* @param receiver the receiver of the flow
|
|
62
|
+
* @param providerOrSigner a provider or signer object
|
|
63
|
+
* @returns {Promise<IWeb3FlowInfo>} Web3 Flow info object
|
|
64
|
+
*/
|
|
65
|
+
getFlow: ({ sender, receiver, providerOrSigner, }: ISuperTokenGetFlowParams) => Promise<IWeb3FlowInfo>;
|
|
66
|
+
/**
|
|
67
|
+
* @dev Get the flow info of an account (net flow).
|
|
68
|
+
* @param account the account we're querying
|
|
69
|
+
* @param providerOrSigner a provider or signer object
|
|
70
|
+
* @returns {Promise<IWeb3FlowInfo>} Web3 Flow info object
|
|
71
|
+
*/
|
|
72
|
+
getAccountFlowInfo: ({ account, providerOrSigner, }: ISuperTokenGetFlowInfoParams) => Promise<IWeb3FlowInfo>;
|
|
73
|
+
/**
|
|
74
|
+
* @dev Get the net flow of an account.
|
|
75
|
+
* @param account the account we're querying
|
|
76
|
+
* @param providerOrSigner a provider or signer object
|
|
77
|
+
* @returns {Promise<string>} Web3 Flow info object
|
|
78
|
+
*/
|
|
79
|
+
getNetFlow: ({ account, providerOrSigner, }: ISuperTokenGetFlowInfoParams) => Promise<string>;
|
|
80
|
+
/**
|
|
81
|
+
* @dev Create a flow of the token of this class.
|
|
82
|
+
* @param sender The sender of the flow.
|
|
83
|
+
* @param receiver The receiver of the flow.
|
|
84
|
+
* @param flowRate The specified flow rate.
|
|
85
|
+
* @param userData Extra user data provided.
|
|
86
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
87
|
+
*/
|
|
88
|
+
createFlow: ({ sender, receiver, flowRate, userData, }: ISuperTokenCreateFlowParams) => Operation;
|
|
89
|
+
/**
|
|
90
|
+
* @dev Update a flow of the token of this class.
|
|
91
|
+
* @param sender The sender of the flow.
|
|
92
|
+
* @param receiver The receiver of the flow.
|
|
93
|
+
* @param flowRate The specified flow rate.
|
|
94
|
+
* @param userData Extra user data provided.
|
|
95
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
96
|
+
*/
|
|
97
|
+
updateFlow: ({ sender, receiver, flowRate, userData, }: ISuperTokenUpdateFlowParams) => Operation;
|
|
98
|
+
/**
|
|
99
|
+
* @dev Delete a flow of the token of this class.
|
|
100
|
+
* @param sender The sender of the flow.
|
|
101
|
+
* @param receiver The receiver of the flow.
|
|
102
|
+
* @param userData Extra user data provided.
|
|
103
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
104
|
+
*/
|
|
105
|
+
deleteFlow: ({ sender, receiver, userData, }: ISuperTokenDeleteFlowParams) => Operation;
|
|
106
|
+
/**
|
|
107
|
+
* @dev Get the details of a `Subscription`.
|
|
108
|
+
* @param publisher the address of the publisher of the index
|
|
109
|
+
* @param indexId the index id
|
|
110
|
+
* @param subscriber the subscriber's address
|
|
111
|
+
* @param providerOrSigner a provider or signer object
|
|
112
|
+
* @returns {Promise<IWeb3Subscription>} Web3 Subscription object
|
|
113
|
+
*/
|
|
114
|
+
getSubscription: ({ publisher, indexId, subscriber, providerOrSigner, }: ISuperTokenGetSubscriptionParams) => Promise<IWeb3Subscription>;
|
|
115
|
+
/**
|
|
116
|
+
* @dev Get the details of an `Index`.
|
|
117
|
+
* @param publisher the address of the publisher of the index
|
|
118
|
+
* @param indexId the index id
|
|
119
|
+
* @param providerOrSigner a provider or signer object
|
|
120
|
+
* @returns {Promise<IWeb3Index>} Web3 Index object
|
|
121
|
+
*/
|
|
122
|
+
getIndex: ({ publisher, indexId, providerOrSigner, }: ISuperTokenGetIndexParams) => Promise<IWeb3Index>;
|
|
123
|
+
/**
|
|
124
|
+
* @dev Creates an IDA Index.
|
|
125
|
+
* @param indexId The id of the index.
|
|
126
|
+
* @param userData Extra user data provided.
|
|
127
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
128
|
+
*/
|
|
129
|
+
createIndex: ({ indexId, userData, }: ISuperTokenBaseIDAParams) => Operation;
|
|
130
|
+
/**
|
|
131
|
+
* @dev Distributes `amount` of token to an index
|
|
132
|
+
* @param indexId The id of the index.
|
|
133
|
+
* @param amount The amount of tokens to be distributed.
|
|
134
|
+
* @param userData Extra user data provided.
|
|
135
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
136
|
+
*/
|
|
137
|
+
distribute: ({ indexId, amount, userData, }: ISuperTokenDistributeParams) => Operation;
|
|
138
|
+
/**
|
|
139
|
+
* @dev Updates the `IndexValue` field of an index.
|
|
140
|
+
* @param indexId The id of the index.
|
|
141
|
+
* @param indexValue The new indexValue.
|
|
142
|
+
* @param userData Extra user data provided.
|
|
143
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
144
|
+
*
|
|
145
|
+
* NOTE: It has the same effect as `distribute`, but is closer to the low level data structure of the index.
|
|
146
|
+
*/
|
|
147
|
+
updateIndexValue: ({ indexId, indexValue, userData, }: ISuperTokenUpdateIndexValueParams) => Operation;
|
|
148
|
+
/**
|
|
149
|
+
* @dev Updates the `units` allocated to a Subscription.
|
|
150
|
+
* @param indexId The id of the index.
|
|
151
|
+
* @param subscriber The subscriber address whose units you want to update.
|
|
152
|
+
* @param units The amount of units you want to update to.
|
|
153
|
+
* @param userData Extra user data provided.
|
|
154
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
155
|
+
*/
|
|
156
|
+
updateSubscriptionUnits: ({ indexId, subscriber, units, userData, }: ISuperTokenUpdateSubscriptionUnitsParams) => Operation;
|
|
157
|
+
/**
|
|
158
|
+
* @dev Approves a Subscription, so the Subscriber won't need to claim tokens when the Publisher distributes.
|
|
159
|
+
* @param indexId The id of the index.
|
|
160
|
+
* @param publisher The publisher address whose subscription you want to approve.
|
|
161
|
+
* @param userData Extra user data provided.
|
|
162
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
163
|
+
*/
|
|
164
|
+
approveSubscription: ({ indexId, publisher, userData, }: ISuperTokenPublisherOperationParams) => Operation;
|
|
165
|
+
/**
|
|
166
|
+
* @dev Revokes a Subscription, so the Subscriber will need to claim tokens when the Publisher distributes.
|
|
167
|
+
* @param indexId The id of the index.
|
|
168
|
+
* @param publisher The index publisher address you want to revoke for the subscriber.
|
|
169
|
+
* @param userData Extra user data provided.
|
|
170
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
171
|
+
*/
|
|
172
|
+
revokeSubscription: ({ indexId, publisher, userData, }: ISuperTokenPublisherOperationParams) => Operation;
|
|
173
|
+
/**
|
|
174
|
+
* @dev Deletes a Subscription by setting the `units` allocated to the Subscriber to 0.
|
|
175
|
+
* @param indexId The id of the index.
|
|
176
|
+
* @param subscriber The subscriber address whose subscription you want to delete.
|
|
177
|
+
* @param publisher The publisher address of the index you are targeting.
|
|
178
|
+
* @param userData Extra user data provided.
|
|
179
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
180
|
+
*/
|
|
181
|
+
deleteSubscription: ({ indexId, subscriber, publisher, userData, }: ISuperTokenPubSubParams) => Operation;
|
|
182
|
+
/**
|
|
183
|
+
* @dev Claims any pending tokens allocated to the Subscription (unapproved).
|
|
184
|
+
* @param indexId The id of the index.
|
|
185
|
+
* @param subscriber The subscriber address who you are claiming for.
|
|
186
|
+
* @param publisher The publisher address of the index you are targeting.
|
|
187
|
+
* @param userData Extra user data provided.
|
|
188
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
189
|
+
*/
|
|
190
|
+
claim: ({ indexId, subscriber, publisher, userData, }: ISuperTokenPubSubParams) => Operation;
|
|
191
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { IBaseSuperTokenParams, ITransferFromParams } from "./interfaces";
|
|
3
|
+
import Operation from "./Operation";
|
|
4
|
+
export default class Token {
|
|
5
|
+
readonly address: string;
|
|
6
|
+
constructor(address: string);
|
|
7
|
+
private get tokenContract();
|
|
8
|
+
/**
|
|
9
|
+
* @dev Returns the allowance the `owner` has granted the `spender`.
|
|
10
|
+
* @param owner the owner who has allotted the allowance
|
|
11
|
+
* @param spender the spender who has received the allowance
|
|
12
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
13
|
+
* @returns {Promise<string>} the allowance amount
|
|
14
|
+
*/
|
|
15
|
+
allowance: ({ owner, spender, providerOrSigner, }: {
|
|
16
|
+
owner: string;
|
|
17
|
+
spender: string;
|
|
18
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer;
|
|
19
|
+
}) => Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* @dev Returns the ERC20 balanceOf the `account`, this can't be negative and will just display 0.
|
|
22
|
+
* @param account the account you would like to query
|
|
23
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
24
|
+
* @returns {Promise<string>} the token balance of `account`
|
|
25
|
+
*/
|
|
26
|
+
balanceOf: ({ account, providerOrSigner, }: {
|
|
27
|
+
account: string;
|
|
28
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer;
|
|
29
|
+
}) => Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* @dev Returns the token name
|
|
32
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
33
|
+
* @returns {string} the token name
|
|
34
|
+
*/
|
|
35
|
+
name: ({ providerOrSigner, }: {
|
|
36
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer;
|
|
37
|
+
}) => Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* @dev Returns the token symbol
|
|
40
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
41
|
+
* @returns {string} the token symbol
|
|
42
|
+
*/
|
|
43
|
+
symbol: ({ providerOrSigner, }: {
|
|
44
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer;
|
|
45
|
+
}) => Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* @dev Returns the total supply of the token.
|
|
48
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
49
|
+
* @returns {Promise<string>} the total supply of the token
|
|
50
|
+
*/
|
|
51
|
+
totalSupply: ({ providerOrSigner, }: {
|
|
52
|
+
providerOrSigner: ethers.providers.Provider | ethers.Signer;
|
|
53
|
+
}) => Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* @dev Approve `receiver` to spend `amount` tokens.
|
|
56
|
+
* @param receiver The receiver approved.
|
|
57
|
+
* @param amount The amount approved.
|
|
58
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
59
|
+
*/
|
|
60
|
+
approve: ({ receiver, amount }: IBaseSuperTokenParams) => Operation;
|
|
61
|
+
/**
|
|
62
|
+
* @dev Transfer `receiver` `amount` tokens.
|
|
63
|
+
* @param receiver The receiver of the transfer.
|
|
64
|
+
* @param amount The amount to be transferred.
|
|
65
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
66
|
+
*/
|
|
67
|
+
transfer: ({ receiver, amount }: IBaseSuperTokenParams) => Operation;
|
|
68
|
+
/**
|
|
69
|
+
* @dev Transfer from `sender` to `receiver` `amount` tokens.
|
|
70
|
+
* @param sender The sender of the transfer.
|
|
71
|
+
* @param receiver The receiver of the transfer.
|
|
72
|
+
* @param amount The amount to be transferred.
|
|
73
|
+
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
74
|
+
*/
|
|
75
|
+
transferFrom: ({ sender, receiver, amount, }: ITransferFromParams) => Operation;
|
|
76
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IResolverData } from "./interfaces";
|
|
2
|
+
export declare const MONTHS_PER_YEAR = 12;
|
|
3
|
+
export declare const DAYS_PER_MONTH = 30;
|
|
4
|
+
export declare const HOURS_PER_DAY = 24;
|
|
5
|
+
export declare const MINUTES_PER_HOUR = 60;
|
|
6
|
+
export declare const SECONDS_PER_MINUTE = 60;
|
|
7
|
+
export declare const chainIds: number[];
|
|
8
|
+
export declare const networkNames: string[];
|
|
9
|
+
export declare const chainIdToDataMap: Map<number, IResolverData>;
|
|
10
|
+
export declare const networkNameToChainIdMap: Map<string, number>;
|