From 14ef5206cfc5c9d68063b03abed2ee7c8564e73b Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Wed, 10 Jan 2024 18:51:08 +0530 Subject: [PATCH] fix: check is valid allocator (#455) * fix: check is valid allocator * fmt * fix * fix * fix --------- Co-authored-by: 0xKurt --- .../_poc/sqf-superfluid/RecipientSuperApp.sol | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/contracts/strategies/_poc/sqf-superfluid/RecipientSuperApp.sol b/contracts/strategies/_poc/sqf-superfluid/RecipientSuperApp.sol index 1e456a56d..a990f7064 100644 --- a/contracts/strategies/_poc/sqf-superfluid/RecipientSuperApp.sol +++ b/contracts/strategies/_poc/sqf-superfluid/RecipientSuperApp.sol @@ -16,6 +16,8 @@ import {IInstantDistributionAgreementV1} from import {SQFSuperFluidStrategy} from "./SQFSuperFluidStrategy.sol"; contract RecipientSuperApp is ISuperApp { + error UNAUTHORIZED(); + using SuperTokenV1Library for ISuperToken; bytes32 public constant CFAV1_TYPE = keccak256("org.superfluid-finance.agreements.ConstantFlowAgreement.v1"); @@ -84,6 +86,16 @@ contract RecipientSuperApp is ISuperApp { return address(_superToken) == address(acceptedToken); } + /// @notice This is the main callback function called by the host + /// to notify the app about the callback context. + function onFlowCreated(int96 previousFlowRate, int96 newFlowRate, address sender, bytes calldata ctx) + internal + returns (bytes memory newCtx) + { + if (!strategy.isValidAllocator(sender)) revert UNAUTHORIZED(); + newCtx = onFlowUpdated(previousFlowRate, newFlowRate, ctx); + } + /// @notice This is the main callback function called by the host /// to notify the app about the callback context. function onFlowUpdated(int96 previousFlowRate, int96 newFlowRate, bytes calldata ctx) @@ -156,9 +168,10 @@ contract RecipientSuperApp is ISuperApp { (address sender,) = abi.decode(agreementData, (address, address)); (, int96 flowRate,,) = superToken.getFlowInfo(sender, address(this)); - return onFlowUpdated( + return onFlowCreated( 0, flowRate, + sender, ctx // userData can be acquired with `host.decodeCtx(ctx).userData` ); }