Skip to content

Commit 671c6c3

Browse files
committed
feat: enhance fee charging logic for TWAP updates to improve user experience
1 parent 74217f9 commit 671c6c3

File tree

1 file changed

+3
-0
lines changed
  • target_chains/ethereum/contracts/contracts/pyth

1 file changed

+3
-0
lines changed

target_chains/ethereum/contracts/contracts/pyth/Pyth.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,14 @@ abstract contract Pyth is
373373
if (updateData.length != 2) {
374374
revert PythErrors.InvalidUpdateData();
375375
}
376+
// We only charge fee for 1 update even though we need 2 updates to derive TWAP.
377+
// This is for better UX since user's intention is to get a single TWAP price.
376378
uint requiredFee = getUpdateFee(updateData[0]);
377379

378380
if (requiredFee != getUpdateFee(updateData[1])) {
379381
revert PythErrors.InvalidUpdateData();
380382
}
383+
381384
if (msg.value < requiredFee) revert PythErrors.InsufficientFee();
382385

383386
unchecked {

0 commit comments

Comments
 (0)