Skip to content

Commit 0020b33

Browse files
authored
AA-288 L-08 Incomplete Event [samples] (eth-infinitism#431)
* Replacing cachedPrice with cachedPriceWithMarkup in event
1 parent 14eec23 commit 0020b33

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

contracts/samples/TokenPaymaster.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ contract TokenPaymaster is BasePaymaster, UniswapHelper, OracleHelper {
4141

4242
event ConfigUpdated(TokenPaymasterConfig tokenPaymasterConfig);
4343

44-
event UserOperationSponsored(address indexed user, uint256 actualTokenCharge, uint256 actualGasCost, uint256 actualTokenPrice);
44+
event UserOperationSponsored(address indexed user, uint256 actualTokenCharge, uint256 actualGasCost, uint256 actualTokenPriceWithMarkup);
4545

4646
event Received(address indexed sender, uint256 value);
4747

@@ -184,7 +184,7 @@ contract TokenPaymaster is BasePaymaster, UniswapHelper, OracleHelper {
184184
);
185185
}
186186

187-
emit UserOperationSponsored(userOpSender, actualTokenNeeded, actualGasCost, _cachedPrice);
187+
emit UserOperationSponsored(userOpSender, actualTokenNeeded, actualGasCost, cachedPriceWithMarkup);
188188
refillEntryPointDeposit(_cachedPrice);
189189
}
190190
}

reports/gas-checker.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
4545
║ paymaster+postOp with diff │ 11 │ │ 42951 │ 13972 ║
4646
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
47-
║ token paymaster │ 1 │ 128503 │ │ ║
47+
║ token paymaster │ 1 │ 128491 │ │ ║
4848
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
49-
║ token paymaster with diff │ 2 │ │ 6613337154
49+
║ token paymaster with diff │ 2 │ │ 6612137142
5050
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
51-
║ token paymaster │ 10 │ 723935 │ │ ║
51+
║ token paymaster │ 10 │ 723863 │ │ ║
5252
╟────────────────────────────────┼───────┼───────────────┼────────────────┼─────────────────────╢
53-
║ token paymaster with diff │ 11 │ │ 6619237213
53+
║ token paymaster with diff │ 11 │ │ 6610837129
5454
╚════════════════════════════════╧═══════╧═══════════════╧════════════════╧═════════════════════╝
5555

test/samples/TokenPaymaster.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,9 @@ describe('TokenPaymaster', function () {
208208
const refundTokens = decodedLogs[2].args.value
209209
const actualTokenChargeEvents = preChargeTokens.sub(refundTokens)
210210
const actualTokenCharge = decodedLogs[3].args.actualTokenCharge
211-
const actualTokenPrice = decodedLogs[3].args.actualTokenPrice
211+
const actualTokenPriceWithMarkup = decodedLogs[3].args.actualTokenPriceWithMarkup
212212
const actualGasCostPaymaster = decodedLogs[3].args.actualGasCost
213213
const actualGasCostEntryPoint = decodedLogs[4].args.actualGasCost
214-
const expectedTokenPrice = initialPriceToken / initialPriceEther // ether is 5x the token => ether-per-token is 0.2
215214
const addedPostOpCost = BigNumber.from(op.maxFeePerGas).mul(40000)
216215

217216
// note: as price is in ether-per-token, and we want more tokens, increasing it means dividing it by markup
@@ -224,7 +223,7 @@ describe('TokenPaymaster', function () {
224223
assert.equal(decodedLogs[4].args.success, true)
225224
assert.equal(actualTokenChargeEvents.toString(), actualTokenCharge.toString())
226225
assert.equal(actualTokenChargeEvents.toString(), expectedTokenCharge.toString())
227-
assert.equal(actualTokenPrice / (priceDenominator as any), expectedTokenPrice)
226+
assert.equal(actualTokenPriceWithMarkup.toString(), expectedTokenPriceWithMarkup.toString())
228227
assert.closeTo(postOpGasCost.div(tx.effectiveGasPrice).toNumber(), 50000, 20000)
229228
await ethers.provider.send('evm_revert', [snapshot])
230229
})
@@ -256,10 +255,11 @@ describe('TokenPaymaster', function () {
256255

257256
const oldExpectedPrice = priceDenominator.mul(initialPriceToken).div(initialPriceEther)
258257
const newExpectedPrice = oldExpectedPrice.div(2) // ether DOUBLED in price relative to token
258+
const oldExpectedPriceWithMarkup = oldExpectedPrice.mul(10).div(15)
259+
const newExpectedPriceWithMarkup = oldExpectedPriceWithMarkup.div(2)
259260

260-
const actualTokenPrice = decodedLogs[4].args.actualTokenPrice
261-
assert.equal(actualTokenPrice.toString(), newExpectedPrice.toString())
262-
261+
const actualTokenPriceWithMarkup = decodedLogs[4].args.actualTokenPriceWithMarkup
262+
assert.equal(actualTokenPriceWithMarkup.toString(), newExpectedPriceWithMarkup.toString())
263263
await expect(tx).to
264264
.emit(paymaster, 'TokenPriceUpdated')
265265
.withArgs(newExpectedPrice, oldExpectedPrice, block.timestamp)

0 commit comments

Comments
 (0)