diff --git a/crates/core/src/scenarios/README.md b/crates/core/src/scenarios/README.md index 65e2d5683..199ae704c 100644 --- a/crates/core/src/scenarios/README.md +++ b/crates/core/src/scenarios/README.md @@ -85,6 +85,11 @@ This is a cumbersome process in most cases. Override templates that are registered in the Surfpool repo will automatically be available in Surfpool Studio's drag-and-drop UI for creating scenarios. This UI will automatically create the `surfnet_registerScenario` payload for you, eliminating the complexity from the process. +A collection tagged `clock-sensitive` holds accounts with a time or slot the program checks against the Clock, such as a +Pyth price's `publish_time` or the oracle staleness window of Phoenix markets. Playing such a scenario with the clock paused +leaves fetched accounts ahead of the surfnet's time, and the program can refuse transactions; Studio warns before pausing for +them. The tag applies to every template in the collection, including ones without a time check. + ## Creating Native Scenario Support for a Protocol Having a protocol being natively supported by Surfpool Scenarios will allow users to easily create scenarios to override account states for that protocol. All accounts in a surfnet's account db that are owned by the protocol will include automatic IDL-parsing, and the protocol's account overrides will be available in Surfpool Studio's drag-and-drop UI. diff --git a/crates/core/src/scenarios/protocols/phoenix-eternal/v1/overrides.yaml b/crates/core/src/scenarios/protocols/phoenix-eternal/v1/overrides.yaml index 9a7d3a51f..72a78e48b 100644 --- a/crates/core/src/scenarios/protocols/phoenix-eternal/v1/overrides.yaml +++ b/crates/core/src/scenarios/protocols/phoenix-eternal/v1/overrides.yaml @@ -7,6 +7,7 @@ tags: - perpetuals - collateral - risk + - clock-sensitive templates: - id: phoenix-oracle-price diff --git a/crates/core/src/scenarios/protocols/pyth/v2/overrides.yaml b/crates/core/src/scenarios/protocols/pyth/v2/overrides.yaml index 415fe4347..bdc65802d 100644 --- a/crates/core/src/scenarios/protocols/pyth/v2/overrides.yaml +++ b/crates/core/src/scenarios/protocols/pyth/v2/overrides.yaml @@ -7,6 +7,7 @@ tags: - oracle - price-feed - defi + - clock-sensitive constants: price_feed: diff --git a/crates/core/src/scenarios/registry.rs b/crates/core/src/scenarios/registry.rs index 4e2088488..84299e19b 100644 --- a/crates/core/src/scenarios/registry.rs +++ b/crates/core/src/scenarios/registry.rs @@ -1052,6 +1052,30 @@ templates: [] ); } + #[test] + fn test_clock_sensitive_tag_marks_pyth_and_every_phoenix_template() { + let registry = TemplateRegistry::new(); + let tagged: Vec<&str> = registry + .by_tags(&["clock-sensitive".to_string()]) + .iter() + .map(|template| template.id.as_str()) + .collect(); + + let phoenix = registry.by_protocol("Phoenix Eternal"); + assert!( + !phoenix.is_empty(), + "the Phoenix Eternal templates are registered" + ); + for template in std::iter::once("pyth-price-feed-v2") + .chain(phoenix.iter().map(|template| template.id.as_str())) + { + assert!( + tagged.contains(&template), + "{template} must be clock-sensitive" + ); + } + } + #[test] fn test_jupiter_idl_has_token_ledger_account() { let registry = TemplateRegistry::new();