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

[ETHEREUM-CONTRACTS] Disable flownfts #1991

Merged
merged 25 commits into from
Aug 5, 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: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
// 3. if you want to use nix further, do "nix develop"
"postCreateCommand": [
"curl -L https://foundry.paradigm.xyz | bash",
"source /home/node/.bashrc && foundryup",
"source /home/vscode/.bashrc && foundryup",
"yarn global add npm-run-all",
"yarn install && yarn build",
"sudo apt-get install libpq5", // for subgraph's matchstick
"./tasks/fix-devcontainer.sh && nix develop . -c bash <(echo \"yarn install && yarn build\")"
"./tasks/fix-devcontainer.sh && yarn shell . -c bash <(echo \"yarn install && yarn build\")"
]
// Configure tool-specific properties.
// "customizations": {},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/call.test-local-subgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- name: "Docker compose"
run: |
docker rm subgraph_graph-node_1 || true
docker-compose up &
docker compose up &
working-directory: ${{ env.subgraph-working-directory }}

- name: "Run subgraph integration test suite"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/call.test-sdk-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
- name: "Docker compose"
run: |
docker rm subgraph_graph-node_1 || true
docker-compose up &
docker compose up &
working-directory: ${{ env.subgraph-working-directory }}

- name: "Build and deploy local subgraph"
Expand All @@ -86,7 +86,7 @@ jobs:
- name: "Run test suite"
if: inputs.run-coverage-tests == false
run: |
yarn generate-graphql-schema:${{ inputs.subgraph-release }}
yarn get-graphql-schema:${{ inputs.subgraph-release }}
./tasks/setupTestEnvironment.sh
npx hardhat test --network localhost
working-directory: ${{ env.sdk-core-working-directory }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
- name: "Docker compose"
run: |
docker rm subgraph_graph-node_1 || true
docker-compose up &
docker compose up &
working-directory: ./packages/subgraph

- name: "Prepare and Deploy Local Subgraph"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/handler.publish-release-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
id: publish-sdk-core
if: env.PUBLISH_SDK_CORE == 1
run: |
yarn --cwd packages/sdk-core generate-graphql-schema:v1
yarn --cwd packages/sdk-core get-graphql-schema:v1
yarn --cwd packages/ethereum-contracts build
yarn --cwd packages/sdk-core build
tasks/npm-publish.sh packages/sdk-core/ latest
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
if: env.PUBLISH_SDK_REDUX == 1
run: |
yarn --cwd packages/ethereum-contracts build
yarn --cwd packages/sdk-core generate-graphql-schema:v1
yarn --cwd packages/sdk-core get-graphql-schema:v1
yarn --cwd packages/sdk-core build
yarn --cwd packages/sdk-redux build
tasks/npm-publish.sh packages/sdk-redux/ latest
Expand Down
4 changes: 2 additions & 2 deletions packages/automation-contracts/autowrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"devDependencies": {
"@openzeppelin/contracts": "4.9.6",
"@superfluid-finance/ethereum-contracts": "^1.10.0",
"@superfluid-finance/metadata": "^1.3.1"
"@superfluid-finance/ethereum-contracts": "^1.11.0",
"@superfluid-finance/metadata": "^1.4.0"
}
}
4 changes: 2 additions & 2 deletions packages/automation-contracts/scheduler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"devDependencies": {
"@openzeppelin/contracts": "4.9.6",
"@superfluid-finance/ethereum-contracts": "^1.10.0",
"@superfluid-finance/metadata": "^1.3.1"
"@superfluid-finance/ethereum-contracts": "^1.11.0",
"@superfluid-finance/metadata": "^1.4.0"
}
}
6 changes: 6 additions & 0 deletions packages/ethereum-contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ All notable changes to the ethereum-contracts will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v1.11.0]

### Breaking

- FlowNFTs are being deprecated. The hooks aren't invoked anymore by CFA and GDA.

## [v1.10.0]

### Breaking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import {
ISuperfluid,
ISuperfluidGovernance,
ISuperApp,
ISuperToken,
ISuperfluidToken,
IConstantFlowAgreementV1,
FlowOperatorDefinitions,
SuperAppDefinitions,
ContextDefinitions,
SuperfluidGovernanceConfigs,
IConstantOutflowNFT
SuperfluidGovernanceConfigs
} from "../interfaces/superfluid/ISuperfluid.sol";
import { AgreementBase } from "./AgreementBase.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
Expand Down Expand Up @@ -431,71 +429,6 @@ contract ConstantFlowAgreementV1 is
if (flowParams.flowRate <= 0) revert CFA_INVALID_FLOW_RATE();
}


/**
* @notice Checks whether or not the NFT hook can be called.
* @dev A staticcall, so `CONSTANT_OUTFLOW_NFT` must be a view otherwise the assumption is that it reverts
* @param token the super token that is being streamed
* @return constantOutflowNFTAddress the address returned by low level call
*/
function _canCallNFTHook(
ISuperfluidToken token
) internal view returns (address constantOutflowNFTAddress) {
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory data) = address(token).staticcall(
abi.encodeWithSelector(ISuperToken.CONSTANT_OUTFLOW_NFT.selector)
);

if (success) {
// @note We are aware this may revert if a Custom SuperToken's
// CONSTANT_OUTFLOW_NFT does not return data that can be
// decoded to an address. This would mean it was intentionally
// done by the creator of the Custom SuperToken logic and is
// fully expected to revert in that case as the author desired.
constantOutflowNFTAddress = abi.decode(data, (address));
}
}

function _handleOnCreateHook(
_StackVars_createOrUpdateFlow memory flowVars
) internal {
address constantOutflowNFTAddress = _canCallNFTHook(flowVars.token);

if (constantOutflowNFTAddress != address(0)) {
IConstantOutflowNFT(constantOutflowNFTAddress).onCreate(
flowVars.token,
flowVars.sender,
flowVars.receiver
);
}
}

function _handleOnUpdateHook(
_StackVars_createOrUpdateFlow memory flowVars
) internal {
address constantOutflowNFTAddress = _canCallNFTHook(flowVars.token);
if (constantOutflowNFTAddress != address(0)) {
IConstantOutflowNFT(constantOutflowNFTAddress).onUpdate(
flowVars.token,
flowVars.sender,
flowVars.receiver
);
}
}

function _handleOnDeleteHook(
_StackVars_createOrUpdateFlow memory flowVars
) internal {
address constantOutflowNFTAddress = _canCallNFTHook(flowVars.token);
if (constantOutflowNFTAddress != address(0)) {
IConstantOutflowNFT(constantOutflowNFTAddress).onDelete(
flowVars.token,
flowVars.sender,
flowVars.receiver
);
}
}

function _createFlow(
_StackVars_createOrUpdateFlow memory flowVars,
bytes calldata ctx,
Expand All @@ -521,8 +454,6 @@ contract ConstantFlowAgreementV1 is
}

_requireAvailableBalance(flowVars.token, flowVars.sender, currentContext);

_handleOnCreateHook(flowVars);
}

function _updateFlow(
Expand Down Expand Up @@ -551,8 +482,6 @@ contract ConstantFlowAgreementV1 is
}

_requireAvailableBalance(flowVars.token, flowVars.sender, currentContext);

_handleOnUpdateHook(flowVars);
}

function _deleteFlow(
Expand Down Expand Up @@ -663,8 +592,6 @@ contract ConstantFlowAgreementV1 is
newCtx, currentContext);
}
}

_handleOnDeleteHook(flowVars);
}

/**************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
} from "../../interfaces/agreements/gdav1/IGeneralDistributionAgreementV1.sol";
import { SuperfluidUpgradeableBeacon } from "../../upgradability/SuperfluidUpgradeableBeacon.sol";
import { ISuperfluidToken } from "../../interfaces/superfluid/ISuperfluidToken.sol";
import { IConstantOutflowNFT } from "../../interfaces/superfluid/IConstantOutflowNFT.sol";
import { ISuperToken } from "../../interfaces/superfluid/ISuperToken.sol";
import { IPoolAdminNFT } from "../../interfaces/agreements/gdav1/IPoolAdminNFT.sol";
import { ISuperfluidPool } from "../../interfaces/agreements/gdav1/ISuperfluidPool.sol";
Expand Down Expand Up @@ -565,31 +564,6 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
}
}

// handleFlowNFT() - mint/burn FlowNFT to flow distributor
{
address constantOutflowNFTAddress = _getConstantOutflowNFTAddress(token);

if (constantOutflowNFTAddress != address(0)) {
// create flow (mint)
if (requestedFlowRate > 0 && FlowRate.unwrap(flowVars.oldFlowRate) == 0) {
// solhint-disable-next-line no-empty-blocks
IConstantOutflowNFT(constantOutflowNFTAddress).onCreate(token, from, address(pool));
}

// update flow (update metadata)
if (requestedFlowRate > 0 && FlowRate.unwrap(flowVars.oldFlowRate) > 0) {
// solhint-disable-next-line no-empty-blocks
IConstantOutflowNFT(constantOutflowNFTAddress).onUpdate(token, from, address(pool));
}

// delete flow (burn)
if (requestedFlowRate == 0) {
// solhint-disable-next-line no-empty-blocks
IConstantOutflowNFT(constantOutflowNFTAddress).onDelete(token, from, address(pool));
}
}
}

{
(address adjustmentFlowRecipient,, int96 adjustmentFlowRate) =
_getPoolAdjustmentFlowInfo(abi.encode(token), address(pool));
Expand All @@ -609,31 +583,6 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
}
}

/**
* @notice Checks whether or not the NFT hook can be called.
* @dev A staticcall, so `CONSTANT_OUTFLOW_NFT` must be a view otherwise the assumption is that it reverts
* @param token the super token that is being streamed
* @return constantOutflowNFTAddress the address returned by low level call
*/
function _getConstantOutflowNFTAddress(ISuperfluidToken token)
internal
view
returns (address constantOutflowNFTAddress)
{
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory data) =
address(token).staticcall(abi.encodeWithSelector(ISuperToken.CONSTANT_OUTFLOW_NFT.selector));

if (success) {
// @note We are aware this may revert if a Custom SuperToken's
// CONSTANT_OUTFLOW_NFT does not return data that can be
// decoded to an address. This would mean it was intentionally
// done by the creator of the Custom SuperToken logic and is
// fully expected to revert in that case as the author desired.
constantOutflowNFTAddress = abi.decode(data, (address));
}
}

function _getPoolAdminNFTAddress(ISuperfluidToken token) internal view returns (address poolAdminNFTAddress) {
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory data) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ library SuperfluidLoaderLibrary {
uint256 private constant CELO_MAINNET = 42220;
uint256 private constant AVALANCHE_C = 43114;
uint256 private constant SCROLL_MAINNET = 534352;
uint256 private constant DEGENCHAIN = 666666666;


// testnets
uint256 private constant AVALANCHE_FUJI = 43113;
uint256 private constant SCROLL_SEPOLIA = 534351;
uint256 private constant ETH_SEPOLIA = 11155111;
uint256 private constant OPTIMISM_SEPOLIA = 11155420;
uint256 private constant BASE_SEPOLIA = 84532;


function getHost() public view returns (address) {
Expand All @@ -46,6 +48,8 @@ library SuperfluidLoaderLibrary {
return 0x60377C7016E4cdB03C87EF474896C11cB560752C;
} else if (block.chainid == SCROLL_MAINNET) {
return 0x0F86a21F6216c061B222c224e315d9FC34520bb7;
} else if (block.chainid == DEGENCHAIN) {
return 0xc1314EdcD7e478C831a7a24169F7dEADB2646eD2;
// testnets
} else if (block.chainid == AVALANCHE_FUJI) {
return 0x85Fe79b998509B77BF10A8BD4001D58475D29386;
Expand All @@ -55,6 +59,8 @@ library SuperfluidLoaderLibrary {
return 0x109412E3C84f0539b43d39dB691B08c90f58dC7c;
} else if (block.chainid == OPTIMISM_SEPOLIA) {
return 0xd399e2Fb5f4cf3722a11F65b88FAB6B2B8621005;
} else if (block.chainid == BASE_SEPOLIA) {
return 0x109412E3C84f0539b43d39dB691B08c90f58dC7c;
} else {
revert UnsupportedNetwork();
}
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading