-
Notifications
You must be signed in to change notification settings - Fork 305
pulse-scheduler: init ethereum contracts, subscriptions, updating prices #2572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
404e1f4
feat(scheduler): init scheduler state and core functions
tejasbadadare 2ff7b4e
ci: apply precommit
tejasbadadare b6c01a4
test(scheduler): add pulsescheduler tests
tejasbadadare 2d50188
fix: better naming
tejasbadadare 6261818
test: add test for mismatched timestamps
tejasbadadare 7605555
fix: access control, add todos
tejasbadadare 50b341f
feat(scheduler): enhance price update logic and validation
tejasbadadare 800e1ef
Merge branch 'main' of github.com:pyth-network/pyth-crosschain into t…
tejasbadadare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
target_chains/ethereum/contracts/contracts/pulse/scheduler/IScheduler.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| // SPDX-License-Identifier: Apache 2 | ||
|
|
||
| pragma solidity ^0.8.0; | ||
|
|
||
| import "@pythnetwork/pyth-sdk-solidity/IPyth.sol"; | ||
| import "@pythnetwork/pyth-sdk-solidity/PythStructs.sol"; | ||
| import "./SchedulerEvents.sol"; | ||
| import "./SchedulerState.sol"; | ||
|
|
||
| interface IScheduler is SchedulerEvents { | ||
| // CORE FUNCTIONS | ||
|
|
||
| /** | ||
| * @notice Adds a new subscription | ||
tejasbadadare marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * @param subscriptionParams The parameters for the subscription | ||
| * @return subscriptionId The ID of the newly created subscription | ||
| */ | ||
| function addSubscription( | ||
| SchedulerState.SubscriptionParams calldata subscriptionParams | ||
| ) external returns (uint256 subscriptionId); | ||
|
|
||
| /** | ||
| * @notice Gets a subscription's parameters and status | ||
| * @param subscriptionId The ID of the subscription | ||
| * @return params The subscription parameters | ||
| * @return status The subscription status | ||
| */ | ||
| function getSubscription( | ||
| uint256 subscriptionId | ||
| ) | ||
| external | ||
| view | ||
| returns ( | ||
| SchedulerState.SubscriptionParams memory params, | ||
| SchedulerState.SubscriptionStatus memory status | ||
| ); | ||
|
|
||
| /** | ||
| * @notice Updates an existing subscription | ||
| * @param subscriptionId The ID of the subscription to update | ||
| * @param newSubscriptionParams The new parameters for the subscription | ||
| */ | ||
| function updateSubscription( | ||
| uint256 subscriptionId, | ||
| SchedulerState.SubscriptionParams calldata newSubscriptionParams | ||
| ) external; | ||
|
|
||
| /** | ||
| * @notice Deactivates a subscription | ||
| * @param subscriptionId The ID of the subscription to deactivate | ||
| */ | ||
| function deactivateSubscription(uint256 subscriptionId) external; | ||
|
|
||
| /** | ||
| * @notice Updates price feeds for a subscription. | ||
| * Verifies the updateData using the Pyth contract and validates that all feeds have the same timestamp. | ||
| * @param subscriptionId The ID of the subscription | ||
| * @param updateData The price update data from Pyth | ||
| * @param priceIds The IDs of the price feeds to update | ||
| */ | ||
| function updatePriceFeeds( | ||
| uint256 subscriptionId, | ||
| bytes[] calldata updateData, | ||
| bytes32[] calldata priceIds | ||
| ) external; | ||
|
|
||
| /** | ||
| * @notice Gets the latest prices for a subscription | ||
| * @param subscriptionId The ID of the subscription | ||
| * @param priceIds Optional array of price IDs to retrieve. If empty, returns all price feeds for the subscription. | ||
| * @return The latest price feeds for the requested price IDs | ||
| */ | ||
| function getLatestPrices( | ||
| uint256 subscriptionId, | ||
| bytes32[] calldata priceIds | ||
| ) external view returns (PythStructs.PriceFeed[] memory); | ||
|
|
||
| /** | ||
| * @notice Adds funds to a subscription's balance | ||
| * @param subscriptionId The ID of the subscription | ||
| */ | ||
| function addFunds(uint256 subscriptionId) external payable; | ||
|
|
||
| /** | ||
| * @notice Withdraws funds from a subscription's balance | ||
| * @param subscriptionId The ID of the subscription | ||
| * @param amount The amount to withdraw | ||
| */ | ||
| function withdrawFunds(uint256 subscriptionId, uint256 amount) external; | ||
|
|
||
| /** | ||
| * @notice Gets all active subscriptions with their parameters | ||
| * @dev This function has no access control to allow keepers to discover active subscriptions | ||
| * @return subscriptionIds Array of active subscription IDs | ||
| * @return subscriptionParams Array of subscription parameters for each active subscription | ||
| */ | ||
| function getActiveSubscriptions() | ||
| external | ||
| view | ||
| returns ( | ||
| uint256[] memory subscriptionIds, | ||
| SchedulerState.SubscriptionParams[] memory subscriptionParams | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.