Skip to content

Commit b74f034

Browse files
committed
feat(target_chains/ethreum): add transaction fee handling to fee calculations and state management in pyth contract
1 parent 3b92ed5 commit b74f034

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ abstract contract Pyth is
330330
function getTotalFee(
331331
uint totalNumUpdates
332332
) private view returns (uint requiredFee) {
333-
return totalNumUpdates * singleUpdateFeeInWei();
333+
return
334+
(totalNumUpdates * singleUpdateFeeInWei()) + transactionFeeInWei();
334335
}
335336

336337
function findIndexOfPriceId(

target_chains/ethereum/contracts/contracts/pyth/PythGetters.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,8 @@ contract PythGetters is PythState {
9191
function governanceDataSourceIndex() public view returns (uint32) {
9292
return _state.governanceDataSourceIndex;
9393
}
94+
95+
function transactionFeeInWei() public view returns (uint) {
96+
return _state.transactionFeeInWei;
97+
}
9498
}

target_chains/ethereum/contracts/contracts/pyth/PythSetters.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ contract PythSetters is PythState, IPythEvents {
4848
function setGovernanceDataSourceIndex(uint32 newIndex) internal {
4949
_state.governanceDataSourceIndex = newIndex;
5050
}
51+
52+
function setTransactionFeeInWei(uint fee) internal {
53+
_state.transactionFeeInWei = fee;
54+
}
5155
}

target_chains/ethereum/contracts/contracts/pyth/PythState.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ contract PythStorage {
3838
// Mapping of cached price information
3939
// priceId => PriceInfo
4040
mapping(bytes32 => PythInternalStructs.PriceInfo) latestPriceInfo;
41+
// Fee charged per transaction, in addition to per-update fees
42+
uint transactionFeeInWei;
4143
}
4244
}
4345

0 commit comments

Comments
 (0)