|
| 1 | +// SPDX-License-Identifier: Apache 2 |
| 2 | + |
| 3 | +pragma solidity ^0.8.0; |
| 4 | + |
| 5 | +import "@pythnetwork/pyth-sdk-solidity/IPyth.sol"; |
| 6 | +import "@pythnetwork/pyth-sdk-solidity/PythStructs.sol"; |
| 7 | +import "./SchedulerEvents.sol"; |
| 8 | +import "./SchedulerState.sol"; |
| 9 | + |
| 10 | +interface IScheduler is SchedulerEvents { |
| 11 | + // CORE FUNCTIONS |
| 12 | + |
| 13 | + /** |
| 14 | + * @notice Adds a new subscription |
| 15 | + * @param subscriptionParams The parameters for the subscription |
| 16 | + * @return subscriptionId The ID of the newly created subscription |
| 17 | + */ |
| 18 | + function addSubscription( |
| 19 | + SchedulerState.SubscriptionParams calldata subscriptionParams |
| 20 | + ) external returns (uint256 subscriptionId); |
| 21 | + |
| 22 | + /** |
| 23 | + * @notice Gets a subscription's parameters and status |
| 24 | + * @param subscriptionId The ID of the subscription |
| 25 | + * @return params The subscription parameters |
| 26 | + * @return status The subscription status |
| 27 | + */ |
| 28 | + function getSubscription( |
| 29 | + uint256 subscriptionId |
| 30 | + ) |
| 31 | + external |
| 32 | + view |
| 33 | + returns ( |
| 34 | + SchedulerState.SubscriptionParams memory params, |
| 35 | + SchedulerState.SubscriptionStatus memory status |
| 36 | + ); |
| 37 | + |
| 38 | + /** |
| 39 | + * @notice Updates an existing subscription |
| 40 | + * @param subscriptionId The ID of the subscription to update |
| 41 | + * @param newSubscriptionParams The new parameters for the subscription |
| 42 | + */ |
| 43 | + function updateSubscription( |
| 44 | + uint256 subscriptionId, |
| 45 | + SchedulerState.SubscriptionParams calldata newSubscriptionParams |
| 46 | + ) external; |
| 47 | + |
| 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 | + /** |
| 55 | + * @notice Updates price feeds for a subscription. |
| 56 | + * Verifies the updateData using the Pyth contract and validates that all feeds have the same timestamp. |
| 57 | + * @param subscriptionId The ID of the subscription |
| 58 | + * @param updateData The price update data from Pyth |
| 59 | + * @param priceIds The IDs of the price feeds to update |
| 60 | + */ |
| 61 | + function updatePriceFeeds( |
| 62 | + uint256 subscriptionId, |
| 63 | + bytes[] calldata updateData, |
| 64 | + bytes32[] calldata priceIds |
| 65 | + ) external; |
| 66 | + |
| 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 |
| 72 | + */ |
| 73 | + function getLatestPrices( |
| 74 | + uint256 subscriptionId, |
| 75 | + bytes32[] calldata priceIds |
| 76 | + ) external view returns (PythStructs.PriceFeed[] memory); |
| 77 | + |
| 78 | + /** |
| 79 | + * @notice Adds funds to a subscription's balance |
| 80 | + * @param subscriptionId The ID of the subscription |
| 81 | + */ |
| 82 | + function addFunds(uint256 subscriptionId) external payable; |
| 83 | + |
| 84 | + /** |
| 85 | + * @notice Withdraws funds from a subscription's balance |
| 86 | + * @param subscriptionId The ID of the subscription |
| 87 | + * @param amount The amount to withdraw |
| 88 | + */ |
| 89 | + function withdrawFunds(uint256 subscriptionId, uint256 amount) external; |
| 90 | + |
| 91 | + /** |
| 92 | + * @notice Gets all active subscriptions with their parameters |
| 93 | + * @dev This function has no access control to allow keepers to discover active subscriptions |
| 94 | + * @return subscriptionIds Array of active subscription IDs |
| 95 | + * @return subscriptionParams Array of subscription parameters for each active subscription |
| 96 | + */ |
| 97 | + function getActiveSubscriptions() |
| 98 | + external |
| 99 | + view |
| 100 | + returns ( |
| 101 | + uint256[] memory subscriptionIds, |
| 102 | + SchedulerState.SubscriptionParams[] memory subscriptionParams |
| 103 | + ); |
| 104 | +} |
0 commit comments