Skip to content

Commit e5ef15d

Browse files
feat(scenarios): tag the Pyth v2 and Phoenix collections clock-sensitive
feat(scenarios): tag the Pyth v2 and Phoenix collections clock-sensitive
1 parent 3c12d40 commit e5ef15d

4 files changed

Lines changed: 31 additions & 0 deletions

File tree

‎crates/core/src/scenarios/README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ This is a cumbersome process in most cases.
8888
Override templates that are registered in the Surfpool repo will automatically be available in Surfpool Studio's drag-and-drop UI for creating scenarios.
8989
This UI will automatically create the `surfnet_registerScenario` payload for you, eliminating the complexity from the process.
9090

91+
A collection tagged `clock-sensitive` holds accounts with a time or slot the program checks against the Clock, such as a
92+
Pyth price's `publish_time` or the oracle staleness window of Phoenix markets. Playing such a scenario with the clock paused
93+
leaves fetched accounts ahead of the surfnet's time, and the program can refuse transactions; Studio warns before pausing for
94+
them. The tag applies to every template in the collection, including ones without a time check.
95+
9196
## Creating Native Scenario Support for a Protocol
9297
Having a protocol being natively supported by Surfpool Scenarios will allow users to easily create scenarios to override account states for that protocol.
9398
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.

‎crates/core/src/scenarios/protocols/phoenix-eternal/v1/overrides.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ tags:
77
- perpetuals
88
- collateral
99
- risk
10+
- clock-sensitive
1011

1112
templates:
1213
- id: phoenix-oracle-price

‎crates/core/src/scenarios/protocols/pyth/v2/overrides.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ tags:
77
- oracle
88
- price-feed
99
- defi
10+
- clock-sensitive
1011

1112
constants:
1213
price_feed:

‎crates/core/src/scenarios/registry.rs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,30 @@ templates: []
10521052
);
10531053
}
10541054

1055+
#[test]
1056+
fn test_clock_sensitive_tag_marks_pyth_and_every_phoenix_template() {
1057+
let registry = TemplateRegistry::new();
1058+
let tagged: Vec<&str> = registry
1059+
.by_tags(&["clock-sensitive".to_string()])
1060+
.iter()
1061+
.map(|template| template.id.as_str())
1062+
.collect();
1063+
1064+
let phoenix = registry.by_protocol("Phoenix Eternal");
1065+
assert!(
1066+
!phoenix.is_empty(),
1067+
"the Phoenix Eternal templates are registered"
1068+
);
1069+
for template in std::iter::once("pyth-price-feed-v2")
1070+
.chain(phoenix.iter().map(|template| template.id.as_str()))
1071+
{
1072+
assert!(
1073+
tagged.contains(&template),
1074+
"{template} must be clock-sensitive"
1075+
);
1076+
}
1077+
}
1078+
10551079
#[test]
10561080
fn test_jupiter_idl_has_token_ledger_account() {
10571081
let registry = TemplateRegistry::new();

0 commit comments

Comments
 (0)