-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fontaine.sol
71 lines (58 loc) · 2.59 KB
/
Fontaine.sol
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
60
61
62
63
64
65
66
67
68
69
70
71
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
/* Openzeppelin Contracts & Interfaces */
import { Initializable } from "@openzeppelin-v5/contracts/proxy/utils/Initializable.sol";
/* Superfluid Protocol Contracts & Interfaces */
import {
ISuperfluid,
ISuperfluidPool,
ISuperToken,
ISuperApp
} from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
/* FLUID Contracts & Interfaces */
import { IFontaine } from "./interfaces/IFontaine.sol";
using SuperTokenV1Library for ISuperToken;
/**
* @title Fontaine Contract
* @author Superfluid
* @notice Contract responsible for flowing the token being unlocked from the locker to the locker owner
*
*/
contract Fontaine is Initializable, IFontaine {
// _____ __ __
// / ___// /_____ _/ /____ _____
// \__ \/ __/ __ `/ __/ _ \/ ___/
// ___/ / /_/ /_/ / /_/ __(__ )
// /____/\__/\__,_/\__/\___/____/
/// @notice $FLUID SuperToken interface
ISuperToken public immutable FLUID;
/// @notice Superfluid pool interface
ISuperfluidPool public immutable TAX_DISTRIBUTION_POOL;
// ______ __ __
// / ____/___ ____ _____/ /________ _______/ /_____ _____
// / / / __ \/ __ \/ ___/ __/ ___/ / / / ___/ __/ __ \/ ___/
// / /___/ /_/ / / / (__ ) /_/ / / /_/ / /__/ /_/ /_/ / /
// \____/\____/_/ /_/____/\__/_/ \__,_/\___/\__/\____/_/
/**
* @notice Fontaine contract constructor
* @param fluid FLUID SuperToken interface
* @param taxDistributionPool Tax Distribution Pool GDA contract address
*/
constructor(ISuperToken fluid, ISuperfluidPool taxDistributionPool) {
// Disable initializers to prevent implementation contract initalization
_disableInitializers();
// Sets immutable states
FLUID = fluid;
TAX_DISTRIBUTION_POOL = taxDistributionPool;
}
/// @inheritdoc IFontaine
function initialize(address unlockRecipient, int96 unlockFlowRate, int96 taxFlowRate) external initializer {
// Ensure recipient is not a SuperApp
if (ISuperfluid(FLUID.getHost()).isApp(ISuperApp(unlockRecipient))) revert CANNOT_UNLOCK_TO_SUPERAPP();
// Distribute Tax flow to Staker GDA Pool
FLUID.distributeFlow(address(this), TAX_DISTRIBUTION_POOL, taxFlowRate);
// Create the unlocking flow from the Fontaine to the locker owner
FLUID.createFlow(unlockRecipient, unlockFlowRate);
}
}