diff --git a/lazer/contracts/sui/sources/channel.move b/lazer/contracts/sui/sources/channel.move
index 86f332b9a6..0f5e4ca50b 100644
--- a/lazer/contracts/sui/sources/channel.move
+++ b/lazer/contracts/sui/sources/channel.move
@@ -1,17 +1,14 @@
module pyth_lazer::channel;
+// Error codes for channel parsing
+const EInvalidChannel: u64 = 1;
+
public enum Channel has copy, drop {
- Invalid,
RealTime,
FixedRate50ms,
FixedRate200ms,
}
-/// Create a new Invalid channel
-public fun new_invalid(): Channel {
- Channel::Invalid
-}
-
/// Create a new RealTime channel
public fun new_real_time(): Channel {
Channel::RealTime
@@ -27,11 +24,16 @@ public fun new_fixed_rate_200ms(): Channel {
Channel::FixedRate200ms
}
-/// Check if the channel is Invalid
-public fun is_invalid(channel: &Channel): bool {
- match (channel) {
- Channel::Invalid => true,
- _ => false,
+/// Parse channel from a channel value byte
+public fun from_u8(channel_value: u8): Channel {
+ if (channel_value == 1) {
+ new_real_time()
+ } else if (channel_value == 2) {
+ new_fixed_rate_50ms()
+ } else if (channel_value == 3) {
+ new_fixed_rate_200ms()
+ } else {
+ abort EInvalidChannel
}
}
diff --git a/lazer/contracts/sui/sources/feed.move b/lazer/contracts/sui/sources/feed.move
index 894f9faa94..a937e62f4b 100644
--- a/lazer/contracts/sui/sources/feed.move
+++ b/lazer/contracts/sui/sources/feed.move
@@ -1,7 +1,11 @@
module pyth_lazer::feed;
-use pyth_lazer::i16::I16;
-use pyth_lazer::i64::I64;
+use pyth_lazer::i16::{Self, I16};
+use pyth_lazer::i64::{Self, I64};
+use sui::bcs;
+
+// Error codes for feed parsing
+const EInvalidProperty: u64 = 2;
/// The feed struct is based on the Lazer rust protocol definition defined here:
/// https://github.com/pyth-network/pyth-crosschain/blob/main/lazer/sdk/rust/protocol/src/payload.rs
@@ -56,7 +60,7 @@ public(package) fun new(
confidence,
funding_rate,
funding_timestamp,
- funding_rate_interval
+ funding_rate_interval,
}
}
@@ -156,6 +160,115 @@ public(package) fun set_funding_timestamp(feed: &mut Feed, funding_timestamp: Op
}
/// Set the funding rate interval
-public(package) fun set_funding_rate_interval(feed: &mut Feed, funding_rate_interval: Option