You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This method is called by Pulse to provide the price updates to the consumer.
11
+
// It asserts that the msg.sender is the Pulse contract. It is not meant to be
12
+
// overridden by the consumer.
13
+
function _pulseCallback(
14
+
uint64sequenceNumber,
15
+
PythStructs.PriceFeed[] memorypriceFeeds
16
+
) external {
17
+
address pulse =getPulse();
18
+
require(pulse !=address(0), "Pulse address not set");
19
+
require(msg.sender== pulse, "Only Pulse can call this function");
20
+
21
+
pulseCallback(sequenceNumber, priceFeeds);
22
+
}
23
+
24
+
// getPulse returns the Pulse contract address. The method is being used to check that the
25
+
// callback is indeed from the Pulse contract. The consumer is expected to implement this method.
26
+
function getPulse() internalviewvirtualreturns (address);
27
+
28
+
// This method is expected to be implemented by the consumer to handle the price updates.
29
+
// It will be called by _pulseCallback after _pulseCallback ensures that the call is
30
+
// indeed from Pulse contract.
10
31
function pulseCallback(
11
32
uint64sequenceNumber,
12
33
PythStructs.PriceFeed[] memorypriceFeeds
13
-
) external;
34
+
) internalvirtual;
14
35
}
15
36
16
37
interfaceIPulseisPulseEvents {
17
38
// Core functions
18
39
/**
19
40
* @notice Requests price updates with a callback
20
41
* @dev The msg.value must be equal to getFee(callbackGasLimit)
21
-
* @param callbackGasLimit The amount of gas allocated for the callback execution
42
+
* @param provider The provider to fulfill the request
22
43
* @param publishTime The minimum publish time for price updates, it should be less than or equal to block.timestamp + 60
23
44
* @param priceIds The price feed IDs to update. Maximum 10 price feeds per request.
24
45
* Requests requiring more feeds should be split into multiple calls.
46
+
* @param callbackGasLimit The amount of gas allocated for the callback execution
25
47
* @return sequenceNumber The sequence number assigned to this request
26
48
* @dev Security note: The 60-second future limit on publishTime prevents a DoS vector where
27
49
* attackers could submit many low-fee requests for far-future updates when gas prices
@@ -30,7 +52,8 @@ interface IPulse is PulseEvents {
30
52
* the fee estimation unreliable.
31
53
*/
32
54
function requestPriceUpdatesWithCallback(
33
-
uint256publishTime,
55
+
addressprovider,
56
+
uint64publishTime,
34
57
bytes32[] calldatapriceIds,
35
58
uint256callbackGasLimit
36
59
) externalpayablereturns (uint64sequenceNumber);
@@ -39,11 +62,13 @@ interface IPulse is PulseEvents {
39
62
* @notice Executes the callback for a price update request
40
63
* @dev Requires 1.5x the callback gas limit to account for cross-contract call overhead
41
64
* For example, if callbackGasLimit is 1M, the transaction needs at least 1.5M gas + some gas for some other operations in the function before the callback
65
+
* @param providerToCredit The provider to credit for fulfilling the request. This may not be the provider that submitted the request (if the exclusivity period has elapsed).
42
66
* @param sequenceNumber The sequence number of the request
43
67
* @param updateData The raw price update data from Pyth
44
68
* @param priceIds The price feed IDs to update, must match the request
45
69
*/
46
70
function executeCallback(
71
+
addressproviderToCredit,
47
72
uint64sequenceNumber,
48
73
bytes[] calldataupdateData,
49
74
bytes32[] calldatapriceIds
@@ -59,15 +84,22 @@ interface IPulse is PulseEvents {
59
84
60
85
/**
61
86
* @notice Calculates the total fee required for a price update request
62
-
* @dev Total fee = base Pyth protocol fee + gas costs for callback
87
+
* @dev Total fee = base Pyth protocol fee + base provider fee + provider fee per feed + gas costs for callback
88
+
* @param provider The provider to fulfill the request
63
89
* @param callbackGasLimit The amount of gas allocated for callback execution
90
+
* @param priceIds The price feed IDs to update.
64
91
* @return feeAmount The total fee in wei that must be provided as msg.value
65
92
*/
66
93
function getFee(
67
-
uint256callbackGasLimit
94
+
addressprovider,
95
+
uint256callbackGasLimit,
96
+
bytes32[] calldatapriceIds
68
97
) externalviewreturns (uint128feeAmount);
69
98
70
-
function getAccruedFees() externalviewreturns (uint128accruedFeesInWei);
99
+
function getAccruedPythFees()
100
+
external
101
+
view
102
+
returns (uint128accruedFeesInWei);
71
103
72
104
function getRequest(
73
105
uint64sequenceNumber
@@ -83,9 +115,18 @@ interface IPulse is PulseEvents {
83
115
84
116
function withdrawAsFeeManager(addressprovider, uint128amount) external;
85
117
86
-
function registerProvider(uint128feeInWei) external;
118
+
function registerProvider(
119
+
uint128baseFeeInWei,
120
+
uint128feePerFeedInWei,
121
+
uint128feePerGasInWei
122
+
) external;
87
123
88
-
function setProviderFee(uint128newFeeInWei) external;
0 commit comments