@@ -8,16 +8,15 @@ import "./SchedulerEvents.sol";
8
8
import "./SchedulerState.sol " ;
9
9
10
10
interface IScheduler is SchedulerEvents {
11
- // CORE FUNCTIONS
12
-
13
11
/**
14
- * @notice Adds a new subscription
12
+ * @notice Creates a new subscription
13
+ * @dev Requires msg.value to be at least the minimum balance for the subscription (calculated by getMinimumBalance()).
15
14
* @param subscriptionParams The parameters for the subscription
16
15
* @return subscriptionId The ID of the newly created subscription
17
16
*/
18
- function addSubscription (
17
+ function createSubscription (
19
18
SchedulerState.SubscriptionParams calldata subscriptionParams
20
- ) external returns (uint256 subscriptionId );
19
+ ) external payable returns (uint256 subscriptionId );
21
20
22
21
/**
23
22
* @notice Gets a subscription's parameters and status
@@ -37,6 +36,8 @@ interface IScheduler is SchedulerEvents {
37
36
38
37
/**
39
38
* @notice Updates an existing subscription
39
+ * @dev You can activate or deactivate a subscription by setting isActive to true or false.
40
+ * @dev Reactivating a subscription requires the subscription to hold at least the minimum balance (calculated by getMinimumBalance()).
40
41
* @param subscriptionId The ID of the subscription to update
41
42
* @param newSubscriptionParams The new parameters for the subscription
42
43
*/
@@ -45,12 +46,6 @@ interface IScheduler is SchedulerEvents {
45
46
SchedulerState.SubscriptionParams calldata newSubscriptionParams
46
47
) external ;
47
48
48
- /**
49
- * @notice Deactivates a subscription
50
- * @param subscriptionId The ID of the subscription to deactivate
51
- */
52
- function deactivateSubscription (uint256 subscriptionId ) external ;
53
-
54
49
/**
55
50
* @notice Updates price feeds for a subscription.
56
51
* Verifies the updateData using the Pyth contract and validates that all feeds have the same timestamp.
@@ -64,16 +59,36 @@ interface IScheduler is SchedulerEvents {
64
59
bytes32 [] calldata priceIds
65
60
) external ;
66
61
67
- /**
68
- * @notice Gets the latest prices for a subscription
69
- * @param subscriptionId The ID of the subscription
70
- * @param priceIds Optional array of price IDs to retrieve. If empty, returns all price feeds for the subscription.
71
- * @return The latest price feeds for the requested price IDs
62
+ /** @notice Returns the price of a price feed without any sanity checks.
63
+ * @dev This function returns the most recent price update in this contract without any recency checks.
64
+ * This function is unsafe as the returned price update may be arbitrarily far in the past.
65
+ *
66
+ * Users of this function should check the `publishTime` in the price to ensure that the returned price is
67
+ * sufficiently recent for their application. If you are considering using this function, it may be
68
+ * safer / easier to use `getPriceNoOlderThan`.
69
+ * @return prices - please read the documentation of PythStructs.Price to understand how to use this safely.
70
+ */
71
+ function getPricesUnsafe (
72
+ uint256 subscriptionId ,
73
+ bytes32 [] calldata priceIds
74
+ ) external view returns (PythStructs.Price[] memory prices );
75
+
76
+ /** @notice Returns the exponentially-weighted moving average price of a price feed without any sanity checks.
77
+ * @dev This function returns the same price as `getEmaPrice` in the case where the price is available.
78
+ * However, if the price is not recent this function returns the latest available price.
79
+ *
80
+ * The returned price can be from arbitrarily far in the past; this function makes no guarantees that
81
+ * the returned price is recent or useful for any particular application.
82
+ *
83
+ * Users of this function should check the `publishTime` in the price to ensure that the returned price is
84
+ * sufficiently recent for their application. If you are considering using this function, it may be
85
+ * safer / easier to use either `getEmaPrice` or `getEmaPriceNoOlderThan`.
86
+ * @return price - please read the documentation of PythStructs.Price to understand how to use this safely.
72
87
*/
73
- function getLatestPrices (
88
+ function getEmaPriceUnsafe (
74
89
uint256 subscriptionId ,
75
90
bytes32 [] calldata priceIds
76
- ) external view returns (PythStructs.PriceFeed [] memory );
91
+ ) external view returns (PythStructs.Price [] memory price );
77
92
78
93
/**
79
94
* @notice Adds funds to a subscription's balance
@@ -82,23 +97,40 @@ interface IScheduler is SchedulerEvents {
82
97
function addFunds (uint256 subscriptionId ) external payable ;
83
98
84
99
/**
85
- * @notice Withdraws funds from a subscription's balance
100
+ * @notice Withdraws funds from a subscription's balance.
101
+ * @dev A minimum balance must be maintained for active subscriptions. To withdraw past
102
+ * the minimum balance limit, deactivate the subscription first.
86
103
* @param subscriptionId The ID of the subscription
87
104
* @param amount The amount to withdraw
88
105
*/
89
106
function withdrawFunds (uint256 subscriptionId , uint256 amount ) external ;
90
107
108
+ /**
109
+ * @notice Returns the minimum balance an active subscription of a given size needs to hold.
110
+ * @param numPriceFeeds The number of price feeds in the subscription.
111
+ */
112
+ function getMinimumBalance (
113
+ uint8 numPriceFeeds
114
+ ) external view returns (uint256 minimumBalanceInWei );
115
+
91
116
/**
92
117
* @notice Gets all active subscriptions with their parameters
93
118
* @dev This function has no access control to allow keepers to discover active subscriptions
119
+ * @param startIndex The starting index for pagination
120
+ * @param maxResults The maximum number of results to return
94
121
* @return subscriptionIds Array of active subscription IDs
95
122
* @return subscriptionParams Array of subscription parameters for each active subscription
123
+ * @return totalCount Total number of active subscriptions
96
124
*/
97
- function getActiveSubscriptions ()
125
+ function getActiveSubscriptions (
126
+ uint256 startIndex ,
127
+ uint256 maxResults
128
+ )
98
129
external
99
130
view
100
131
returns (
101
132
uint256 [] memory subscriptionIds ,
102
- SchedulerState.SubscriptionParams[] memory subscriptionParams
133
+ SchedulerState.SubscriptionParams[] memory subscriptionParams ,
134
+ uint256 totalCount
103
135
);
104
136
}
0 commit comments