@superfluid-finance/sdk-core 0.3.3-dev.24f280c.0 → 0.3.3-dev.5923a95.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/CHANGELOG.md +6 -0
- package/README.md +2 -0
- package/dist/index.umd.js +29317 -25731
- package/dist/main/BatchCall.d.ts +6 -6
- package/dist/main/BatchCall.js +8 -8
- package/dist/main/BatchCall.js.map +1 -1
- package/dist/main/ConstantFlowAgreementV1.d.ts +109 -17
- package/dist/main/ConstantFlowAgreementV1.d.ts.map +1 -1
- package/dist/main/ConstantFlowAgreementV1.js +245 -50
- package/dist/main/ConstantFlowAgreementV1.js.map +1 -1
- package/dist/main/ERC20Token.d.ts +15 -12
- package/dist/main/ERC20Token.d.ts.map +1 -1
- package/dist/main/ERC20Token.js +26 -30
- package/dist/main/ERC20Token.js.map +1 -1
- package/dist/main/Framework.d.ts +16 -7
- package/dist/main/Framework.d.ts.map +1 -1
- package/dist/main/Framework.js +34 -15
- package/dist/main/Framework.js.map +1 -1
- package/dist/main/Governance.d.ts +40 -0
- package/dist/main/Governance.d.ts.map +1 -0
- package/dist/main/Governance.js +82 -0
- package/dist/main/Governance.js.map +1 -0
- package/dist/main/Host.d.ts +3 -3
- package/dist/main/Host.d.ts.map +1 -1
- package/dist/main/Host.js +4 -4
- package/dist/main/Host.js.map +1 -1
- package/dist/main/InstantDistributionAgreementV1.d.ts +25 -22
- package/dist/main/InstantDistributionAgreementV1.d.ts.map +1 -1
- package/dist/main/InstantDistributionAgreementV1.js +69 -71
- package/dist/main/InstantDistributionAgreementV1.js.map +1 -1
- package/dist/main/Operation.d.ts +5 -5
- package/dist/main/Operation.js +5 -5
- package/dist/main/Query.d.ts +1 -1
- package/dist/main/Query.js +1 -1
- package/dist/main/SFError.d.ts +1 -1
- package/dist/main/SFError.d.ts.map +1 -1
- package/dist/main/SFError.js +2 -0
- package/dist/main/SFError.js.map +1 -1
- package/dist/main/SuperToken.d.ts +228 -67
- package/dist/main/SuperToken.d.ts.map +1 -1
- package/dist/main/SuperToken.js +316 -130
- package/dist/main/SuperToken.js.map +1 -1
- package/dist/main/abi/IConstantFlowAgreementV1.json +350 -2
- package/dist/main/abi/ISETH.json +1604 -0
- package/dist/main/abi/SuperfluidGovernanceII.json +939 -0
- package/dist/main/constants.d.ts +4 -0
- package/dist/main/constants.d.ts.map +1 -1
- package/dist/main/constants.js +19 -1
- package/dist/main/constants.js.map +1 -1
- package/dist/main/events.d.ts +14 -2
- package/dist/main/events.d.ts.map +1 -1
- package/dist/main/frameworkHelpers.d.ts +2 -2
- package/dist/main/frameworkHelpers.js +2 -2
- package/dist/main/index.d.ts +14 -6
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +9 -1
- package/dist/main/index.js.map +1 -1
- package/dist/main/interfaces.d.ts +82 -8
- package/dist/main/interfaces.d.ts.map +1 -1
- package/dist/main/mapGetAllEventsQueryEvents.d.ts.map +1 -1
- package/dist/main/mapGetAllEventsQueryEvents.js +22 -1
- package/dist/main/mapGetAllEventsQueryEvents.js.map +1 -1
- package/dist/main/pagination.d.ts +4 -4
- package/dist/main/pagination.js +2 -2
- package/dist/main/subgraph/events/events.generated.d.ts +46 -3
- package/dist/main/subgraph/events/events.generated.d.ts.map +1 -1
- package/dist/main/subgraph/events/events.generated.js +4 -3
- package/dist/main/subgraph/events/events.generated.js.map +1 -1
- package/dist/main/subgraph/queries/getAllEvents.generated.d.ts +12 -0
- package/dist/main/subgraph/queries/getAllEvents.generated.d.ts.map +1 -1
- package/dist/main/subgraph/queries/getAllEvents.generated.js +1 -1
- package/dist/main/subgraph/queries/getAllEvents.generated.js.map +1 -1
- package/dist/main/subgraph/schema.generated.d.ts +817 -5
- package/dist/main/subgraph/schema.generated.d.ts.map +1 -1
- package/dist/main/typechain/IConstantFlowAgreementV1.d.ts +187 -5
- package/dist/main/typechain/IConstantFlowAgreementV1.d.ts.map +1 -1
- package/dist/main/typechain/ISETH.d.ts +1068 -0
- package/dist/main/typechain/ISETH.d.ts.map +1 -0
- package/dist/main/typechain/ISETH.js +3 -0
- package/dist/main/typechain/ISETH.js.map +1 -0
- package/dist/main/typechain/SuperfluidGovernanceII.d.ts +633 -0
- package/dist/main/typechain/SuperfluidGovernanceII.d.ts.map +1 -0
- package/dist/main/typechain/SuperfluidGovernanceII.js +3 -0
- package/dist/main/typechain/SuperfluidGovernanceII.js.map +1 -0
- package/dist/main/typechain/factories/IConstantFlowAgreementV1__factory.d.ts.map +1 -1
- package/dist/main/typechain/factories/IConstantFlowAgreementV1__factory.js +350 -2
- package/dist/main/typechain/factories/IConstantFlowAgreementV1__factory.js.map +1 -1
- package/dist/main/typechain/factories/ISETH__factory.d.ts +36 -0
- package/dist/main/typechain/factories/ISETH__factory.d.ts.map +1 -0
- package/dist/main/typechain/factories/ISETH__factory.js +1622 -0
- package/dist/main/typechain/factories/ISETH__factory.js.map +1 -0
- package/dist/main/typechain/factories/SuperfluidGovernanceII__factory.d.ts +36 -0
- package/dist/main/typechain/factories/SuperfluidGovernanceII__factory.d.ts.map +1 -0
- package/dist/main/typechain/factories/SuperfluidGovernanceII__factory.js +957 -0
- package/dist/main/typechain/factories/SuperfluidGovernanceII__factory.js.map +1 -0
- package/dist/main/typechain/index.d.ts +4 -0
- package/dist/main/typechain/index.d.ts.map +1 -1
- package/dist/main/typechain/index.js +5 -1
- package/dist/main/typechain/index.js.map +1 -1
- package/dist/main/utils.d.ts +15 -13
- package/dist/main/utils.d.ts.map +1 -1
- package/dist/main/utils.js +29 -15
- package/dist/main/utils.js.map +1 -1
- package/dist/module/BatchCall.d.ts +6 -6
- package/dist/module/BatchCall.js +8 -8
- package/dist/module/BatchCall.js.map +1 -1
- package/dist/module/ConstantFlowAgreementV1.d.ts +109 -17
- package/dist/module/ConstantFlowAgreementV1.d.ts.map +1 -1
- package/dist/module/ConstantFlowAgreementV1.js +246 -51
- package/dist/module/ConstantFlowAgreementV1.js.map +1 -1
- package/dist/module/ERC20Token.d.ts +15 -12
- package/dist/module/ERC20Token.d.ts.map +1 -1
- package/dist/module/ERC20Token.js +26 -30
- package/dist/module/ERC20Token.js.map +1 -1
- package/dist/module/Framework.d.ts +16 -7
- package/dist/module/Framework.d.ts.map +1 -1
- package/dist/module/Framework.js +34 -15
- package/dist/module/Framework.js.map +1 -1
- package/dist/module/Governance.d.ts +40 -0
- package/dist/module/Governance.d.ts.map +1 -0
- package/dist/module/Governance.js +76 -0
- package/dist/module/Governance.js.map +1 -0
- package/dist/module/Host.d.ts +3 -3
- package/dist/module/Host.d.ts.map +1 -1
- package/dist/module/Host.js +4 -4
- package/dist/module/Host.js.map +1 -1
- package/dist/module/InstantDistributionAgreementV1.d.ts +25 -22
- package/dist/module/InstantDistributionAgreementV1.d.ts.map +1 -1
- package/dist/module/InstantDistributionAgreementV1.js +69 -71
- package/dist/module/InstantDistributionAgreementV1.js.map +1 -1
- package/dist/module/Operation.d.ts +5 -5
- package/dist/module/Operation.js +5 -5
- package/dist/module/Query.d.ts +1 -1
- package/dist/module/Query.js +1 -1
- package/dist/module/SFError.d.ts +1 -1
- package/dist/module/SFError.d.ts.map +1 -1
- package/dist/module/SFError.js +2 -0
- package/dist/module/SFError.js.map +1 -1
- package/dist/module/SuperToken.d.ts +228 -67
- package/dist/module/SuperToken.d.ts.map +1 -1
- package/dist/module/SuperToken.js +313 -131
- package/dist/module/SuperToken.js.map +1 -1
- package/dist/module/abi/IConstantFlowAgreementV1.json +350 -2
- package/dist/module/abi/ISETH.json +1604 -0
- package/dist/module/abi/SuperfluidGovernanceII.json +939 -0
- package/dist/module/constants.d.ts +4 -0
- package/dist/module/constants.d.ts.map +1 -1
- package/dist/module/constants.js +18 -0
- package/dist/module/constants.js.map +1 -1
- package/dist/module/events.d.ts +14 -2
- package/dist/module/events.d.ts.map +1 -1
- package/dist/module/frameworkHelpers.d.ts +2 -2
- package/dist/module/frameworkHelpers.js +2 -2
- package/dist/module/index.d.ts +14 -6
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +14 -6
- package/dist/module/index.js.map +1 -1
- package/dist/module/interfaces.d.ts +82 -8
- package/dist/module/interfaces.d.ts.map +1 -1
- package/dist/module/mapGetAllEventsQueryEvents.d.ts.map +1 -1
- package/dist/module/mapGetAllEventsQueryEvents.js +22 -1
- package/dist/module/mapGetAllEventsQueryEvents.js.map +1 -1
- package/dist/module/pagination.d.ts +4 -4
- package/dist/module/pagination.js +2 -2
- package/dist/module/subgraph/events/events.generated.d.ts +46 -3
- package/dist/module/subgraph/events/events.generated.d.ts.map +1 -1
- package/dist/module/subgraph/events/events.generated.js +3 -2
- package/dist/module/subgraph/events/events.generated.js.map +1 -1
- package/dist/module/subgraph/queries/getAllEvents.generated.d.ts +12 -0
- package/dist/module/subgraph/queries/getAllEvents.generated.d.ts.map +1 -1
- package/dist/module/subgraph/queries/getAllEvents.generated.js +1 -1
- package/dist/module/subgraph/queries/getAllEvents.generated.js.map +1 -1
- package/dist/module/subgraph/schema.generated.d.ts +817 -5
- package/dist/module/subgraph/schema.generated.d.ts.map +1 -1
- package/dist/module/typechain/IConstantFlowAgreementV1.d.ts +187 -5
- package/dist/module/typechain/IConstantFlowAgreementV1.d.ts.map +1 -1
- package/dist/module/typechain/ISETH.d.ts +1068 -0
- package/dist/module/typechain/ISETH.d.ts.map +1 -0
- package/dist/module/typechain/ISETH.js +2 -0
- package/dist/module/typechain/ISETH.js.map +1 -0
- package/dist/module/typechain/SuperfluidGovernanceII.d.ts +633 -0
- package/dist/module/typechain/SuperfluidGovernanceII.d.ts.map +1 -0
- package/dist/module/typechain/SuperfluidGovernanceII.js +2 -0
- package/dist/module/typechain/SuperfluidGovernanceII.js.map +1 -0
- package/dist/module/typechain/factories/IConstantFlowAgreementV1__factory.d.ts.map +1 -1
- package/dist/module/typechain/factories/IConstantFlowAgreementV1__factory.js +350 -2
- package/dist/module/typechain/factories/IConstantFlowAgreementV1__factory.js.map +1 -1
- package/dist/module/typechain/factories/ISETH__factory.d.ts +36 -0
- package/dist/module/typechain/factories/ISETH__factory.d.ts.map +1 -0
- package/dist/module/typechain/factories/ISETH__factory.js +1618 -0
- package/dist/module/typechain/factories/ISETH__factory.js.map +1 -0
- package/dist/module/typechain/factories/SuperfluidGovernanceII__factory.d.ts +36 -0
- package/dist/module/typechain/factories/SuperfluidGovernanceII__factory.d.ts.map +1 -0
- package/dist/module/typechain/factories/SuperfluidGovernanceII__factory.js +953 -0
- package/dist/module/typechain/factories/SuperfluidGovernanceII__factory.js.map +1 -0
- package/dist/module/typechain/index.d.ts +4 -0
- package/dist/module/typechain/index.d.ts.map +1 -1
- package/dist/module/typechain/index.js +2 -0
- package/dist/module/typechain/index.js.map +1 -1
- package/dist/module/utils.d.ts +15 -13
- package/dist/module/utils.d.ts.map +1 -1
- package/dist/module/utils.js +27 -15
- package/dist/module/utils.js.map +1 -1
- package/package.json +10 -40
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import Operation from "./Operation";
|
|
3
3
|
import { IBaseSuperTokenParams, ITransferFromParams } from "./interfaces";
|
|
4
|
+
import { ERC20WithTokenInfo } from "./typechain/ERC20WithTokenInfo";
|
|
4
5
|
export default class ERC20Token {
|
|
5
6
|
readonly address: string;
|
|
7
|
+
readonly contract: ERC20WithTokenInfo;
|
|
6
8
|
constructor(address: string);
|
|
7
|
-
|
|
9
|
+
/** ### ERC20 Token Contract Read Functions ### */
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
11
|
+
* Returns the allowance the `owner` has granted the `spender`.
|
|
10
12
|
* @param owner the owner who has allotted the allowance
|
|
11
13
|
* @param spender the spender who has received the allowance
|
|
12
14
|
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
@@ -18,7 +20,7 @@ export default class ERC20Token {
|
|
|
18
20
|
providerOrSigner: ethers.providers.Provider | ethers.Signer;
|
|
19
21
|
}) => Promise<string>;
|
|
20
22
|
/**
|
|
21
|
-
*
|
|
23
|
+
* Returns the ERC20 balanceOf the `account`, this can't be negative and will just display 0.
|
|
22
24
|
* @param account the account you would like to query
|
|
23
25
|
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
24
26
|
* @returns {Promise<string>} the token balance of `account`
|
|
@@ -28,7 +30,7 @@ export default class ERC20Token {
|
|
|
28
30
|
providerOrSigner: ethers.providers.Provider | ethers.Signer;
|
|
29
31
|
}) => Promise<string>;
|
|
30
32
|
/**
|
|
31
|
-
*
|
|
33
|
+
* Returns the token name
|
|
32
34
|
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
33
35
|
* @returns {string} the token name
|
|
34
36
|
*/
|
|
@@ -36,7 +38,7 @@ export default class ERC20Token {
|
|
|
36
38
|
providerOrSigner: ethers.providers.Provider | ethers.Signer;
|
|
37
39
|
}) => Promise<string>;
|
|
38
40
|
/**
|
|
39
|
-
*
|
|
41
|
+
* Returns the token symbol
|
|
40
42
|
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
41
43
|
* @returns {string} the token symbol
|
|
42
44
|
*/
|
|
@@ -44,37 +46,38 @@ export default class ERC20Token {
|
|
|
44
46
|
providerOrSigner: ethers.providers.Provider | ethers.Signer;
|
|
45
47
|
}) => Promise<string>;
|
|
46
48
|
/**
|
|
47
|
-
*
|
|
49
|
+
* Returns the total supply of the token.
|
|
48
50
|
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
49
51
|
* @returns {Promise<string>} the total supply of the token
|
|
50
52
|
*/
|
|
51
53
|
totalSupply: ({ providerOrSigner, }: {
|
|
52
54
|
providerOrSigner: ethers.providers.Provider | ethers.Signer;
|
|
53
55
|
}) => Promise<string>;
|
|
56
|
+
/** ### ERC20 Token Contract Write Functions ### */
|
|
54
57
|
/**
|
|
55
|
-
*
|
|
58
|
+
* Approve `receiver` to spend `amount` tokens.
|
|
56
59
|
* @param receiver The receiver approved.
|
|
57
60
|
* @param amount The amount approved.
|
|
58
61
|
* @param overrides ethers overrides object for more control over the transaction sent.
|
|
59
62
|
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
60
63
|
*/
|
|
61
|
-
approve: (
|
|
64
|
+
approve: (params: IBaseSuperTokenParams) => Operation;
|
|
62
65
|
/**
|
|
63
|
-
*
|
|
66
|
+
* Transfer `receiver` `amount` tokens.
|
|
64
67
|
* @param receiver The receiver of the transfer.
|
|
65
68
|
* @param amount The amount to be transferred.
|
|
66
69
|
* @param overrides ethers overrides object for more control over the transaction sent.
|
|
67
70
|
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
68
71
|
*/
|
|
69
|
-
transfer: (
|
|
72
|
+
transfer: (params: IBaseSuperTokenParams) => Operation;
|
|
70
73
|
/**
|
|
71
|
-
*
|
|
74
|
+
* Transfer from `sender` to `receiver` `amount` tokens.
|
|
72
75
|
* @param sender The sender of the transfer.
|
|
73
76
|
* @param receiver The receiver of the transfer.
|
|
74
77
|
* @param amount The amount to be transferred.
|
|
75
78
|
* @param overrides ethers overrides object for more control over the transaction sent.
|
|
76
79
|
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
77
80
|
*/
|
|
78
|
-
transferFrom: (
|
|
81
|
+
transferFrom: (params: ITransferFromParams) => Operation;
|
|
79
82
|
}
|
|
80
83
|
//# sourceMappingURL=ERC20Token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ERC20Token.d.ts","sourceRoot":"","sources":["../../src/ERC20Token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"ERC20Token.d.ts","sourceRoot":"","sources":["../../src/ERC20Token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC,OAAO,EAAE,qBAAqB,EAAE,mBAAmB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### ERC20 Token Contract Read Functions ### */
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Returns the allowance the `owner` has granted the `spender`.
|
|
11
11
|
* @param owner the owner who has allotted the allowance
|
|
12
12
|
* @param spender the spender who has received the allowance
|
|
13
13
|
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
@@ -17,7 +17,7 @@ export default class ERC20Token {
|
|
|
17
17
|
const normalizedOwner = normalizeAddress(owner);
|
|
18
18
|
const normalizedSpender = normalizeAddress(spender);
|
|
19
19
|
try {
|
|
20
|
-
const allowance = await this.
|
|
20
|
+
const allowance = await this.contract
|
|
21
21
|
.connect(providerOrSigner)
|
|
22
22
|
.allowance(normalizedOwner, normalizedSpender);
|
|
23
23
|
return allowance.toString();
|
|
@@ -31,7 +31,7 @@ export default class ERC20Token {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Returns the ERC20 balanceOf the `account`, this can't be negative and will just display 0.
|
|
35
35
|
* @param account the account you would like to query
|
|
36
36
|
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
37
37
|
* @returns {Promise<string>} the token balance of `account`
|
|
@@ -39,7 +39,7 @@ export default class ERC20Token {
|
|
|
39
39
|
this.balanceOf = async ({ account, providerOrSigner, }) => {
|
|
40
40
|
try {
|
|
41
41
|
const normalizedAccount = normalizeAddress(account);
|
|
42
|
-
const balanceOf = await this.
|
|
42
|
+
const balanceOf = await this.contract
|
|
43
43
|
.connect(providerOrSigner)
|
|
44
44
|
.balanceOf(normalizedAccount);
|
|
45
45
|
return balanceOf.toString();
|
|
@@ -53,15 +53,13 @@ export default class ERC20Token {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Returns the token name
|
|
57
57
|
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
58
58
|
* @returns {string} the token name
|
|
59
59
|
*/
|
|
60
60
|
this.name = async ({ providerOrSigner, }) => {
|
|
61
61
|
try {
|
|
62
|
-
const name = await this.
|
|
63
|
-
.connect(providerOrSigner)
|
|
64
|
-
.name();
|
|
62
|
+
const name = await this.contract.connect(providerOrSigner).name();
|
|
65
63
|
return name;
|
|
66
64
|
}
|
|
67
65
|
catch (err) {
|
|
@@ -73,13 +71,13 @@ export default class ERC20Token {
|
|
|
73
71
|
}
|
|
74
72
|
};
|
|
75
73
|
/**
|
|
76
|
-
*
|
|
74
|
+
* Returns the token symbol
|
|
77
75
|
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
78
76
|
* @returns {string} the token symbol
|
|
79
77
|
*/
|
|
80
78
|
this.symbol = async ({ providerOrSigner, }) => {
|
|
81
79
|
try {
|
|
82
|
-
const symbol = await this.
|
|
80
|
+
const symbol = await this.contract
|
|
83
81
|
.connect(providerOrSigner)
|
|
84
82
|
.symbol();
|
|
85
83
|
return symbol;
|
|
@@ -93,13 +91,13 @@ export default class ERC20Token {
|
|
|
93
91
|
}
|
|
94
92
|
};
|
|
95
93
|
/**
|
|
96
|
-
*
|
|
94
|
+
* Returns the total supply of the token.
|
|
97
95
|
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
98
96
|
* @returns {Promise<string>} the total supply of the token
|
|
99
97
|
*/
|
|
100
98
|
this.totalSupply = async ({ providerOrSigner, }) => {
|
|
101
99
|
try {
|
|
102
|
-
const totalSupply = await this.
|
|
100
|
+
const totalSupply = await this.contract
|
|
103
101
|
.connect(providerOrSigner)
|
|
104
102
|
.totalSupply();
|
|
105
103
|
return totalSupply.toString();
|
|
@@ -112,49 +110,47 @@ export default class ERC20Token {
|
|
|
112
110
|
});
|
|
113
111
|
}
|
|
114
112
|
};
|
|
115
|
-
|
|
113
|
+
/** ### ERC20 Token Contract Write Functions ### */
|
|
116
114
|
/**
|
|
117
|
-
*
|
|
115
|
+
* Approve `receiver` to spend `amount` tokens.
|
|
118
116
|
* @param receiver The receiver approved.
|
|
119
117
|
* @param amount The amount approved.
|
|
120
118
|
* @param overrides ethers overrides object for more control over the transaction sent.
|
|
121
119
|
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
122
120
|
*/
|
|
123
|
-
this.approve = (
|
|
124
|
-
const normalizedReceiver = normalizeAddress(receiver);
|
|
125
|
-
const txn = this.
|
|
121
|
+
this.approve = (params) => {
|
|
122
|
+
const normalizedReceiver = normalizeAddress(params.receiver);
|
|
123
|
+
const txn = this.contract.populateTransaction.approve(normalizedReceiver, params.amount, params.overrides || {});
|
|
126
124
|
return new Operation(txn, "ERC20_APPROVE");
|
|
127
125
|
};
|
|
128
126
|
/**
|
|
129
|
-
*
|
|
127
|
+
* Transfer `receiver` `amount` tokens.
|
|
130
128
|
* @param receiver The receiver of the transfer.
|
|
131
129
|
* @param amount The amount to be transferred.
|
|
132
130
|
* @param overrides ethers overrides object for more control over the transaction sent.
|
|
133
131
|
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
134
132
|
*/
|
|
135
|
-
this.transfer = (
|
|
136
|
-
const normalizedReceiver = normalizeAddress(receiver);
|
|
137
|
-
const txn = this.
|
|
133
|
+
this.transfer = (params) => {
|
|
134
|
+
const normalizedReceiver = normalizeAddress(params.receiver);
|
|
135
|
+
const txn = this.contract.populateTransaction.transfer(normalizedReceiver, params.amount, params.overrides || {});
|
|
138
136
|
return new Operation(txn, "UNSUPPORTED");
|
|
139
137
|
};
|
|
140
138
|
/**
|
|
141
|
-
*
|
|
139
|
+
* Transfer from `sender` to `receiver` `amount` tokens.
|
|
142
140
|
* @param sender The sender of the transfer.
|
|
143
141
|
* @param receiver The receiver of the transfer.
|
|
144
142
|
* @param amount The amount to be transferred.
|
|
145
143
|
* @param overrides ethers overrides object for more control over the transaction sent.
|
|
146
144
|
* @returns {Operation} An instance of Operation which can be executed or batched.
|
|
147
145
|
*/
|
|
148
|
-
this.transferFrom = (
|
|
149
|
-
const normalizedSender = normalizeAddress(sender);
|
|
150
|
-
const normalizedReceiver = normalizeAddress(receiver);
|
|
151
|
-
const txn = this.
|
|
146
|
+
this.transferFrom = (params) => {
|
|
147
|
+
const normalizedSender = normalizeAddress(params.sender);
|
|
148
|
+
const normalizedReceiver = normalizeAddress(params.receiver);
|
|
149
|
+
const txn = this.contract.populateTransaction.transferFrom(normalizedSender, normalizedReceiver, params.amount, params.overrides || {});
|
|
152
150
|
return new Operation(txn, "ERC20_TRANSFER_FROM");
|
|
153
151
|
};
|
|
154
152
|
this.address = address;
|
|
155
|
-
|
|
156
|
-
get tokenContract() {
|
|
157
|
-
return new ethers.Contract(this.address, ERC20WithTokenInfoABI.abi);
|
|
153
|
+
this.contract = new ethers.Contract(this.address, ERC20WithTokenInfoABI.abi);
|
|
158
154
|
}
|
|
159
155
|
}
|
|
160
156
|
//# sourceMappingURL=ERC20Token.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ERC20Token.js","sourceRoot":"","sources":["../../src/ERC20Token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,CAAC,OAAO,OAAO,UAAU;
|
|
1
|
+
{"version":3,"file":"ERC20Token.js","sourceRoot":"","sources":["../../src/ERC20Token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,CAAC,OAAO,OAAO,UAAU;IAI3B,YAAY,OAAe;QAQ3B,kDAAkD;QAEl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C;IAC5B,CAAC;CA6LJ"}
|
|
@@ -4,12 +4,13 @@ import { ethers } from "ethers";
|
|
|
4
4
|
import Web3 from "web3";
|
|
5
5
|
import BatchCall from "./BatchCall";
|
|
6
6
|
import ConstantFlowAgreementV1 from "./ConstantFlowAgreementV1";
|
|
7
|
+
import Governance from "./Governance";
|
|
7
8
|
import Host from "./Host";
|
|
8
9
|
import InstantDistributionAgreementV1 from "./InstantDistributionAgreementV1";
|
|
9
10
|
import Operation from "./Operation";
|
|
10
11
|
import Query from "./Query";
|
|
11
12
|
import SuperToken from "./SuperToken";
|
|
12
|
-
import { IConfig, ISignerConstructorOptions } from "./interfaces";
|
|
13
|
+
import { IConfig, IContracts, ISignerConstructorOptions } from "./interfaces";
|
|
13
14
|
import { DataMode } from "./types";
|
|
14
15
|
declare type SupportedProvider = ethers.providers.Provider | (typeof ethers & HardhatEthersHelpers) | Web3;
|
|
15
16
|
export interface IFrameworkOptions {
|
|
@@ -31,19 +32,21 @@ export interface IFrameworkSettings {
|
|
|
31
32
|
config: IConfig;
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
+
* Superfluid Framework Class
|
|
35
36
|
* @description The entrypoint for the SDK-core, `create` an instance of this for full functionality.
|
|
36
37
|
*/
|
|
37
38
|
export default class Framework {
|
|
38
39
|
readonly userInputOptions: IFrameworkOptions;
|
|
39
40
|
settings: IFrameworkSettings;
|
|
41
|
+
contracts: IContracts;
|
|
40
42
|
cfaV1: ConstantFlowAgreementV1;
|
|
43
|
+
governance: Governance;
|
|
41
44
|
host: Host;
|
|
42
45
|
idaV1: InstantDistributionAgreementV1;
|
|
43
46
|
query: Query;
|
|
44
47
|
private constructor();
|
|
45
48
|
/**
|
|
46
|
-
*
|
|
49
|
+
* Creates the Framework object based on user provided `options`.
|
|
47
50
|
* @param options.chainId the chainId of your desired network (e.g. 137 = matic)
|
|
48
51
|
* @param options.customSubgraphQueriesEndpoint your custom subgraph endpoint
|
|
49
52
|
* @param options.dataMode the data mode you'd like the framework to use (SUBGRAPH_ONLY, SUBGRAPH_WEB3, WEB3_ONLY)
|
|
@@ -55,7 +58,7 @@ export default class Framework {
|
|
|
55
58
|
*/
|
|
56
59
|
static create: (options: IFrameworkOptions) => Promise<Framework>;
|
|
57
60
|
/**
|
|
58
|
-
*
|
|
61
|
+
* Create a signer which can be used to sign transactions.
|
|
59
62
|
* @param options.web3Provider a Web3Provider object (e.g. client side - metamask, web3modal)
|
|
60
63
|
* @param options.provider an ethers Provider object (e.g. via Hardhat ethers)
|
|
61
64
|
* @param options.privateKey a test account private key
|
|
@@ -64,17 +67,23 @@ export default class Framework {
|
|
|
64
67
|
*/
|
|
65
68
|
createSigner: (options: ISignerConstructorOptions) => Signer;
|
|
66
69
|
/**
|
|
67
|
-
*
|
|
70
|
+
* Create a `BatchCall` class from the `Framework`.
|
|
68
71
|
* @param operations the list of operations to execute
|
|
69
72
|
* @returns `BatchCall` class
|
|
70
73
|
*/
|
|
71
74
|
batchCall: (operations: Operation[]) => BatchCall;
|
|
72
75
|
/**
|
|
73
|
-
*
|
|
76
|
+
* Loads `SuperTokenWithUnderlying`, `SuperTokenWithoutUnderlying` or `NativeAssetSuperToken` class from the `Framework`.
|
|
74
77
|
* @param tokenAddressOrSymbol the `SuperToken` address or symbol (if symbol, it must be on the resolver)
|
|
75
78
|
* @returns `SuperToken` class
|
|
76
79
|
*/
|
|
77
|
-
loadSuperToken: (tokenAddressOrSymbol: string) => Promise<
|
|
80
|
+
loadSuperToken: <T extends SuperToken = SuperToken>(tokenAddressOrSymbol: string) => Promise<T>;
|
|
81
|
+
/**
|
|
82
|
+
* Try to get the token address given an address (returns if valid) or the token symbol via the resolver.
|
|
83
|
+
* @param tokenAddressOrSymbol
|
|
84
|
+
* @returns token address
|
|
85
|
+
*/
|
|
86
|
+
private _tryGetTokenAddress;
|
|
78
87
|
}
|
|
79
88
|
export {};
|
|
80
89
|
//# sourceMappingURL=Framework.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Framework.d.ts","sourceRoot":"","sources":["../../src/Framework.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,8BAA8B,MAAM,kCAAkC,CAAC;AAC9E,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,UAAU,MAAM,cAAc,CAAC;AAStC,OAAO,
|
|
1
|
+
{"version":3,"file":"Framework.d.ts","sourceRoot":"","sources":["../../src/Framework.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,8BAA8B,MAAM,kCAAkC,CAAC;AAC9E,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,UAAU,MAAM,cAAc,CAAC;AAStC,OAAO,EACH,OAAO,EACP,UAAU,EAEV,yBAAyB,EAC5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,MAAM,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;;;OAIG;IACH,cAAc,4DACY,MAAM,gBAO9B;IAEF;;;;OAIG;IACH,OAAO,CAAC,mBAAmB,CAiCzB;CACL"}
|
package/dist/module/Framework.js
CHANGED
|
@@ -2,6 +2,7 @@ var _a;
|
|
|
2
2
|
import { ethers } from "ethers";
|
|
3
3
|
import BatchCall from "./BatchCall";
|
|
4
4
|
import ConstantFlowAgreementV1 from "./ConstantFlowAgreementV1";
|
|
5
|
+
import Governance from "./Governance";
|
|
5
6
|
import Host from "./Host";
|
|
6
7
|
import InstantDistributionAgreementV1 from "./InstantDistributionAgreementV1";
|
|
7
8
|
import Query from "./Query";
|
|
@@ -13,13 +14,13 @@ import { chainIdToResolverDataMap, networkNameToChainIdMap } from "./constants";
|
|
|
13
14
|
import { getNetworkName, getSubgraphQueriesEndpoint, validateFrameworkConstructorOptions, } from "./frameworkHelpers";
|
|
14
15
|
import { isEthersProvider, isInjectedWeb3 } from "./utils";
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Superfluid Framework Class
|
|
17
18
|
* @description The entrypoint for the SDK-core, `create` an instance of this for full functionality.
|
|
18
19
|
*/
|
|
19
20
|
export default class Framework {
|
|
20
21
|
constructor(options, settings) {
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* Create a signer which can be used to sign transactions.
|
|
23
24
|
* @param options.web3Provider a Web3Provider object (e.g. client side - metamask, web3modal)
|
|
24
25
|
* @param options.provider an ethers Provider object (e.g. via Hardhat ethers)
|
|
25
26
|
* @param options.privateKey a test account private key
|
|
@@ -60,7 +61,7 @@ export default class Framework {
|
|
|
60
61
|
});
|
|
61
62
|
};
|
|
62
63
|
/**
|
|
63
|
-
*
|
|
64
|
+
* Create a `BatchCall` class from the `Framework`.
|
|
64
65
|
* @param operations the list of operations to execute
|
|
65
66
|
* @returns `BatchCall` class
|
|
66
67
|
*/
|
|
@@ -71,15 +72,26 @@ export default class Framework {
|
|
|
71
72
|
});
|
|
72
73
|
};
|
|
73
74
|
/**
|
|
74
|
-
*
|
|
75
|
+
* Loads `SuperTokenWithUnderlying`, `SuperTokenWithoutUnderlying` or `NativeAssetSuperToken` class from the `Framework`.
|
|
75
76
|
* @param tokenAddressOrSymbol the `SuperToken` address or symbol (if symbol, it must be on the resolver)
|
|
76
77
|
* @returns `SuperToken` class
|
|
77
78
|
*/
|
|
78
79
|
this.loadSuperToken = async (tokenAddressOrSymbol) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
address
|
|
80
|
+
const address = await this._tryGetTokenAddress(tokenAddressOrSymbol);
|
|
81
|
+
return (await SuperToken.create({
|
|
82
|
+
...this.settings,
|
|
83
|
+
address,
|
|
84
|
+
}));
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Try to get the token address given an address (returns if valid) or the token symbol via the resolver.
|
|
88
|
+
* @param tokenAddressOrSymbol
|
|
89
|
+
* @returns token address
|
|
90
|
+
*/
|
|
91
|
+
this._tryGetTokenAddress = async (tokenAddressOrSymbol) => {
|
|
92
|
+
const isInputValidAddress = ethers.utils.isAddress(tokenAddressOrSymbol);
|
|
93
|
+
if (isInputValidAddress) {
|
|
94
|
+
return tokenAddressOrSymbol;
|
|
83
95
|
}
|
|
84
96
|
else {
|
|
85
97
|
try {
|
|
@@ -88,8 +100,7 @@ export default class Framework {
|
|
|
88
100
|
"." +
|
|
89
101
|
tokenAddressOrSymbol;
|
|
90
102
|
const resolver = new ethers.Contract(this.settings.config.resolverAddress, IResolverABI.abi, this.settings.provider);
|
|
91
|
-
|
|
92
|
-
address = tokenAddress;
|
|
103
|
+
return await resolver.get(superTokenKey);
|
|
93
104
|
}
|
|
94
105
|
catch (err) {
|
|
95
106
|
throw new SFError({
|
|
@@ -101,26 +112,29 @@ export default class Framework {
|
|
|
101
112
|
});
|
|
102
113
|
}
|
|
103
114
|
}
|
|
104
|
-
return await SuperToken.create({
|
|
105
|
-
...this.settings,
|
|
106
|
-
address,
|
|
107
|
-
});
|
|
108
115
|
};
|
|
109
116
|
this.userInputOptions = options;
|
|
110
117
|
this.settings = settings;
|
|
111
118
|
this.cfaV1 = new ConstantFlowAgreementV1({
|
|
112
119
|
config: this.settings.config,
|
|
113
120
|
});
|
|
121
|
+
this.governance = new Governance(this.settings.config.governanceAddress, this.settings.config.hostAddress);
|
|
114
122
|
this.host = new Host(this.settings.config.hostAddress);
|
|
115
123
|
this.idaV1 = new InstantDistributionAgreementV1({
|
|
116
124
|
config: this.settings.config,
|
|
117
125
|
});
|
|
118
126
|
this.query = new Query(this.settings);
|
|
127
|
+
this.contracts = {
|
|
128
|
+
cfaV1: this.cfaV1.contract,
|
|
129
|
+
governance: this.governance.contract,
|
|
130
|
+
host: this.host.contract,
|
|
131
|
+
idaV1: this.idaV1.contract,
|
|
132
|
+
};
|
|
119
133
|
}
|
|
120
134
|
}
|
|
121
135
|
_a = Framework;
|
|
122
136
|
/**
|
|
123
|
-
*
|
|
137
|
+
* Creates the Framework object based on user provided `options`.
|
|
124
138
|
* @param options.chainId the chainId of your desired network (e.g. 137 = matic)
|
|
125
139
|
* @param options.customSubgraphQueriesEndpoint your custom subgraph endpoint
|
|
126
140
|
* @param options.dataMode the data mode you'd like the framework to use (SUBGRAPH_ONLY, SUBGRAPH_WEB3, WEB3_ONLY)
|
|
@@ -167,6 +181,7 @@ Framework.create = async (options) => {
|
|
|
167
181
|
subgraphAPIEndpoint: "",
|
|
168
182
|
resolverAddress: "",
|
|
169
183
|
networkName: "",
|
|
184
|
+
nativeTokenSymbol: "",
|
|
170
185
|
};
|
|
171
186
|
const resolverAddress = options.resolverAddress
|
|
172
187
|
? options.resolverAddress
|
|
@@ -175,6 +190,9 @@ Framework.create = async (options) => {
|
|
|
175
190
|
const superfluidLoaderAddress = await resolver.get("SuperfluidLoader-v1");
|
|
176
191
|
const superfluidLoader = new ethers.Contract(superfluidLoaderAddress, SuperfluidLoaderABI.abi, provider);
|
|
177
192
|
const framework = await superfluidLoader.loadFramework(releaseVersion);
|
|
193
|
+
const governanceAddress = await new Host(framework.superfluid).contract
|
|
194
|
+
.connect(provider)
|
|
195
|
+
.getGovernance();
|
|
178
196
|
const settings = {
|
|
179
197
|
chainId,
|
|
180
198
|
customSubgraphQueriesEndpoint,
|
|
@@ -187,6 +205,7 @@ Framework.create = async (options) => {
|
|
|
187
205
|
hostAddress: framework.superfluid,
|
|
188
206
|
cfaV1Address: framework.agreementCFAv1,
|
|
189
207
|
idaV1Address: framework.agreementIDAv1,
|
|
208
|
+
governanceAddress,
|
|
190
209
|
},
|
|
191
210
|
};
|
|
192
211
|
return new Framework(options, settings);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Framework.js","sourceRoot":"","sources":["../../src/Framework.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,8BAA8B,MAAM,kCAAkC,CAAC;AAE9E,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,mBAAmB,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EACH,cAAc,EACd,0BAA0B,EAC1B,mCAAmC,GACtC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"Framework.js","sourceRoot":"","sources":["../../src/Framework.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,UAAU,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,iBAAiB;aACpB;SACJ,CAAC;QAEF,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;KAC3C;IAAC,OAAO,GAAG,EAAE;QACV,MAAM,IAAI,OAAO,CAAC;YACd,IAAI,EAAE,0BAA0B;YAChC,aAAa,EAAE,+CAA+C;YAC9D,WAAW,EAAE,GAAG;SACnB,CAAC,CAAC;KACN;AACL,CAAE,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IGetGovernanceParametersParams, IWeb3GovernanceParams } from "./interfaces";
|
|
2
|
+
import { SuperfluidGovernanceII } from "./typechain/SuperfluidGovernanceII";
|
|
3
|
+
export default class Governance {
|
|
4
|
+
contract: SuperfluidGovernanceII;
|
|
5
|
+
hostAddress: string;
|
|
6
|
+
constructor(govAddress: string, hostAddress: string);
|
|
7
|
+
/**
|
|
8
|
+
* Returns the 3Ps config for the specified token (or default) - the liquidation period and patrician period
|
|
9
|
+
* @see https://docs.superfluid.finance/superfluid/sentinels/liquidations-and-toga
|
|
10
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
11
|
+
* @param token specified governance parameter token
|
|
12
|
+
* @returns {Object} liquidationPeriod and patricianPeriod as strings
|
|
13
|
+
*/
|
|
14
|
+
getPPPConfig: ({ providerOrSigner, token, }: IGetGovernanceParametersParams) => Promise<{
|
|
15
|
+
liquidationPeriod: string;
|
|
16
|
+
patricianPeriod: string;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the reward address for the specified token (or default)
|
|
20
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
21
|
+
* @param token specified governance parameter token
|
|
22
|
+
* @returns {string} the reward address
|
|
23
|
+
*/
|
|
24
|
+
getRewardAddress: ({ providerOrSigner, token, }: IGetGovernanceParametersParams) => Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the minimum deposit for the specified token (or default)
|
|
27
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
28
|
+
* @param token specified governance parameter token
|
|
29
|
+
* @returns {string} minimum deposit
|
|
30
|
+
*/
|
|
31
|
+
getMinimumDeposit: ({ providerOrSigner, token, }: IGetGovernanceParametersParams) => Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the relevant governance parameters
|
|
34
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
35
|
+
* @param token specified governance parameter token
|
|
36
|
+
* @returns {Object} liquidationPeriod, patricianPeriod, rewardAddress and minimumDeposit
|
|
37
|
+
*/
|
|
38
|
+
getGovernanceParameters: ({ providerOrSigner, token, }: IGetGovernanceParametersParams) => Promise<IWeb3GovernanceParams>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=Governance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Governance.d.ts","sourceRoot":"","sources":["../../src/Governance.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,8BAA8B,EAC9B,qBAAqB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,MAAM,CAAC,OAAO,OAAO,UAAU;IAC3B,QAAQ,EAAE,sBAAsB,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;gBAER,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAQnD;;;;;;OAMG;IACH,YAAY,iCAGT,8BAA8B;;;OAQ/B;IAEF;;;;;OAKG;IACH,gBAAgB,iCAGb,8BAA8B,qBAI/B;IAEF;;;;;OAKG;IACH,iBAAiB,iCAGd,8BAA8B,qBAK/B;IAEF;;;;;OAKG;IACH,uBAAuB,iCAGpB,8BAA8B,KAAG,QAAQ,qBAAqB,CAAC,CAqBhE;CACL"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import SuperfluidGovernanceIIABI from "./abi/SuperfluidGovernanceII.json";
|
|
3
|
+
export default class Governance {
|
|
4
|
+
constructor(govAddress, hostAddress) {
|
|
5
|
+
/**
|
|
6
|
+
* Returns the 3Ps config for the specified token (or default) - the liquidation period and patrician period
|
|
7
|
+
* @see https://docs.superfluid.finance/superfluid/sentinels/liquidations-and-toga
|
|
8
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
9
|
+
* @param token specified governance parameter token
|
|
10
|
+
* @returns {Object} liquidationPeriod and patricianPeriod as strings
|
|
11
|
+
*/
|
|
12
|
+
this.getPPPConfig = async ({ providerOrSigner, token = ethers.constants.AddressZero, }) => {
|
|
13
|
+
const { liquidationPeriod, patricianPeriod } = await this.contract
|
|
14
|
+
.connect(providerOrSigner)
|
|
15
|
+
.getPPPConfig(this.hostAddress, token);
|
|
16
|
+
return {
|
|
17
|
+
liquidationPeriod: liquidationPeriod.toString(),
|
|
18
|
+
patricianPeriod: patricianPeriod.toString(),
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Returns the reward address for the specified token (or default)
|
|
23
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
24
|
+
* @param token specified governance parameter token
|
|
25
|
+
* @returns {string} the reward address
|
|
26
|
+
*/
|
|
27
|
+
this.getRewardAddress = async ({ providerOrSigner, token = ethers.constants.AddressZero, }) => {
|
|
28
|
+
return await this.contract
|
|
29
|
+
.connect(providerOrSigner)
|
|
30
|
+
.getRewardAddress(this.hostAddress, token);
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Returns the minimum deposit for the specified token (or default)
|
|
34
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
35
|
+
* @param token specified governance parameter token
|
|
36
|
+
* @returns {string} minimum deposit
|
|
37
|
+
*/
|
|
38
|
+
this.getMinimumDeposit = async ({ providerOrSigner, token = ethers.constants.AddressZero, }) => {
|
|
39
|
+
const superTokenMinimumDeposit = await this.contract
|
|
40
|
+
.connect(providerOrSigner)
|
|
41
|
+
.getSuperTokenMinimumDeposit(this.hostAddress, token);
|
|
42
|
+
return superTokenMinimumDeposit.toString();
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Returns the relevant governance parameters
|
|
46
|
+
* @param providerOrSigner a provider or signer for executing a web3 call
|
|
47
|
+
* @param token specified governance parameter token
|
|
48
|
+
* @returns {Object} liquidationPeriod, patricianPeriod, rewardAddress and minimumDeposit
|
|
49
|
+
*/
|
|
50
|
+
this.getGovernanceParameters = async ({ providerOrSigner, token = ethers.constants.AddressZero, }) => {
|
|
51
|
+
const pppPromise = this.getPPPConfig({ providerOrSigner, token });
|
|
52
|
+
const rewardPromose = this.getRewardAddress({
|
|
53
|
+
providerOrSigner,
|
|
54
|
+
token,
|
|
55
|
+
});
|
|
56
|
+
const minimumDepositPromise = this.getMinimumDeposit({
|
|
57
|
+
providerOrSigner,
|
|
58
|
+
token,
|
|
59
|
+
});
|
|
60
|
+
const data = await Promise.all([
|
|
61
|
+
pppPromise,
|
|
62
|
+
rewardPromose,
|
|
63
|
+
minimumDepositPromise,
|
|
64
|
+
]);
|
|
65
|
+
return {
|
|
66
|
+
liquidationPeriod: data[0].liquidationPeriod,
|
|
67
|
+
patricianPeriod: data[0].patricianPeriod,
|
|
68
|
+
rewardAddress: data[1],
|
|
69
|
+
minimumDeposit: data[2],
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
this.contract = new ethers.Contract(govAddress, SuperfluidGovernanceIIABI.abi);
|
|
73
|
+
this.hostAddress = hostAddress;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=Governance.js.map
|