|  | 
|  | 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 | +    ) external view returns (SchedulerState.SubscriptionParams memory params, SchedulerState.SubscriptionStatus memory status); | 
|  | 31 | + | 
|  | 32 | +    /** | 
|  | 33 | +     * @notice Updates an existing subscription | 
|  | 34 | +     * @param subscriptionId The ID of the subscription to update | 
|  | 35 | +     * @param newSubscriptionParams The new parameters for the subscription | 
|  | 36 | +     */ | 
|  | 37 | +    function updateSubscription( | 
|  | 38 | +        uint256 subscriptionId, | 
|  | 39 | +        SchedulerState.SubscriptionParams calldata newSubscriptionParams | 
|  | 40 | +    ) external; | 
|  | 41 | + | 
|  | 42 | +    /** | 
|  | 43 | +     * @notice Deactivates a subscription | 
|  | 44 | +     * @param subscriptionId The ID of the subscription to deactivate | 
|  | 45 | +     */ | 
|  | 46 | +    function deactivateSubscription( | 
|  | 47 | +        uint256 subscriptionId | 
|  | 48 | +    ) external; | 
|  | 49 | + | 
|  | 50 | +    /** | 
|  | 51 | +     * @notice Updates price feeds for a subscription | 
|  | 52 | +     * @dev Verifies the updateData using the Pyth contract and validates that all feeds have the same timestamp | 
|  | 53 | +     * @param subscriptionId The ID of the subscription | 
|  | 54 | +     * @param updateData The price update data from Pyth | 
|  | 55 | +     * @param priceIds The IDs of the price feeds to update | 
|  | 56 | +     */ | 
|  | 57 | +    function updatePriceFeeds( | 
|  | 58 | +        uint256 subscriptionId, | 
|  | 59 | +        bytes[] calldata updateData, | 
|  | 60 | +        bytes32[] calldata priceIds | 
|  | 61 | +    ) external; | 
|  | 62 | + | 
|  | 63 | +    /** | 
|  | 64 | +     * @notice Gets the latest prices for a subscription | 
|  | 65 | +     * @param subscriptionId The ID of the subscription | 
|  | 66 | +     * @param priceIds Optional array of price IDs to retrieve. If empty, returns all price feeds for the subscription. | 
|  | 67 | +     * @return The latest price feeds for the requested price IDs | 
|  | 68 | +     */ | 
|  | 69 | +    function getLatestPrices( | 
|  | 70 | +        uint256 subscriptionId, | 
|  | 71 | +        bytes32[] calldata priceIds | 
|  | 72 | +    ) external view returns (PythStructs.PriceFeed[] memory); | 
|  | 73 | + | 
|  | 74 | +    /** | 
|  | 75 | +     * @notice Adds funds to a subscription's balance | 
|  | 76 | +     * @param subscriptionId The ID of the subscription | 
|  | 77 | +     */ | 
|  | 78 | +    function addFunds( | 
|  | 79 | +        uint256 subscriptionId | 
|  | 80 | +    ) external payable; | 
|  | 81 | + | 
|  | 82 | +    /** | 
|  | 83 | +     * @notice Withdraws funds from a subscription's balance | 
|  | 84 | +     * @param subscriptionId The ID of the subscription | 
|  | 85 | +     * @param amount The amount to withdraw | 
|  | 86 | +     */ | 
|  | 87 | +    function withdrawFunds( | 
|  | 88 | +        uint256 subscriptionId, | 
|  | 89 | +        uint256 amount | 
|  | 90 | +    ) external; | 
|  | 91 | +     | 
|  | 92 | +    /** | 
|  | 93 | +     * @notice Gets all active subscriptions with their parameters | 
|  | 94 | +     * @return subscriptionIds Array of active subscription IDs | 
|  | 95 | +     * @return subscriptionParams Array of subscription parameters for each active subscription | 
|  | 96 | +     */ | 
|  | 97 | +    function getActiveSubscriptions() external view returns ( | 
|  | 98 | +        uint256[] memory subscriptionIds, | 
|  | 99 | +        SchedulerState.SubscriptionParams[] memory subscriptionParams | 
|  | 100 | +    ); | 
|  | 101 | +} | 
0 commit comments