Skip to content

Commit

Permalink
setCFAFlowRate -> flow
Browse files Browse the repository at this point in the history
  • Loading branch information
d10r committed Oct 30, 2024
1 parent 74e1d21 commit 0b33f76
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ library SuperTokenV1Library {
* @param flowRate The wanted flowrate in wad/second. Only positive values are valid here.
* @return bool
*/
function setCFAFlowRate(
function flow(

Check warning on line 1439 in packages/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol

View check run for this annotation

Codecov / codecov/patch

packages/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol#L1439

Added line #L1439 was not covered by tests
ISuperToken token,
address receiver,
int96 flowRate
Expand All @@ -1463,15 +1463,15 @@ library SuperTokenV1Library {
}

/**
* @notice Like `setCFAFlowRate`, but can be invoked by an account with flowOperator permissions
* @notice Like `flow`, but can be invoked by an account with flowOperator permissions
* on behalf of the sender account.
* @param token Super token address
* @param sender The sender of the flow
* @param receiver The receiver of the flow
* @param flowRate The wanted flowRate in wad/second. Only positive values are valid here.
* @return bool
*/
function setCFAFlowRateFrom(
function flowFrom(

Check warning on line 1474 in packages/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol

View check run for this annotation

Codecov / codecov/patch

packages/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol#L1474

Added line #L1474 was not covered by tests
ISuperToken token,
address sender,
address receiver,
Expand Down Expand Up @@ -1522,7 +1522,7 @@ library SuperTokenV1Library {
flowRate
);
} else {
return setCFAFlowRate(token, receiverOrPool, flowRate);
return flow(token, receiverOrPool, flowRate);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ contract SuperTokenV1LibraryTest is FoundrySuperfluidTester {

function testGetCFAFlowRate() external {
assertEq(superToken.getCFAFlowRate(address(this), bob), 0);
superToken.setCFAFlowRate(bob, DEFAULT_FLOWRATE);
superToken.flow(bob, DEFAULT_FLOWRATE);
assertEq(superToken.getCFAFlowRate(address(this), bob), DEFAULT_FLOWRATE);
}

function testGetCFAFlowInfo() external {
superToken.setCFAFlowRate(bob, DEFAULT_FLOWRATE);
superToken.flow(bob, DEFAULT_FLOWRATE);
(uint256 refLastUpdated, int96 refFlowRate, uint256 refDeposit, uint256 refOwedDeposit)
= sf.cfa.getFlow(superToken, address(this), bob);
(uint256 lastUpdated, int96 flowRate, uint256 deposit, uint256 owedDeposit) =
Expand All @@ -63,23 +63,23 @@ contract SuperTokenV1LibraryTest is FoundrySuperfluidTester {

function testSetGetCFAFlowRate() external {
// initial createFlow
superToken.setCFAFlowRate(bob, DEFAULT_FLOWRATE);
superToken.flow(bob, DEFAULT_FLOWRATE);
assertEq(_getCFAFlowRate(address(this), bob), DEFAULT_FLOWRATE, "createFlow unexpected result");

// double it -> updateFlow
superToken.setCFAFlowRate(bob, DEFAULT_FLOWRATE * 2);
superToken.flow(bob, DEFAULT_FLOWRATE * 2);
assertEq(_getCFAFlowRate(address(this), bob), DEFAULT_FLOWRATE * 2, "updateFlow unexpected result");

// set to 0 -> deleteFlow
superToken.setCFAFlowRate(bob, 0);
superToken.flow(bob, 0);
assertEq(_getCFAFlowRate(address(this), bob), 0, "deleteFlow unexpected result");

// invalid flowrate
vm.expectRevert(IConstantFlowAgreementV1.CFA_INVALID_FLOW_RATE.selector);
this.__externalSetCFAFlowRate(address(this), bob, -1);
this.__externalflow(address(this), bob, -1);
}

function testSetCFAFlowRateFrom() external {
function testflowFrom() external {
// alice allows this Test contract to operate CFA flows on her behalf
vm.startPrank(alice);
sf.host.callAgreement(
Expand All @@ -90,19 +90,19 @@ contract SuperTokenV1LibraryTest is FoundrySuperfluidTester {
vm.stopPrank();

// initial createFlow
superToken.setCFAFlowRateFrom(alice, bob, DEFAULT_FLOWRATE);
superToken.flowFrom(alice, bob, DEFAULT_FLOWRATE);
assertEq(_getCFAFlowRate(alice, bob), DEFAULT_FLOWRATE, "createFlow unexpected result");

// double it -> updateFlow
superToken.setCFAFlowRateFrom(alice, bob, DEFAULT_FLOWRATE * 2);
superToken.flowFrom(alice, bob, DEFAULT_FLOWRATE * 2);
assertEq(_getCFAFlowRate(alice, bob), DEFAULT_FLOWRATE * 2, "updateFlow unexpected result");

// set to 0 -> deleteFlow
superToken.setCFAFlowRateFrom(alice, bob, 0);
superToken.flowFrom(alice, bob, 0);
assertEq(_getCFAFlowRate(alice, bob), 0, "deleteFlow unexpected result");

vm.expectRevert(IConstantFlowAgreementV1.CFA_INVALID_FLOW_RATE.selector);
this.__externalSetCFAFlowRateFrom(address(this), alice, bob, -1);
this.__externalflowFrom(address(this), alice, bob, -1);
}

function testFlowXToAccount() external {
Expand Down Expand Up @@ -164,15 +164,15 @@ contract SuperTokenV1LibraryTest is FoundrySuperfluidTester {

// helpers converting the lib call to an external call, for exception checking

function __externalSetCFAFlowRate(address msgSender, address receiver, int96 flowRate) external {
function __externalflow(address msgSender, address receiver, int96 flowRate) external {
vm.startPrank(msgSender);
superToken.setCFAFlowRate(receiver, flowRate);
superToken.flow(receiver, flowRate);
vm.stopPrank();
}

function __externalSetCFAFlowRateFrom(address msgSender, address sender, address receiver, int96 flowRate) external {
function __externalflowFrom(address msgSender, address sender, address receiver, int96 flowRate) external {
vm.startPrank(msgSender);
superToken.setCFAFlowRateFrom(sender, receiver, flowRate);
superToken.flowFrom(sender, receiver, flowRate);
vm.stopPrank();
}
}

0 comments on commit 0b33f76

Please sign in to comment.