Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDA Pool Permission #2010

Merged
merged 7 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/ethereum-contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

* `IUserDefinedMacro`: added a method `postCheck()` which allows to verify state changes after running the macro.

### Fixed

* GDA Pools are not multi-tokens ready, added a permission check (#2010).

## [v1.11.0]

### Breaking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi

newCtx = ctx;

if (_isPool(token, address(pool)) == false) {
if (_isPool(token, address(pool)) == false ||
// Note: we do not support multi-tokens pools
pool.superToken() != token) {
revert GDA_ONLY_SUPER_TOKEN_POOL();
}

Expand Down Expand Up @@ -485,7 +487,9 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
int96 requestedFlowRate,
bytes calldata ctx
) external override returns (bytes memory newCtx) {
if (_isPool(token, address(pool)) == false) {
if (_isPool(token, address(pool)) == false ||
// Note: we do not support multi-tokens pools
pool.superToken() != token) {
revert GDA_ONLY_SUPER_TOKEN_POOL();
}
if (requestedFlowRate < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ contract GeneralDistributionAgreementV1IntegrationTest is FoundrySuperfluidTeste
vm.stopPrank();
}

function testRevertDistributeFlowToPoolOfWrongToken(int96 requestedFlowRate) public {
vm.assume(requestedFlowRate >= 0);
vm.assume(requestedFlowRate < int96(type(int64).max));
ISuperToken badToken = sfDeployer.deployNativeAssetSuperToken("Super Bad", "BADx");
vm.startPrank(alice);
vm.expectRevert(IGeneralDistributionAgreementV1.GDA_ONLY_SUPER_TOKEN_POOL.selector);
badToken.distributeFlow(alice, ISuperfluidPool(bob), requestedFlowRate);
vm.stopPrank();
}

function testRevertDistributeFromAnyAddressWhenNotAllowed(bool useForwarder) public {
PoolConfig memory config = PoolConfig({ transferabilityForUnitsOwner: true, distributionFromAnyAddress: false });
ISuperfluidPool pool = _helperCreatePool(superToken, alice, alice, useForwarder, config);
Expand Down Expand Up @@ -258,6 +268,15 @@ contract GeneralDistributionAgreementV1IntegrationTest is FoundrySuperfluidTeste
vm.stopPrank();
}

function testRevertDistributeToPoolOfWrongToken(uint256 requestedAmount) public {
vm.assume(requestedAmount < uint256(type(uint128).max));
ISuperToken badToken = sfDeployer.deployNativeAssetSuperToken("Super Bad", "BADx");
vm.startPrank(alice);
vm.expectRevert(IGeneralDistributionAgreementV1.GDA_ONLY_SUPER_TOKEN_POOL.selector);
badToken.distributeToPool(alice, ISuperfluidPool(bob), requestedAmount);
vm.stopPrank();
}

function testRevertDistributeForOthers(address signer, uint256 requestedAmount) public {
ISuperfluidPool pool = _helperCreatePool(superToken, alice, alice, false, poolConfig);
vm.assume(requestedAmount < uint256(type(uint128).max));
Expand Down
Loading