@superfluid-finance/sdk-core 1.0.1-dev.0846cd5.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.
Files changed (147) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +487 -0
  3. package/dist/main/BatchCall.d.ts +53 -0
  4. package/dist/main/ConstantFlowAgreementV1.d.ts +74 -0
  5. package/dist/main/Framework.d.ts +75 -0
  6. package/dist/main/Host.d.ts +18 -0
  7. package/dist/main/InstantDistributionAgreementV1.d.ts +107 -0
  8. package/dist/main/Operation.d.ts +38 -0
  9. package/dist/main/Query.d.ts +24 -0
  10. package/dist/main/SFError.d.ts +13 -0
  11. package/dist/main/SuperToken.d.ts +191 -0
  12. package/dist/main/Token.d.ts +76 -0
  13. package/dist/main/constants.d.ts +10 -0
  14. package/dist/main/events.d.ts +254 -0
  15. package/dist/main/frameworkHelpers.d.ts +20 -0
  16. package/dist/main/index.d.ts +19 -0
  17. package/dist/main/index.js +10780 -0
  18. package/dist/main/interfaces.d.ts +309 -0
  19. package/dist/main/mapGetAllEventsQueryEvents.d.ts +3 -0
  20. package/dist/main/pagination.d.ts +31 -0
  21. package/dist/main/scripts/setup.d.ts +22 -0
  22. package/dist/main/subgraph/SubgraphClient.d.ts +16 -0
  23. package/dist/main/subgraph/queries/getAccountTokenSnapshots.generated.d.ts +41 -0
  24. package/dist/main/subgraph/queries/getAllEvents.generated.d.ts +578 -0
  25. package/dist/main/subgraph/queries/getIndexSubscriptions.generated.d.ts +42 -0
  26. package/dist/main/subgraph/queries/getIndexes.generated.d.ts +40 -0
  27. package/dist/main/subgraph/queries/getStreams.generated.d.ts +54 -0
  28. package/dist/main/subgraph/queries/getTokens.generated.d.ts +23 -0
  29. package/dist/main/subgraph/schema.generated.d.ts +6907 -0
  30. package/dist/main/typechain/ERC20WithTokenInfo.d.ts +159 -0
  31. package/dist/main/typechain/IConstantFlowAgreementV1.d.ts +305 -0
  32. package/dist/main/typechain/IInstantDistributionAgreementV1.d.ts +585 -0
  33. package/dist/main/typechain/IResolver.d.ts +57 -0
  34. package/dist/main/typechain/SuperToken.d.ts +1011 -0
  35. package/dist/main/typechain/Superfluid.d.ts +780 -0
  36. package/dist/main/typechain/SuperfluidLoader.d.ts +55 -0
  37. package/dist/main/typechain/TestToken.d.ts +207 -0
  38. package/dist/main/typechain/common.d.ts +21 -0
  39. package/dist/main/typechain/factories/ERC20WithTokenInfo__factory.d.ts +35 -0
  40. package/dist/main/typechain/factories/IConstantFlowAgreementV1__factory.d.ts +35 -0
  41. package/dist/main/typechain/factories/IInstantDistributionAgreementV1__factory.d.ts +35 -0
  42. package/dist/main/typechain/factories/IResolver__factory.d.ts +22 -0
  43. package/dist/main/typechain/factories/SuperToken__factory.d.ts +46 -0
  44. package/dist/main/typechain/factories/SuperfluidLoader__factory.d.ts +37 -0
  45. package/dist/main/typechain/factories/Superfluid__factory.d.ts +82 -0
  46. package/dist/main/typechain/factories/TestToken__factory.d.ts +46 -0
  47. package/dist/main/typechain/index.d.ts +16 -0
  48. package/dist/main/types.d.ts +2 -0
  49. package/dist/main/utils.d.ts +89 -0
  50. package/dist/main/validation.d.ts +8 -0
  51. package/dist/module/BatchCall.d.ts +53 -0
  52. package/dist/module/ConstantFlowAgreementV1.d.ts +74 -0
  53. package/dist/module/Framework.d.ts +75 -0
  54. package/dist/module/Host.d.ts +18 -0
  55. package/dist/module/InstantDistributionAgreementV1.d.ts +107 -0
  56. package/dist/module/Operation.d.ts +38 -0
  57. package/dist/module/Query.d.ts +24 -0
  58. package/dist/module/SFError.d.ts +13 -0
  59. package/dist/module/SuperToken.d.ts +191 -0
  60. package/dist/module/Token.d.ts +76 -0
  61. package/dist/module/constants.d.ts +10 -0
  62. package/dist/module/events.d.ts +254 -0
  63. package/dist/module/frameworkHelpers.d.ts +20 -0
  64. package/dist/module/index.d.ts +19 -0
  65. package/dist/module/index.js +10749 -0
  66. package/dist/module/interfaces.d.ts +309 -0
  67. package/dist/module/mapGetAllEventsQueryEvents.d.ts +3 -0
  68. package/dist/module/pagination.d.ts +31 -0
  69. package/dist/module/scripts/setup.d.ts +22 -0
  70. package/dist/module/subgraph/SubgraphClient.d.ts +16 -0
  71. package/dist/module/subgraph/queries/getAccountTokenSnapshots.generated.d.ts +41 -0
  72. package/dist/module/subgraph/queries/getAllEvents.generated.d.ts +578 -0
  73. package/dist/module/subgraph/queries/getIndexSubscriptions.generated.d.ts +42 -0
  74. package/dist/module/subgraph/queries/getIndexes.generated.d.ts +40 -0
  75. package/dist/module/subgraph/queries/getStreams.generated.d.ts +54 -0
  76. package/dist/module/subgraph/queries/getTokens.generated.d.ts +23 -0
  77. package/dist/module/subgraph/schema.generated.d.ts +6907 -0
  78. package/dist/module/typechain/ERC20WithTokenInfo.d.ts +159 -0
  79. package/dist/module/typechain/IConstantFlowAgreementV1.d.ts +305 -0
  80. package/dist/module/typechain/IInstantDistributionAgreementV1.d.ts +585 -0
  81. package/dist/module/typechain/IResolver.d.ts +57 -0
  82. package/dist/module/typechain/SuperToken.d.ts +1011 -0
  83. package/dist/module/typechain/Superfluid.d.ts +780 -0
  84. package/dist/module/typechain/SuperfluidLoader.d.ts +55 -0
  85. package/dist/module/typechain/TestToken.d.ts +207 -0
  86. package/dist/module/typechain/common.d.ts +21 -0
  87. package/dist/module/typechain/factories/ERC20WithTokenInfo__factory.d.ts +35 -0
  88. package/dist/module/typechain/factories/IConstantFlowAgreementV1__factory.d.ts +35 -0
  89. package/dist/module/typechain/factories/IInstantDistributionAgreementV1__factory.d.ts +35 -0
  90. package/dist/module/typechain/factories/IResolver__factory.d.ts +22 -0
  91. package/dist/module/typechain/factories/SuperToken__factory.d.ts +46 -0
  92. package/dist/module/typechain/factories/SuperfluidLoader__factory.d.ts +37 -0
  93. package/dist/module/typechain/factories/Superfluid__factory.d.ts +82 -0
  94. package/dist/module/typechain/factories/TestToken__factory.d.ts +46 -0
  95. package/dist/module/typechain/index.d.ts +16 -0
  96. package/dist/module/types.d.ts +2 -0
  97. package/dist/module/utils.d.ts +89 -0
  98. package/dist/module/validation.d.ts +8 -0
  99. package/dist/umd/BatchCall.d.ts +53 -0
  100. package/dist/umd/ConstantFlowAgreementV1.d.ts +74 -0
  101. package/dist/umd/Framework.d.ts +75 -0
  102. package/dist/umd/Host.d.ts +18 -0
  103. package/dist/umd/InstantDistributionAgreementV1.d.ts +107 -0
  104. package/dist/umd/Operation.d.ts +38 -0
  105. package/dist/umd/Query.d.ts +24 -0
  106. package/dist/umd/SFError.d.ts +13 -0
  107. package/dist/umd/SuperToken.d.ts +191 -0
  108. package/dist/umd/Token.d.ts +76 -0
  109. package/dist/umd/constants.d.ts +10 -0
  110. package/dist/umd/events.d.ts +254 -0
  111. package/dist/umd/frameworkHelpers.d.ts +20 -0
  112. package/dist/umd/index.d.ts +19 -0
  113. package/dist/umd/index.js +10782 -0
  114. package/dist/umd/interfaces.d.ts +309 -0
  115. package/dist/umd/mapGetAllEventsQueryEvents.d.ts +3 -0
  116. package/dist/umd/pagination.d.ts +31 -0
  117. package/dist/umd/scripts/setup.d.ts +22 -0
  118. package/dist/umd/subgraph/SubgraphClient.d.ts +16 -0
  119. package/dist/umd/subgraph/queries/getAccountTokenSnapshots.generated.d.ts +41 -0
  120. package/dist/umd/subgraph/queries/getAllEvents.generated.d.ts +578 -0
  121. package/dist/umd/subgraph/queries/getIndexSubscriptions.generated.d.ts +42 -0
  122. package/dist/umd/subgraph/queries/getIndexes.generated.d.ts +40 -0
  123. package/dist/umd/subgraph/queries/getStreams.generated.d.ts +54 -0
  124. package/dist/umd/subgraph/queries/getTokens.generated.d.ts +23 -0
  125. package/dist/umd/subgraph/schema.generated.d.ts +6907 -0
  126. package/dist/umd/typechain/ERC20WithTokenInfo.d.ts +159 -0
  127. package/dist/umd/typechain/IConstantFlowAgreementV1.d.ts +305 -0
  128. package/dist/umd/typechain/IInstantDistributionAgreementV1.d.ts +585 -0
  129. package/dist/umd/typechain/IResolver.d.ts +57 -0
  130. package/dist/umd/typechain/SuperToken.d.ts +1011 -0
  131. package/dist/umd/typechain/Superfluid.d.ts +780 -0
  132. package/dist/umd/typechain/SuperfluidLoader.d.ts +55 -0
  133. package/dist/umd/typechain/TestToken.d.ts +207 -0
  134. package/dist/umd/typechain/common.d.ts +21 -0
  135. package/dist/umd/typechain/factories/ERC20WithTokenInfo__factory.d.ts +35 -0
  136. package/dist/umd/typechain/factories/IConstantFlowAgreementV1__factory.d.ts +35 -0
  137. package/dist/umd/typechain/factories/IInstantDistributionAgreementV1__factory.d.ts +35 -0
  138. package/dist/umd/typechain/factories/IResolver__factory.d.ts +22 -0
  139. package/dist/umd/typechain/factories/SuperToken__factory.d.ts +46 -0
  140. package/dist/umd/typechain/factories/SuperfluidLoader__factory.d.ts +37 -0
  141. package/dist/umd/typechain/factories/Superfluid__factory.d.ts +82 -0
  142. package/dist/umd/typechain/factories/TestToken__factory.d.ts +46 -0
  143. package/dist/umd/typechain/index.d.ts +16 -0
  144. package/dist/umd/types.d.ts +2 -0
  145. package/dist/umd/utils.d.ts +89 -0
  146. package/dist/umd/validation.d.ts +8 -0
  147. 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;
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@superfluid-finance/sdk-core",
3
+ "version": "1.0.1-dev.0846cd5.0",
4
+ "description": "SDK Core for building with Superfluid Protocol",
5
+ "homepage": "https://github.com/superfluid-finance/protocol-monorepo/tree/dev/packages/sdk-core#readme",
6
+ "repository": "github:superfluid-finance/protocol-monorepo",
7
+ "license": "MIT",
8
+ "main": "dist/main/index.js",
9
+ "module": "dist/module/index.js",
10
+ "types": "dist/main/index.d.ts",
11
+ "files": [
12
+ "dist/**/*.js",
13
+ "dist/**/*.d.ts"
14
+ ],
15
+ "scripts": {
16
+ "build": "yarn generate-abi-files && yarn generate-web3-types && rm -rf dist && rollup --config rollup.config.ts --configPlugin typescript",
17
+ "testenv:start": "tasks/testenv-ctl.sh start",
18
+ "testenv:stop": "tasks/testenv-ctl.sh stop",
19
+ "pretest": "yarn testenv:start",
20
+ "test": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter=html --reporter=lcov --reporter=json npx hardhat test --network localhost",
21
+ "posttest": "yarn testenv:stop",
22
+ "doc:html": "typedoc src/ --exclude **/*.spec.ts --target ES6 --mode file --out build/docs",
23
+ "fix": "run-s fix:*",
24
+ "fix:prettier": "prettier \"src/**/*.ts\" --write",
25
+ "fix:lint": "eslint src --ext .ts --fix",
26
+ "lint": "echo linting",
27
+ "pre-commit": "run-s pre-commit:*",
28
+ "pre-commit:lint": "echo no pre-commit currently",
29
+ "generate-abi-files": "rm -rf src/abi && mkdir src/abi && tasks/build-abi-json.sh",
30
+ "generate-web3-types": "typechain --target=ethers-v5 --out-dir=./src/typechain \"./src/abi/**/*.json\"",
31
+ "generate-graphql-types": "graphql-codegen --config subgraph-codegen.yml && yarn run fix"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/superfluid-finance/protocol-monorepo/issues"
35
+ },
36
+ "dependencies": {
37
+ "@ethersproject/providers": "^5.5.0",
38
+ "@rollup/plugin-json": "^4.1.0",
39
+ "ajv": "^8.6.3",
40
+ "ethers": "^5.5.1",
41
+ "graphql-request": "^3.6.1"
42
+ },
43
+ "devDependencies": {
44
+ "@graphql-codegen/cli": "2.2.2",
45
+ "@graphql-codegen/introspection": "2.1.0",
46
+ "@graphql-codegen/near-operation-file-preset": "^1.18.1",
47
+ "@graphql-codegen/typed-document-node": "^2.2.0",
48
+ "@graphql-codegen/typescript": "2.3.0",
49
+ "@graphql-codegen/typescript-operations": "2.2.0",
50
+ "@nomiclabs/hardhat-ethers": "^2.0.2",
51
+ "@nomiclabs/hardhat-waffle": "^2.0.1",
52
+ "@nomiclabs/hardhat-web3": "^2.0.0",
53
+ "@rollup/plugin-typescript": "^8.3.0",
54
+ "@typechain/ethers-v5": "^8.0.0",
55
+ "@typechain/hardhat": "^3.0.0",
56
+ "@types/chai": "^4.2.22",
57
+ "@types/mocha": "^9.0.0",
58
+ "@types/node": "^16.11.6",
59
+ "chai": "^4.3.4",
60
+ "chai-ethers": "^0.0.1",
61
+ "coveralls": "^3.1.1",
62
+ "dotenv": "^10.0.0",
63
+ "ethereum-waffle": "^3.4.0",
64
+ "hardhat": "^2.6.7",
65
+ "mocha": "^9.1.3",
66
+ "nyc": "^15.1.0",
67
+ "rollup": "^2.58.0",
68
+ "ts-node": "^10.4.0",
69
+ "typechain": "^6.0.0",
70
+ "typedoc": "^0.22.6",
71
+ "typescript": "^4.4.4"
72
+ },
73
+ "resolutions": {
74
+ "graphql": "16.0.0"
75
+ }
76
+ }