Add currentFlowRate param to onFlowCreated and onFlowUpdated hooks as it is used in almost every cases in the implementation side. Unnecessary for onFlowDeleted as it should be a constant 0.
function onFlowCreated(
ISuperToken /*superToken*/,
address /*sender*/,
int96 /*currentFlowRate*/, // <==================== here
bytes calldata ctx
) internal virtual returns (bytes memory /*newCtx*/) {
return ctx;
}
function onFlowUpdated(
ISuperToken /*superToken*/,
address /*sender*/,
int96 /*currentFlowRate*/, // <==================== here
int96 /*previousFlowRate*/,
uint256 /*lastUpdated*/,
bytes calldata ctx
) internal virtual returns (bytes memory /*newCtx*/) {
return ctx;
}
function afterAgreementCreated(
ISuperToken superToken,
address agreementClass,
bytes32 /*agreementId*/,
bytes calldata agreementData,
bytes calldata /*cbdata*/,
bytes calldata ctx
) external override returns (bytes memory newCtx) {
if (msg.sender != address(HOST)) revert UnauthorizedHost();
if (!isAcceptedAgreement(agreementClass)) return ctx;
if (!isAcceptedSuperToken(superToken)) revert NotAcceptedSuperToken();
(address sender, ) = abi.decode(agreementData, (address, address));
int96 currentFlowRate = superToken.getFlowRate(sender, address(this)); // <==================== here
return
onFlowCreated(
superToken,
sender,
currentFlowRate, // <==================== here
ctx // userData can be acquired with `host.decodeCtx(ctx).userData`
);
}
function afterAgreementUpdated(
ISuperToken superToken,
address agreementClass,
bytes32 /*agreementId*/,
bytes calldata agreementData,
bytes calldata cbdata,
bytes calldata ctx
) external override returns (bytes memory newCtx) {
if (msg.sender != address(HOST)) revert UnauthorizedHost();
if (!isAcceptedAgreement(agreementClass)) return ctx;
if (!isAcceptedSuperToken(superToken)) revert NotAcceptedSuperToken();
(address sender, ) = abi.decode(agreementData, (address, address));
(int96 previousFlowRate, uint256 lastUpdated) = abi.decode(cbdata, (int96, uint256));
int96 currentFlowRate = superToken.getFlowRate(sender, address(this)); // <==================== here
return
onFlowUpdated(
superToken,
sender,
currentFlowRate, // <==================== here
previousFlowRate,
lastUpdated,
ctx // userData can be acquired with `host.decodeCtx(ctx).userData`
);
}
Add
currentFlowRateparam toonFlowCreatedandonFlowUpdatedhooks as it is used in almost every cases in the implementation side. Unnecessary foronFlowDeletedas it should be a constant 0.