-
Notifications
You must be signed in to change notification settings - Fork 261
Expand file tree
/
Copy pathSuperfluidLoader.sol
More file actions
59 lines (53 loc) · 1.92 KB
/
SuperfluidLoader.sol
File metadata and controls
59 lines (53 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.11;
import { IResolver } from "../interfaces/utils/IResolver.sol";
import {
ISuperfluid,
ISuperTokenFactory,
ISuperAgreement
} from "../interfaces/superfluid/ISuperfluid.sol";
/**
* @title Superfluid loader contract
* @author Superfluid
* @dev A on-chain utility contract for loading framework objects in one view function.
*
* NOTE:
* Q: Why don't we just use https://www.npmjs.com/package/ethereum-multicall?
* A: Well, no strong reason other than also allowing on-chain one view function loading.
*/
contract SuperfluidLoader {
IResolver private immutable _resolver;
struct Framework {
ISuperfluid superfluid;
ISuperTokenFactory superTokenFactory;
ISuperAgreement agreementCFAv1;
ISuperAgreement agreementIDAv1;
ISuperAgreement agreementGDAv1;
}
constructor(IResolver resolver) {
_resolver = resolver;
}
/**
* @dev Load framework objects
* @param releaseVersion Protocol release version of the deployment
*/
function loadFramework(string calldata releaseVersion)
external view
returns (Framework memory result)
{
// load superfluid host contract
result.superfluid = ISuperfluid(_resolver.get(
string.concat("Superfluid.", releaseVersion)
));
result.superTokenFactory = result.superfluid.getSuperTokenFactory();
result.agreementCFAv1 = result.superfluid.getAgreementClass(
keccak256("org.superfluid-finance.agreements.ConstantFlowAgreement.v1")
);
result.agreementIDAv1 = result.superfluid.getAgreementClass(
keccak256("org.superfluid-finance.agreements.InstantDistributionAgreement.v1")
);
result.agreementGDAv1 = result.superfluid.getAgreementClass(
keccak256("org.superfluid-finance.agreements.GeneralDistributionAgreement.v1")
);
}
}