@gooddollar/goodcollective-contracts 1.0.1 → 1.0.2
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/contracts/DirectPayments/DirectPaymentsPool.sol +12 -2
- package/contracts/GoodCollective/GoodCollectiveSuperApp.sol +264 -0
- package/contracts/GoodCollective/SuperAppBaseFlow.sol +204 -0
- package/contracts/utils/SwapRouterMock.sol +32 -0
- package/package.json +4 -1
- package/releases/deployment.json +7984 -2746
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/AggregatorV3Interface.ts +199 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/CERC20.ts +630 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/ERC20.ts +450 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IAaveIncentivesController.ts +161 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IAdminWallet.ts +189 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IDonationStaking.ts +98 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IERC2917.ts +750 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IFirstClaimPool.ts +144 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IGoodDollar.ts +1033 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IGoodStaking.ts +281 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IHasRouter.ts +81 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IIdentity.ts +598 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IIdentityV2.ts +689 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/ILendingPool.ts +257 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IMultichainRouter.ts +179 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/INameService.ts +100 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/IUBIScheme.ts +137 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/ProxyAdmin.ts +278 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/Reserve.ts +117 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/Staking.ts +175 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/Uniswap.ts +464 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/UniswapFactory.ts +105 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/UniswapPair.ts +209 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/Interfaces.sol/index.ts +26 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/index.ts +7 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/token/FeesFormula.sol/IFeesFormula.ts +115 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/token/FeesFormula.sol/index.ts +4 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/token/index.ts +7 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom.ts +726 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar.ts +3662 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/token/superfluid/ISuperGoodDollar.sol/index.ts +5 -0
- package/typechain-types/@gooddollar/goodprotocol/contracts/token/superfluid/index.ts +5 -0
- package/typechain-types/@gooddollar/goodprotocol/index.ts +5 -0
- package/typechain-types/@gooddollar/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/index.ts +4 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC20/IERC20.ts +342 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC20/index.ts +4 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721.ts +559 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.ts +619 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/extensions/index.ts +4 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC721/index.ts +6 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC777/IERC777.ts +650 -0
- package/typechain-types/@openzeppelin/contracts/token/ERC777/index.ts +4 -0
- package/typechain-types/@openzeppelin/contracts/token/index.ts +9 -0
- package/typechain-types/@openzeppelin/contracts/utils/index.ts +5 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/IERC165.ts +103 -0
- package/typechain-types/@openzeppelin/contracts/utils/introspection/index.ts +4 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/index.ts +5 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/agreements/IConstantFlowAgreementV1.ts +1390 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/agreements/IInstantDistributionAgreementV1.ts +1280 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/agreements/index.ts +5 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/index.ts +9 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/IConstantInflowNFT.ts +876 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/IConstantOutflowNFT.ts +945 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/IFlowNFTBase.ts +807 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperAgreement.ts +157 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperApp.ts +457 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken.ts +2806 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperTokenFactory.ts +465 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.ts +1727 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluidGovernance.ts +506 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluidToken.ts +1010 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/index.ts +13 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/tokens/ERC20WithTokenInfo.ts +384 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/tokens/TokenInfo.ts +109 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/contracts/interfaces/tokens/index.ts +5 -0
- package/typechain-types/@superfluid-finance/ethereum-contracts/index.ts +5 -0
- package/typechain-types/@superfluid-finance/index.ts +5 -0
- package/typechain-types/@uniswap/index.ts +7 -0
- package/typechain-types/@uniswap/v3-core/contracts/index.ts +5 -0
- package/typechain-types/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.ts +122 -0
- package/typechain-types/@uniswap/v3-core/contracts/interfaces/callback/index.ts +4 -0
- package/typechain-types/@uniswap/v3-core/contracts/interfaces/index.ts +5 -0
- package/typechain-types/@uniswap/v3-core/index.ts +5 -0
- package/typechain-types/@uniswap/v3-periphery/contracts/index.ts +5 -0
- package/typechain-types/@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.ts +369 -0
- package/typechain-types/@uniswap/v3-periphery/contracts/interfaces/index.ts +4 -0
- package/typechain-types/@uniswap/v3-periphery/index.ts +5 -0
- package/typechain-types/contracts/DirectPayments/DirectPaymentsPool.sol/DirectPaymentsPool.ts +763 -0
- package/typechain-types/contracts/GoodCollective/GoodCollectiveSuperApp.ts +843 -0
- package/typechain-types/contracts/GoodCollective/SuperAppBaseFlow.ts +523 -0
- package/typechain-types/contracts/GoodCollective/index.ts +5 -0
- package/typechain-types/contracts/index.ts +4 -1
- package/typechain-types/contracts/utils/SwapRouterMock.ts +194 -0
- package/typechain-types/contracts/utils/index.ts +4 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/AggregatorV3Interface__factory.ts +121 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/CERC20__factory.ts +384 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/ERC20__factory.ts +288 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IAaveIncentivesController__factory.ts +83 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IAdminWallet__factory.ts +78 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IDonationStaking__factory.ts +33 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IERC2917__factory.ts +496 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IFirstClaimPool__factory.ts +65 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IGoodDollar__factory.ts +598 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IGoodStaking__factory.ts +178 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IHasRouter__factory.ts +39 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IIdentityV2__factory.ts +334 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IIdentity__factory.ts +287 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/ILendingPool__factory.ts +171 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IMultichainRouter__factory.ts +82 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/INameService__factory.ts +45 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/IUBIScheme__factory.ts +71 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/ProxyAdmin__factory.ts +131 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/Reserve__factory.ts +55 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/Staking__factory.ts +77 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/UniswapFactory__factory.ts +50 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/UniswapPair__factory.ts +120 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/Uniswap__factory.ts +275 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/Interfaces.sol/index.ts +26 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/index.ts +5 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/token/FeesFormula.sol/IFeesFormula__factory.ts +60 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/token/FeesFormula.sol/index.ts +4 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/token/index.ts +5 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/token/superfluid/ISuperGoodDollar.sol/IGoodDollarCustom__factory.ts +370 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/token/superfluid/ISuperGoodDollar.sol/ISuperGoodDollar__factory.ts +2301 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/token/superfluid/ISuperGoodDollar.sol/index.ts +5 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/contracts/token/superfluid/index.ts +4 -0
- package/typechain-types/factories/@gooddollar/goodprotocol/index.ts +4 -0
- package/typechain-types/factories/@gooddollar/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/index.ts +2 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC20/IERC20__factory.ts +206 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC20/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/IERC721__factory.ts +311 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata__factory.ts +356 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/extensions/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC721/index.ts +5 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC777/IERC777__factory.ts +417 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/ERC777/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/token/index.ts +6 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/index.ts +4 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/IERC165__factory.ts +45 -0
- package/typechain-types/factories/@openzeppelin/contracts/utils/introspection/index.ts +4 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/index.ts +4 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/agreements/IConstantFlowAgreementV1__factory.ts +986 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/agreements/IInstantDistributionAgreementV1__factory.ts +1015 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/agreements/index.ts +5 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/index.ts +6 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/IConstantInflowNFT__factory.ts +551 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/IConstantOutflowNFT__factory.ts +614 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/IFlowNFTBase__factory.ts +515 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperAgreement__factory.ts +78 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperApp__factory.ts +275 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperTokenFactory__factory.ts +276 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperToken__factory.ts +1839 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluidGovernance__factory.ts +264 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluidToken__factory.ts +697 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid__factory.ts +1151 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/index.ts +13 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/tokens/ERC20WithTokenInfo__factory.ts +248 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/tokens/TokenInfo__factory.ts +65 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/contracts/interfaces/tokens/index.ts +5 -0
- package/typechain-types/factories/@superfluid-finance/ethereum-contracts/index.ts +4 -0
- package/typechain-types/factories/@superfluid-finance/index.ts +4 -0
- package/typechain-types/factories/@uniswap/index.ts +5 -0
- package/typechain-types/factories/@uniswap/v3-core/contracts/index.ts +4 -0
- package/typechain-types/factories/@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback__factory.ts +53 -0
- package/typechain-types/factories/@uniswap/v3-core/contracts/interfaces/callback/index.ts +4 -0
- package/typechain-types/factories/@uniswap/v3-core/contracts/interfaces/index.ts +4 -0
- package/typechain-types/factories/@uniswap/v3-core/index.ts +4 -0
- package/typechain-types/factories/@uniswap/v3-periphery/contracts/index.ts +4 -0
- package/typechain-types/factories/@uniswap/v3-periphery/contracts/interfaces/ISwapRouter__factory.ts +263 -0
- package/typechain-types/factories/@uniswap/v3-periphery/contracts/interfaces/index.ts +4 -0
- package/typechain-types/factories/@uniswap/v3-periphery/index.ts +4 -0
- package/typechain-types/factories/contracts/DirectPayments/DirectPaymentsFactory__factory.ts +1 -1
- package/typechain-types/factories/contracts/DirectPayments/DirectPaymentsPool.sol/DirectPaymentsPool__factory.ts +581 -3
- package/typechain-types/factories/contracts/GoodCollective/GoodCollectiveSuperApp__factory.ts +584 -0
- package/typechain-types/factories/contracts/GoodCollective/SuperAppBaseFlow__factory.ts +335 -0
- package/typechain-types/factories/contracts/GoodCollective/index.ts +5 -0
- package/typechain-types/factories/contracts/index.ts +2 -1
- package/typechain-types/factories/contracts/utils/SwapRouterMock__factory.ts +183 -0
- package/typechain-types/factories/contracts/utils/index.ts +4 -0
- package/typechain-types/factories/index.ts +3 -0
- package/typechain-types/hardhat.d.ts +445 -4
- package/typechain-types/index.ts +106 -4
|
@@ -9,6 +9,7 @@ import { IERC721ReceiverUpgradeable } from "@openzeppelin/contracts-upgradeable/
|
|
|
9
9
|
|
|
10
10
|
import { ProvableNFT } from "./ProvableNFT.sol";
|
|
11
11
|
import { DirectPaymentsFactory } from "./DirectPaymentsFactory.sol";
|
|
12
|
+
import "../GoodCollective/GoodCollectiveSuperApp.sol";
|
|
12
13
|
|
|
13
14
|
interface IMembersValidator {
|
|
14
15
|
function isMemberValid(
|
|
@@ -30,7 +31,12 @@ interface IIdentityV2 {
|
|
|
30
31
|
- factory -> register the pool, claim nfttype, deploy pool
|
|
31
32
|
- events
|
|
32
33
|
*/
|
|
33
|
-
contract DirectPaymentsPool is
|
|
34
|
+
contract DirectPaymentsPool is
|
|
35
|
+
IERC721ReceiverUpgradeable,
|
|
36
|
+
AccessControlUpgradeable,
|
|
37
|
+
GoodCollectiveSuperApp,
|
|
38
|
+
UUPSUpgradeable
|
|
39
|
+
{
|
|
34
40
|
using SafeERC20Upgradeable for IERC20Upgradeable;
|
|
35
41
|
error NOT_MANAGER();
|
|
36
42
|
error ALREADY_CLAIMED(uint256);
|
|
@@ -86,6 +92,9 @@ contract DirectPaymentsPool is IERC721ReceiverUpgradeable, AccessControlUpgradea
|
|
|
86
92
|
LimitsData public globalLimits;
|
|
87
93
|
address public createdBy;
|
|
88
94
|
|
|
95
|
+
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
96
|
+
constructor(ISuperfluid _host, ISwapRouter _swapRouter) GoodCollectiveSuperApp(_host, _swapRouter) {}
|
|
97
|
+
|
|
89
98
|
/**
|
|
90
99
|
* @dev Authorizes an upgrade for the implementation contract.
|
|
91
100
|
* @param impl The address of the new implementation contract.
|
|
@@ -103,13 +112,14 @@ contract DirectPaymentsPool is IERC721ReceiverUpgradeable, AccessControlUpgradea
|
|
|
103
112
|
PoolSettings memory _settings,
|
|
104
113
|
SafetyLimits memory _limits
|
|
105
114
|
) external initializer {
|
|
106
|
-
uint l = 5;
|
|
107
115
|
createdBy = msg.sender;
|
|
108
116
|
settings = _settings;
|
|
109
117
|
limits = _limits;
|
|
110
118
|
nft = _nft;
|
|
111
119
|
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
|
|
112
120
|
_setupRole(DEFAULT_ADMIN_ROLE, _settings.manager);
|
|
121
|
+
|
|
122
|
+
setSuperToken(ISuperToken(address(settings.rewardToken)));
|
|
113
123
|
}
|
|
114
124
|
|
|
115
125
|
function upgradeToLatest(bytes memory data) external payable virtual onlyProxy {
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity >=0.8.0;
|
|
4
|
+
|
|
5
|
+
import { SuperAppBaseFlow } from "./SuperAppBaseFlow.sol";
|
|
6
|
+
import { ISuperfluid, ISuperToken, SuperAppDefinitions } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
|
|
7
|
+
import { ISuperGoodDollar } from "@gooddollar/goodprotocol/contracts/token/superfluid/ISuperGoodDollar.sol";
|
|
8
|
+
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
|
|
9
|
+
|
|
10
|
+
import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
|
|
11
|
+
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
|
|
12
|
+
|
|
13
|
+
// import "hardhat/console.sol";
|
|
14
|
+
|
|
15
|
+
abstract contract GoodCollectiveSuperApp is SuperAppBaseFlow {
|
|
16
|
+
using SuperTokenV1Library for ISuperToken;
|
|
17
|
+
|
|
18
|
+
error ZERO_ADDRESS();
|
|
19
|
+
error ZERO_AMOUNT();
|
|
20
|
+
error UNSUPPORTED_TOKEN();
|
|
21
|
+
error ONLY_HOST_OR_SENDER(address);
|
|
22
|
+
|
|
23
|
+
event SupporterUpdated(address indexed supporter, uint256 contribution, int96 flowRate, uint256 lastUpdated);
|
|
24
|
+
|
|
25
|
+
//TODO: ask about "view" for beforeagreement functions
|
|
26
|
+
// ask about "receiver" can it be different then app?
|
|
27
|
+
|
|
28
|
+
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
29
|
+
ISwapRouter public immutable swapRouter;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @dev A struct containing information about a token swap
|
|
33
|
+
* @param swapFrom The address of the token being swapped
|
|
34
|
+
* @param amount The amount of tokens being swapped
|
|
35
|
+
* @param minReturn The minimum amount of tokens to be received in the swap
|
|
36
|
+
* @param timestamp The deadline for the swap to occur
|
|
37
|
+
* @param path The path of tokens to take in a uniswap v3 multi-hop swap, encoded as bytes
|
|
38
|
+
*/
|
|
39
|
+
struct SwapData {
|
|
40
|
+
address swapFrom;
|
|
41
|
+
uint256 amount;
|
|
42
|
+
uint256 minReturn;
|
|
43
|
+
uint256 timestamp;
|
|
44
|
+
bytes path;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
struct SupporterData {
|
|
48
|
+
uint256 contribution;
|
|
49
|
+
int96 flowRate;
|
|
50
|
+
uint128 lastUpdated;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
ISuperToken public superToken;
|
|
54
|
+
|
|
55
|
+
mapping(address => SupporterData) public supporters;
|
|
56
|
+
|
|
57
|
+
uint256[50] private _reserved;
|
|
58
|
+
|
|
59
|
+
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
60
|
+
constructor(ISuperfluid _host, ISwapRouter _swapRouter) SuperAppBaseFlow(_host) {
|
|
61
|
+
if (address(_host) == address(0)) revert ZERO_ADDRESS();
|
|
62
|
+
swapRouter = _swapRouter;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @dev Sets the address of the super token and registers the app with the host
|
|
67
|
+
* @param _superToken The address of the super token contract
|
|
68
|
+
*/
|
|
69
|
+
function setSuperToken(ISuperToken _superToken) internal {
|
|
70
|
+
if (address(_superToken) == address(0)) revert ZERO_ADDRESS();
|
|
71
|
+
|
|
72
|
+
// Set the super token address
|
|
73
|
+
superToken = _superToken;
|
|
74
|
+
|
|
75
|
+
// Define the callback definitions for the app
|
|
76
|
+
uint256 callBackDefinitions = SuperAppDefinitions.APP_LEVEL_FINAL;
|
|
77
|
+
|
|
78
|
+
// Register the app with the host
|
|
79
|
+
host.registerApp(callBackDefinitions);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function isAcceptedSuperToken(ISuperToken _superToken) public view override returns (bool) {
|
|
83
|
+
return address(superToken) == address(_superToken);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getRealtimeContribution(address _user) public view returns (uint256) {
|
|
87
|
+
SupporterData memory supporter = supporters[_user];
|
|
88
|
+
if (supporter.flowRate == 0) return supporter.contribution;
|
|
89
|
+
return supporter.contribution + uint96(supporter.flowRate) * (block.timestamp - supporter.lastUpdated);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @dev This function is called when a token transfer occurs
|
|
94
|
+
* @param _sender The address of the sender
|
|
95
|
+
* @param _amount The amount of tokens being transferred
|
|
96
|
+
* @return bool Returns true to indicate that the transfer was successful
|
|
97
|
+
*/
|
|
98
|
+
function onTokenTransfer(address _sender, uint256 _amount, bytes calldata /*_data*/) external returns (bool) {
|
|
99
|
+
if (msg.sender != address(superToken)) revert UNSUPPORTED_TOKEN();
|
|
100
|
+
if (_amount == 0) revert ZERO_AMOUNT();
|
|
101
|
+
|
|
102
|
+
// Update the contribution amount for the sender in the supporters mapping
|
|
103
|
+
_updateSupporter(_sender, int96(int256(_amount / 1000)), block.timestamp - 1000);
|
|
104
|
+
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @dev This function supports the Superfluid protocol by allowing a sender to contribute tokens to the network.
|
|
110
|
+
* @param _sender The address of the sender who is contributing tokens.
|
|
111
|
+
* @param _amount The amount of tokens being contributed.
|
|
112
|
+
* @param _ctx The context of the transaction for superfluid
|
|
113
|
+
* @return Returns the context of the transaction.
|
|
114
|
+
*/
|
|
115
|
+
function support(
|
|
116
|
+
address _sender,
|
|
117
|
+
uint256 _amount,
|
|
118
|
+
bytes memory _ctx
|
|
119
|
+
) external onlyHostOrSender(_sender) returns (bytes memory) {
|
|
120
|
+
if (_amount == 0) revert ZERO_AMOUNT();
|
|
121
|
+
|
|
122
|
+
// Transfer the tokens from the sender to this contract
|
|
123
|
+
TransferHelper.safeTransferFrom(address(superToken), _sender, address(this), _amount);
|
|
124
|
+
|
|
125
|
+
// Update the contribution amount for the sender in the supporters mapping
|
|
126
|
+
_updateSupporter(_sender, int96(int256(_amount / 1000)), block.timestamp - 1000);
|
|
127
|
+
|
|
128
|
+
return _ctx;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @dev Handles the swap of tokens using the SwapData struct
|
|
133
|
+
* @param _customData The SwapData struct containing information about the swap
|
|
134
|
+
* @param _sender The address of the sender of the transaction
|
|
135
|
+
* @param _ctx The context of the transaction for superfluid
|
|
136
|
+
* @return Returns the context of the transaction
|
|
137
|
+
*/
|
|
138
|
+
function handleSwap(
|
|
139
|
+
SwapData memory _customData,
|
|
140
|
+
address _sender,
|
|
141
|
+
bytes memory _ctx
|
|
142
|
+
) external onlyHostOrSender(_sender) returns (bytes memory) {
|
|
143
|
+
// Transfer the tokens from the sender to this contract
|
|
144
|
+
TransferHelper.safeTransferFrom(_customData.swapFrom, _sender, address(this), _customData.amount);
|
|
145
|
+
|
|
146
|
+
// Approve the router to spend the tokens
|
|
147
|
+
TransferHelper.safeApprove(_customData.swapFrom, address(swapRouter), _customData.amount);
|
|
148
|
+
|
|
149
|
+
if (_customData.path.length > 0) {
|
|
150
|
+
// If a path is provided, execute a multi-hop swap
|
|
151
|
+
ISwapRouter.ExactInputParams memory params = ISwapRouter.ExactInputParams({
|
|
152
|
+
path: _customData.path,
|
|
153
|
+
recipient: _sender,
|
|
154
|
+
deadline: _customData.timestamp,
|
|
155
|
+
amountIn: _customData.amount,
|
|
156
|
+
amountOutMinimum: _customData.minReturn
|
|
157
|
+
});
|
|
158
|
+
swapRouter.exactInput(params);
|
|
159
|
+
} else {
|
|
160
|
+
// If no path is provided, execute a single-hop swap
|
|
161
|
+
ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({
|
|
162
|
+
tokenIn: _customData.swapFrom,
|
|
163
|
+
tokenOut: address(superToken),
|
|
164
|
+
fee: 10000,
|
|
165
|
+
recipient: _sender,
|
|
166
|
+
deadline: _customData.timestamp,
|
|
167
|
+
amountIn: _customData.amount,
|
|
168
|
+
amountOutMinimum: _customData.minReturn,
|
|
169
|
+
sqrtPriceLimitX96: 0
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Execute the swap using `exactInputSingle`
|
|
173
|
+
swapRouter.exactInputSingle(params);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Return the context of the transaction
|
|
177
|
+
return _ctx;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @dev Called when a new flow is created
|
|
182
|
+
* @param _sender The address of the sender of the transaction
|
|
183
|
+
* @param _ctx The context of the transaction
|
|
184
|
+
* @return Returns the new context of the transaction
|
|
185
|
+
*/
|
|
186
|
+
function onFlowCreated(
|
|
187
|
+
ISuperToken /*superToken*/,
|
|
188
|
+
address _sender,
|
|
189
|
+
bytes calldata _ctx
|
|
190
|
+
) internal virtual override returns (bytes memory /*newCtx*/) {
|
|
191
|
+
// Update the supporter's information
|
|
192
|
+
_updateSupporter(_sender, 0, 0);
|
|
193
|
+
|
|
194
|
+
// Return the context of the transaction
|
|
195
|
+
return _ctx;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @dev Called when an existing flow is updated
|
|
200
|
+
* @param _sender The address of the sender of the transaction
|
|
201
|
+
* @param _previousFlowRate The previous flow rate of the stream
|
|
202
|
+
* @param _lastUpdated The timestamp of the last update to the stream
|
|
203
|
+
* @param _ctx The context of the transaction
|
|
204
|
+
* @return Returns the new context of the transaction
|
|
205
|
+
*/
|
|
206
|
+
function onFlowUpdated(
|
|
207
|
+
ISuperToken /*superToken*/,
|
|
208
|
+
address _sender,
|
|
209
|
+
int96 _previousFlowRate,
|
|
210
|
+
uint256 _lastUpdated,
|
|
211
|
+
bytes calldata _ctx
|
|
212
|
+
) internal virtual override returns (bytes memory /*newCtx*/) {
|
|
213
|
+
// Update the supporter's information
|
|
214
|
+
_updateSupporter(_sender, _previousFlowRate, _lastUpdated);
|
|
215
|
+
|
|
216
|
+
// Return the context of the transaction
|
|
217
|
+
return _ctx;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* @dev Called when an existing flow is deleted
|
|
222
|
+
* @param _sender The address of the sender of the transaction
|
|
223
|
+
* @param _previousFlowRate The previous flow rate of the stream
|
|
224
|
+
* @param _lastUpdated The timestamp of the last update to the stream
|
|
225
|
+
* @param _ctx The context of the transaction
|
|
226
|
+
* @return Returns the new context of the transaction
|
|
227
|
+
*/
|
|
228
|
+
function onFlowDeleted(
|
|
229
|
+
ISuperToken /*superToken*/,
|
|
230
|
+
address _sender,
|
|
231
|
+
address /*receiver*/,
|
|
232
|
+
int96 _previousFlowRate,
|
|
233
|
+
uint256 _lastUpdated,
|
|
234
|
+
bytes calldata _ctx
|
|
235
|
+
) internal virtual override returns (bytes memory /*newCtx*/) {
|
|
236
|
+
// Update the supporter's information
|
|
237
|
+
_updateSupporter(_sender, _previousFlowRate, _lastUpdated);
|
|
238
|
+
|
|
239
|
+
// Return the context of the transaction
|
|
240
|
+
return _ctx;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @dev Updates the information for a supporter
|
|
245
|
+
* @param _supporter The address of the supporter
|
|
246
|
+
* @param _previousFlowRate The previous flow rate of the stream
|
|
247
|
+
* @param _lastUpdated The timestamp of the last update to the stream
|
|
248
|
+
*/
|
|
249
|
+
function _updateSupporter(address _supporter, int96 _previousFlowRate, uint256 _lastUpdated) internal {
|
|
250
|
+
// Get the current flow rate for the supporter
|
|
251
|
+
(, int96 flowRate, , ) = superToken.getFlowInfo(_supporter, address(this));
|
|
252
|
+
|
|
253
|
+
// Update the supporter's information
|
|
254
|
+
supporters[_supporter].lastUpdated = uint128(block.timestamp);
|
|
255
|
+
supporters[_supporter].flowRate = flowRate;
|
|
256
|
+
supporters[_supporter].contribution += uint96(_previousFlowRate) * (block.timestamp - _lastUpdated);
|
|
257
|
+
emit SupporterUpdated(_supporter, supporters[_supporter].contribution, flowRate, block.timestamp);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
modifier onlyHostOrSender(address _sender) {
|
|
261
|
+
if (msg.sender != _sender && msg.sender != address(host)) revert ONLY_HOST_OR_SENDER(msg.sender);
|
|
262
|
+
_;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPLv3
|
|
2
|
+
pragma solidity >=0.8.0;
|
|
3
|
+
|
|
4
|
+
import { ISuperfluid, ISuperToken, ISuperApp, SuperAppDefinitions } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
|
|
5
|
+
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
|
|
6
|
+
|
|
7
|
+
// import "hardhat/console.sol";
|
|
8
|
+
|
|
9
|
+
abstract contract SuperAppBaseFlow is ISuperApp {
|
|
10
|
+
using SuperTokenV1Library for ISuperToken;
|
|
11
|
+
|
|
12
|
+
bytes32 public constant CFAV1_TYPE = keccak256("org.superfluid-finance.agreements.ConstantFlowAgreement.v1");
|
|
13
|
+
|
|
14
|
+
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
|
|
15
|
+
ISuperfluid public immutable host;
|
|
16
|
+
|
|
17
|
+
/// @dev Thrown when the callback caller is not the host.
|
|
18
|
+
error UnauthorizedHost();
|
|
19
|
+
|
|
20
|
+
/// @dev Thrown if a required callback wasn't implemented (overridden by the SuperApp)
|
|
21
|
+
error NotImplemented();
|
|
22
|
+
|
|
23
|
+
/// @dev Thrown when SuperTokens not accepted by the SuperApp are streamed to it
|
|
24
|
+
error NotAcceptedSuperToken();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @dev Initializes the contract by setting the expected Superfluid Host.
|
|
28
|
+
* and register which callbacks the Host can engage when appropriate.
|
|
29
|
+
*/
|
|
30
|
+
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
31
|
+
constructor(ISuperfluid host_) {
|
|
32
|
+
host = host_;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @dev Optional (positive) filter for accepting only specific SuperTokens.
|
|
37
|
+
* The default implementation accepts all SuperTokens.
|
|
38
|
+
* Can be overridden by the SuperApp in order to apply arbitrary filters.
|
|
39
|
+
*/
|
|
40
|
+
function isAcceptedSuperToken(ISuperToken /*superToken*/) public view virtual returns (bool);
|
|
41
|
+
|
|
42
|
+
// ---------------------------------------------------------------------------------------------
|
|
43
|
+
// CFA specific convenience callbacks
|
|
44
|
+
// to be overridden and implemented by inheriting SuperApps
|
|
45
|
+
|
|
46
|
+
/// @dev override if the SuperApp shall have custom logic invoked when a new flow
|
|
47
|
+
/// to it is created.
|
|
48
|
+
function onFlowCreated(
|
|
49
|
+
ISuperToken /*superToken*/,
|
|
50
|
+
address /*sender*/,
|
|
51
|
+
bytes calldata ctx
|
|
52
|
+
) internal virtual returns (bytes memory /*newCtx*/) {
|
|
53
|
+
return ctx;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// @dev override if the SuperApp shall have custom logic invoked when an existing flow
|
|
57
|
+
/// to it is updated (flowrate change).
|
|
58
|
+
function onFlowUpdated(
|
|
59
|
+
ISuperToken /*superToken*/,
|
|
60
|
+
address /*sender*/,
|
|
61
|
+
int96 /*previousFlowRate*/,
|
|
62
|
+
uint256 /*lastUpdated*/,
|
|
63
|
+
bytes calldata ctx
|
|
64
|
+
) internal virtual returns (bytes memory /*newCtx*/) {
|
|
65
|
+
return ctx;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// @dev override if the SuperApp shall have custom logic invoked when an existing flow
|
|
69
|
+
/// to it is deleted (flowrate set to 0).
|
|
70
|
+
/// Unlike the other callbacks, this method is NOT allowed to revert.
|
|
71
|
+
/// Failing to satisfy that requirement leads to jailing (defunct SuperApp).
|
|
72
|
+
function onFlowDeleted(
|
|
73
|
+
ISuperToken /*superToken*/,
|
|
74
|
+
address /*sender*/,
|
|
75
|
+
address /*receiver*/,
|
|
76
|
+
int96 /*previousFlowRate*/,
|
|
77
|
+
uint256 /*lastUpdated*/,
|
|
78
|
+
bytes calldata ctx
|
|
79
|
+
) internal virtual returns (bytes memory /*newCtx*/) {
|
|
80
|
+
return ctx;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function beforeAgreementCreated(
|
|
84
|
+
ISuperToken superToken,
|
|
85
|
+
address agreementClass,
|
|
86
|
+
bytes32 /*agreementId*/,
|
|
87
|
+
bytes calldata /*agreementData*/,
|
|
88
|
+
bytes calldata /*ctx*/
|
|
89
|
+
) external view returns (bytes memory /*beforeData*/) {
|
|
90
|
+
if (msg.sender != address(host)) revert UnauthorizedHost();
|
|
91
|
+
if (!isAcceptedAgreement(agreementClass)) return "0x";
|
|
92
|
+
if (!isAcceptedSuperToken(superToken)) revert NotAcceptedSuperToken();
|
|
93
|
+
return "0x";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function afterAgreementCreated(
|
|
97
|
+
ISuperToken superToken,
|
|
98
|
+
address /*agreementClass*/,
|
|
99
|
+
bytes32 /*agreementId*/,
|
|
100
|
+
bytes calldata agreementData,
|
|
101
|
+
bytes calldata /*cbdata*/,
|
|
102
|
+
bytes calldata ctx
|
|
103
|
+
) external returns (bytes memory newCtx) {
|
|
104
|
+
(address sender, ) = abi.decode(agreementData, (address, address));
|
|
105
|
+
|
|
106
|
+
return
|
|
107
|
+
onFlowCreated(
|
|
108
|
+
superToken,
|
|
109
|
+
sender,
|
|
110
|
+
ctx // userData can be acquired with `host.decodeCtx(ctx).userData`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// UPDATED callbacks
|
|
115
|
+
|
|
116
|
+
function beforeAgreementUpdated(
|
|
117
|
+
ISuperToken superToken,
|
|
118
|
+
address agreementClass,
|
|
119
|
+
bytes32 /*agreementId*/,
|
|
120
|
+
bytes calldata agreementData,
|
|
121
|
+
bytes calldata /*ctx*/
|
|
122
|
+
) external view returns (bytes memory /*beforeData*/) {
|
|
123
|
+
if (msg.sender != address(host)) revert UnauthorizedHost();
|
|
124
|
+
if (!isAcceptedAgreement(agreementClass)) return "0x";
|
|
125
|
+
if (!isAcceptedSuperToken(superToken)) revert NotAcceptedSuperToken();
|
|
126
|
+
|
|
127
|
+
(address sender, ) = abi.decode(agreementData, (address, address));
|
|
128
|
+
(uint256 lastUpdated, int96 flowRate, , ) = superToken.getFlowInfo(sender, address(this));
|
|
129
|
+
|
|
130
|
+
return abi.encode(flowRate, lastUpdated);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function afterAgreementUpdated(
|
|
134
|
+
ISuperToken superToken,
|
|
135
|
+
address /*agreementClass*/,
|
|
136
|
+
bytes32 /*agreementId*/,
|
|
137
|
+
bytes calldata agreementData,
|
|
138
|
+
bytes calldata cbdata,
|
|
139
|
+
bytes calldata ctx
|
|
140
|
+
) external returns (bytes memory newCtx) {
|
|
141
|
+
(address sender, ) = abi.decode(agreementData, (address, address));
|
|
142
|
+
(int96 previousFlowRate, uint256 lastUpdated) = abi.decode(cbdata, (int96, uint256));
|
|
143
|
+
|
|
144
|
+
return
|
|
145
|
+
onFlowUpdated(
|
|
146
|
+
superToken,
|
|
147
|
+
sender,
|
|
148
|
+
previousFlowRate,
|
|
149
|
+
lastUpdated,
|
|
150
|
+
ctx // userData can be acquired with `host.decodeCtx(ctx).userData`
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// DELETED callbacks
|
|
155
|
+
|
|
156
|
+
function beforeAgreementTerminated(
|
|
157
|
+
ISuperToken superToken,
|
|
158
|
+
address agreementClass,
|
|
159
|
+
bytes32 /*agreementId*/,
|
|
160
|
+
bytes calldata agreementData,
|
|
161
|
+
bytes calldata /*ctx*/
|
|
162
|
+
) external view returns (bytes memory /*beforeData*/) {
|
|
163
|
+
// we're not allowed to revert in this callback, thus just return empty beforeData on failing checks
|
|
164
|
+
if (msg.sender != address(host) || !isAcceptedAgreement(agreementClass) || !isAcceptedSuperToken(superToken)) {
|
|
165
|
+
return "0x";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
(address sender, address receiver) = abi.decode(agreementData, (address, address));
|
|
169
|
+
(uint256 lastUpdated, int96 flowRate, , ) = superToken.getFlowInfo(sender, receiver);
|
|
170
|
+
|
|
171
|
+
return abi.encode(lastUpdated, flowRate);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function afterAgreementTerminated(
|
|
175
|
+
ISuperToken superToken,
|
|
176
|
+
address agreementClass,
|
|
177
|
+
bytes32 /*agreementId*/,
|
|
178
|
+
bytes calldata agreementData,
|
|
179
|
+
bytes calldata cbdata,
|
|
180
|
+
bytes calldata ctx
|
|
181
|
+
) external returns (bytes memory newCtx) {
|
|
182
|
+
// we're not allowed to revert in this callback, thus just return ctx on failing checks
|
|
183
|
+
if (msg.sender != address(host) || !isAcceptedAgreement(agreementClass) || !isAcceptedSuperToken(superToken)) {
|
|
184
|
+
return ctx;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
(address sender, address receiver) = abi.decode(agreementData, (address, address));
|
|
188
|
+
(uint256 lastUpdated, int96 previousFlowRate) = abi.decode(cbdata, (uint256, int96));
|
|
189
|
+
|
|
190
|
+
return onFlowDeleted(superToken, sender, receiver, previousFlowRate, lastUpdated, ctx);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// ---------------------------------------------------------------------------------------------
|
|
194
|
+
// HELPERS
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @dev Expect Super Agreement involved in callback to be an accepted one
|
|
198
|
+
* This function can be overridden with custom logic and to revert if desired
|
|
199
|
+
* Current implementation expects ConstantFlowAgreement
|
|
200
|
+
*/
|
|
201
|
+
function isAcceptedAgreement(address agreementClass) internal view virtual returns (bool) {
|
|
202
|
+
return agreementClass == address(host.getAgreementClass(CFAV1_TYPE));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
|
|
5
|
+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
6
|
+
|
|
7
|
+
contract SwapRouterMock {
|
|
8
|
+
IERC20 private immutable _token;
|
|
9
|
+
|
|
10
|
+
constructor(address token) {
|
|
11
|
+
_token = IERC20(token);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path
|
|
15
|
+
/// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata
|
|
16
|
+
/// @return amountOut The amount of the received token
|
|
17
|
+
function exactInput(ISwapRouter.ExactInputParams calldata params) external payable returns (uint256 amountOut) {
|
|
18
|
+
amountOut = params.amountOutMinimum;
|
|
19
|
+
|
|
20
|
+
// Transfer the output token to the recipient
|
|
21
|
+
_token.transfer(params.recipient, amountOut);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function exactInputSingle(
|
|
25
|
+
ISwapRouter.ExactInputSingleParams memory params
|
|
26
|
+
) external payable returns (uint256 amountOut) {
|
|
27
|
+
amountOut = params.amountOutMinimum;
|
|
28
|
+
|
|
29
|
+
// Transfer the output token to the recipient
|
|
30
|
+
_token.transfer(params.recipient, amountOut);
|
|
31
|
+
}
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddollar/goodcollective-contracts",
|
|
3
3
|
"packageManager": "yarn@3.2.1",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"types": "./typechain-types/index.ts",
|
|
7
7
|
"files": [
|
|
@@ -21,13 +21,16 @@
|
|
|
21
21
|
"@openzeppelin/contracts-upgradeable": "4.8.3",
|
|
22
22
|
"@openzeppelin/hardhat-upgrades": "1.20.0",
|
|
23
23
|
"@superfluid-finance/ethereum-contracts": "^1.7.0",
|
|
24
|
+
"@superfluid-finance/sdk-core": "^0.6.6",
|
|
24
25
|
"@typechain/ethers-v5": "^10.1.0",
|
|
25
26
|
"@types/chai": "^4.2.0",
|
|
26
27
|
"@types/mocha": ">=9.1.0",
|
|
27
28
|
"@types/prettier": "^2",
|
|
28
29
|
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
|
30
|
+
"@uniswap/v3-periphery": "^1.4.3",
|
|
29
31
|
"chai": "^4.2.0",
|
|
30
32
|
"dotenv": "^16.3.1",
|
|
33
|
+
"graphql": "^16.7.1",
|
|
31
34
|
"hardhat": "2.14.*",
|
|
32
35
|
"hardhat-abi-exporter": "^2.10.1",
|
|
33
36
|
"hardhat-contract-sizer": "^2.10.0",
|