Skip to content

Commit 4eedc9f

Browse files
committed
changed API
1 parent 892d48b commit 4eedc9f

File tree

2 files changed

+14
-22
lines changed

2 files changed

+14
-22
lines changed

src/AdSpotContract.sol

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ contract AdSpotContract is CFASuperAppBase {
180180
ISuperToken,
181181
/*superToken*/
182182
address sender,
183+
int96 flowRate,
183184
bytes calldata ctx
184185
)
185186
internal
186187
override
187188
returns (bytes memory newCtx)
188189
{
189-
int96 senderFlowRate = acceptedToken.getFlowRate(sender, address(this));
190-
require(senderFlowRate > highestFlowRate, "Sender flowrate lower than current flowRate");
190+
require(flowRate > highestFlowRate, "Sender flowrate lower than current flowRate");
191191
newCtx = ctx;
192192
if (highestBidder != address(0)) {
193193
newCtx = acceptedToken.deleteFlowWithCtx(highestBidder, address(this), ctx);
@@ -200,10 +200,10 @@ contract AdSpotContract is CFASuperAppBase {
200200
pool.updateMemberUnits(highestBidder, halfShares + pool.getUnits(highestBidder));
201201
}
202202
highestBidder = sender;
203-
highestFlowRate = senderFlowRate;
203+
highestFlowRate = flowRate;
204204
lastUpdate = block.timestamp;
205205
emit newHighestBidder(highestBidder, highestFlowRate);
206-
newCtx = acceptedToken.distributeFlowWithCtx(address(this), pool, senderFlowRate, newCtx);
206+
newCtx = acceptedToken.distributeFlowWithCtx(address(this), pool, flowRate, newCtx);
207207
return newCtx;
208208
}
209209

@@ -219,28 +219,20 @@ contract AdSpotContract is CFASuperAppBase {
219219
function onFlowUpdated(
220220
ISuperToken,
221221
address sender,
222-
int96 previousflowRate,
223-
uint256,
224-
/*lastUpdated*/
222+
int96 flowRate,
223+
int96 previousFlowRate,
224+
uint256 lastUpdated,
225225
bytes calldata ctx
226-
)
227-
internal
228-
override
229-
returns (bytes memory newCtx)
230-
{
231-
int96 senderFlowRate = acceptedToken.getFlowRate(sender, address(this));
232-
require(
233-
senderFlowRate > previousflowRate,
234-
"Sender flowRate is lower than the previous one, delete flowrate and start a new one lower"
235-
);
236-
require(senderFlowRate > highestFlowRate, "You already have a flowrate that is higher than this one");
226+
) internal override returns (bytes memory newCtx) {
227+
require(flowRate > previousFlowRate, "Sender flowRate is lower than the previous one, delete flowrate and start a new one lower");
228+
require(flowRate > highestFlowRate, "You already have a flowrate that is higher than this one");
237229
newCtx = ctx;
238230
uint128 halfShares = SafeCast.toUint128(block.timestamp - lastUpdate) / 2;
239231
ISuperfluidPool(poolAddress).updateMemberUnits(owner, halfShares + pool.getUnits(owner));
240232
ISuperfluidPool(poolAddress).updateMemberUnits(highestBidder, halfShares + pool.getUnits(highestBidder));
241-
newCtx = acceptedToken.distributeFlowWithCtx(address(this), pool, senderFlowRate, newCtx);
233+
newCtx = acceptedToken.distributeFlowWithCtx(address(this), pool, flowRate, newCtx);
242234
highestBidder = sender;
243-
highestFlowRate = senderFlowRate;
235+
highestFlowRate = flowRate;
244236
lastUpdate = block.timestamp;
245237
emit newHighestBidder(highestBidder, highestFlowRate);
246238
return newCtx;
@@ -254,7 +246,7 @@ contract AdSpotContract is CFASuperAppBase {
254246
* @return bytes Returns the new transaction context.
255247
*/
256248

257-
function onFlowDeleted(
249+
function onInFlowDeleted(
258250
ISuperToken,
259251
/*superToken*/
260252
address sender,

0 commit comments

Comments
 (0)