diff --git a/libraries/sbv2-utils/README.md b/libraries/sbv2-utils/README.md
new file mode 100644
index 0000000..348fd70
--- /dev/null
+++ b/libraries/sbv2-utils/README.md
@@ -0,0 +1,13 @@
+# Sbv2-Utils
+
+[](https://github.com/switchboard-xyz/switchboard-v2/tree/main/libraries/sbv2-utils)
+[](https://www.npmjs.com/package/@switchboard-xyz/sbv2-utils)
+[](https://twitter.com/switchboardxyz)
+
+A library of utility functions to interact with the Switchboardv2 program
+
+## Install
+
+```
+npm i @switchboard-xyz/sbv2-utils
+```
diff --git a/website/api/_tasks.md b/website/api/_tasks.md
index 3d7b00a..72dea3d 100644
--- a/website/api/_tasks.md
+++ b/website/api/_tasks.md
@@ -11,6 +11,7 @@
- [OracleJob.CacheTask](#.OracleJob.CacheTask)
- [OracleJob.CacheTask.CacheItem](#.OracleJob.CacheTask.CacheItem)
- [OracleJob.ConditionalTask](#.OracleJob.ConditionalTask)
+ - [OracleJob.CronParseTask](#.OracleJob.CronParseTask)
- [OracleJob.DefiKingdomsTask](#.OracleJob.DefiKingdomsTask)
- [OracleJob.DefiKingdomsTask.Token](#.OracleJob.DefiKingdomsTask.Token)
- [OracleJob.DivideTask](#.OracleJob.DivideTask)
@@ -49,6 +50,7 @@
- [OracleJob.BufferLayoutParseTask.BufferParseType](#.OracleJob.BufferLayoutParseTask.BufferParseType)
- [OracleJob.BufferLayoutParseTask.Endian](#.OracleJob.BufferLayoutParseTask.Endian)
+ - [OracleJob.CronParseTask.ClockType](#.OracleJob.CronParseTask.ClockType)
- [OracleJob.HttpTask.Method](#.OracleJob.HttpTask.Method)
- [OracleJob.JsonParseTask.AggregationMethod](#.OracleJob.JsonParseTask.AggregationMethod)
- [OracleJob.LendingRateTask.Field](#.OracleJob.LendingRateTask.Field)
@@ -179,6 +181,23 @@ This task will run the `attempt` subtasks in an effort to produce a valid numeri
+
+
+### OracleJob.CronParseTask
+return a timestamp from a crontab instruction
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| cron_pattern | [string](#string) | optional | the cron pattern to parse |
+| clock_offset | [int32](#int32) | optional | the timestamp offset to calculate the next run |
+| clock | [OracleJob.CronParseTask.ClockType](#OracleJob.CronParseTask.ClockType) | optional | |
+
+
+
+
+
+
### OracleJob.DefiKingdomsTask
@@ -695,6 +714,7 @@ Return the difference between an oracle's clock and the current timestamp at
| marinade_state_task | [OracleJob.MarinadeStateTask](#OracleJob.MarinadeStateTask) | optional | |
| solana_account_data_fetch_task | [OracleJob.SolanaAccountDataFetchTask](#OracleJob.SolanaAccountDataFetchTask) | optional | |
| buffer_layout_parse_task | [OracleJob.BufferLayoutParseTask](#OracleJob.BufferLayoutParseTask) | optional | |
+| cron_parse_task | [OracleJob.CronParseTask](#OracleJob.CronParseTask) | optional | |
@@ -724,6 +744,7 @@ Takes a twap over a set period for a certain aggregator.
| weight_by_propagation_time | [bool](#bool) | optional | Weight samples by their propagation time |
| min_samples | [uint32](#uint32) | optional | Minimum number of samples in the history to calculate a valid result |
| ending_unix_timestamp | [int32](#int32) | optional | Ending unix timestamp to collect values up to |
+| ending_unix_timestamp_task | [OracleJob.CronParseTask](#OracleJob.CronParseTask) | optional | Execute the task to get the ending unix timestamp |
@@ -838,6 +859,18 @@ Opens and maintains a websocket for light speed data retrieval.
+
+
+### OracleJob.CronParseTask.ClockType
+which type of clock to use
+
+| Name | Number | Description |
+| ---- | ------ | ----------- |
+| ORACLE | 0 | |
+| SYSCLOCK | 1 | |
+
+
+
### OracleJob.HttpTask.Method
@@ -862,6 +895,8 @@ The methods of combining a list of numerical results.
| MIN | 1 | Grab the minimum value of the results. |
| MAX | 2 | Grab the maximum value of the results. |
| SUM | 3 | Sum up all of the results. |
+| MEAN | 4 | Average all of the results. |
+| MEDIAN | 5 | Grab the median of the results. |
diff --git a/website/api/switchboard-tasks.md b/website/api/switchboard-tasks.md
index e2c11d4..7a434ae 100644
--- a/website/api/switchboard-tasks.md
+++ b/website/api/switchboard-tasks.md
@@ -266,12 +266,14 @@ response.
The methods of combining a list of numerical results.
-| Name | Number | Description |
-| ---- | ------ | -------------------------------------- |
-| NONE | 0 | |
-| MIN | 1 | Grab the minimum value of the results. |
-| MAX | 2 | Grab the maximum value of the results. |
-| SUM | 3 | Sum up all of the results. |
+| Name | Number | Description |
+| ------ | ------ | -------------------------------------- |
+| NONE | 0 | |
+| MIN | 1 | Grab the minimum value of the results. |
+| MAX | 2 | Grab the maximum value of the results. |
+| SUM | 3 | Sum up all of the results. |
+| MEAN | 4 | Average all of the results. |
+| MEDIAN | 5 | Grab the median of the results. |
### 🛠RegexExtractTask
@@ -351,6 +353,25 @@ Execute a job and store the result in a variable to reference later.
Return the difference between an oracle's clock and the current timestamp at `SYSVAR_CLOCK_PUBKEY`.
+### CronParseTask
+
+Return a timestamp from a crontab instruction.
+
+| Field | Type | Label | Description |
+| ------------ | ----------------------- | -------- | ---------------------------------------------------------------- |
+| cron_pattern | [string](#string) | optional | The cron pattern to parse |
+| clock_offset | [int32](#int32) | optional | The timestamp offset to calculate the next run |
+| clock | [ClockType](#ClockType) | optional | The type of clock to use, oracle or the solana cluster sysclock. |
+
+#### ClockType
+
+The type of clock.
+
+| Name | Number | Description |
+| -------- | ------ | ------------------------------ |
+| ORACLE | 0 | The oracles current clock. |
+| SYSCLOCK | 1 | The solana cluster's sysclock. |
+
### 🛠TpsTask
Fetch the current transactions per second.
@@ -361,13 +382,14 @@ Fetch the current transactions per second.
Takes a twap over a set period for a certain aggregator.
-| Field | Type | Label | Description |
-| -------------------------- | ----------------- | -------- | -------------------------------------------------------------------- |
-| aggregator_pubkey | [string](#string) | optional | The target aggregator for the TWAP. |
-| period | [int32](#int32) | optional | Period, in seconds, the twap should account for |
-| weight_by_propagation_time | [bool](#bool) | optional | Weight samples by their propagation time |
-| min_samples | [uint32](#uint32) | optional | Minimum number of samples in the history to calculate a valid result |
-| ending_unix_timestamp | [int32](#int32) | optional | Ending unix timestamp to collect values up to |
+| Field | Type | Label | Description |
+| -------------------------- | ------------------------------- | -------- | -------------------------------------------------------------------- |
+| aggregator_pubkey | [string](#string) | optional | The target aggregator for the TWAP. |
+| period | [int32](#int32) | optional | Period, in seconds, the twap should account for |
+| weight_by_propagation_time | [bool](#bool) | optional | Weight samples by their propagation time |
+| min_samples | [uint32](#uint32) | optional | Minimum number of samples in the history to calculate a valid result |
+| ending_unix_timestamp | [int32](#int32) | optional | Ending unix timestamp to collect values up to |
+| ending_unix_timestamp_task | [CronParseTask](#CronParseTask) | optional | Execute the task to get the ending unix timestamp |
### 🛠MaxTask
diff --git a/website/docs/developers/_library_table.mdx b/website/docs/developers/_library_table.mdx
index b122c7c..f2f4664 100644
--- a/website/docs/developers/_library_table.mdx
+++ b/website/docs/developers/_library_table.mdx
@@ -17,11 +17,12 @@ import { SerumIcon } from "/src/components/icons/SerumIcon";
Switchboard V2 on-chain
-| Library | Description |
-| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
-| switchboard-tasks | Protobuf definitions for the various supported task definitions to build job definitions from. |
-| switchboardv2-cli | A Command Line Interface (CLI) to interact with the Switchboardv2 program. |
-| switchboardv2-api | A typescript library of utility functions to interact with the Switchboardv2 program. |
-| sbv2-lite | A typescript "Lite" client to deserialize aggregator accounts. |
-| switchboardpy | A python library of utility functions to interact with the Switchboardv2 program. |
-| switchboard-v2 | A rust library of utility functions to interact with the Switchboardv2 program on-chain. |
+| Library | Description |
+| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- |
+| switchboard-tasks | Protobuf definitions for the various supported task definitions to build job definitions from. |
+| switchboardv2-cli | A Command Line Interface (CLI) to interact with the Switchboardv2 program. |
+| switchboardv2-api | A typescript library of utility functions to interact with the Switchboardv2 program. |
+| sbv2-lite | A typescript "Lite" client to deserialize aggregator accounts. |
+| sbv2-utils | Some utility functions to interact with Switchboard V2. |
+| switchboardpy | A python library of utility functions to interact with the Switchboardv2 program. |
+| switchboard-v2 | A rust library of utility functions to interact with the Switchboardv2 program on-chain. |
diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js
index 4c52df1..527226b 100644
--- a/website/docusaurus.config.js
+++ b/website/docusaurus.config.js
@@ -157,6 +157,10 @@ const config = {
label: "Typescript Lite",
to: "https://docs.switchboard.xyz/api/ts-lite",
},
+ {
+ label: "Sbv2 Utils",
+ to: "https://docs.switchboard.xyz/api/sbv2-utils",
+ },
{
label: "Python",
to: "https://docs.switchboard.xyz/api/py",
diff --git a/website/sidebarsAPI.js b/website/sidebarsAPI.js
index 67a1ed9..047d118 100644
--- a/website/sidebarsAPI.js
+++ b/website/sidebarsAPI.js
@@ -25,6 +25,11 @@ module.exports = {
label: "Typescript Lite",
href: "https://docs.switchboard.xyz/api/ts-lite/",
},
+ {
+ type: "link",
+ label: "Sbv2 Utils",
+ href: "https://docs.switchboard.xyz/api/sbv2-utils/",
+ },
{
type: "link",
label: "Python",