Skip to content

Commit 4ab64d2

Browse files
authored
feat(target_chains/fuel): use saturating sub (#2031)
* use saturating sub * update fuel version * commit release binary file * update fuel sdk version * update pnpm lock * precommit
1 parent 82b5107 commit 4ab64d2

File tree

16 files changed

+616
-281
lines changed

16 files changed

+616
-281
lines changed

apps/price_pusher/config.fuel.testnet.sample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"endpoint": "https://testnet.fuel.network/v1/graphql",
3-
"pyth-contract-address": "0xe31e04946c67fb41923f93d50ee7fc1c6c99d6e07c02860c6bea5f4a13919277",
3+
"pyth-contract-address": "0x25146735b29d4216639f7f8b1d7b921ff87a1d3051de62d6cceaacabeb33b8e7",
44
"price-service-endpoint": "https://hermes.pyth.network",
55
"private-key-file": "./mnemonic",
66
"price-config-file": "./price-config.stable.sample.yaml"

pnpm-lock.yaml

Lines changed: 577 additions & 234 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

target_chains/fuel/contracts/Forc.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[package]]
22
name = "core"
3-
source = "path+from-root-4BB20845430AF9CF"
3+
source = "path+from-root-8357A6DDC5F39D14"
44

55
[[package]]
66
name = "pyth-contract"
@@ -32,7 +32,7 @@ dependencies = ["std"]
3232

3333
[[package]]
3434
name = "std"
35-
source = "git+https://github.com/fuellabs/sway?tag=v0.63.5#31a1d6f98395f571cd3674b492d9bf4773c55f65"
35+
source = "git+https://github.com/fuellabs/sway?tag=v0.65.2#66bb430395daf5b8f7205f7b9d8d008e2e812d54"
3636
dependencies = ["core"]
3737

3838
[[package]]

target_chains/fuel/contracts/fuel-toolchain.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
channel = "latest-aarch64-apple-darwin"
33

44
[components]
5-
forc = "0.63.5"
6-
fuel-core = "0.35.0"
5+
forc = "0.65.2"
6+
fuel-core = "0.37.1"

target_chains/fuel/contracts/pyth-contract/out/release/pyth-contract-abi.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,6 @@
266266
"name": "FeesCanOnlyBePaidInTheBaseAsset",
267267
"typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d"
268268
},
269-
{
270-
"name": "FuturePriceNotAllowed",
271-
"typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d"
272-
},
273269
{
274270
"name": "GuardianSetNotFound",
275271
"typeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d"
@@ -1535,7 +1531,7 @@
15351531
{
15361532
"name": "DEPLOYER",
15371533
"concreteTypeId": "ab7cd04e05be58e3fc15d424c2c4a57f824a2a2d97d67252440a3925ebdc1335",
1538-
"offset": 132984
1534+
"offset": 133088
15391535
}
15401536
]
15411537
}
Binary file not shown.

target_chains/fuel/contracts/pyth-contract/src/main.sw

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,13 @@ fn ema_price_unsafe(price_feed_id: PriceFeedId) -> Price {
331331
fn price_no_older_than(time_period: u64, price_feed_id: PriceFeedId) -> Price {
332332
let price = price_unsafe(price_feed_id);
333333
let current_time = timestamp();
334-
require(
335-
current_time - price.publish_time <= time_period,
336-
PythError::OutdatedPrice,
337-
);
334+
// Mimicking saturating subtraction to avoid underflow
335+
let time_difference = if current_time > price.publish_time {
336+
current_time - price.publish_time
337+
} else {
338+
0
339+
};
340+
require(time_difference <= time_period, PythError::OutdatedPrice);
338341

339342
price
340343
}

target_chains/fuel/contracts/pyth-interface/src/data_structures/price.sw

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ impl PriceFeed {
175175
//convert publish_time from UNIX to TAI64
176176
publish_time += TAI64_DIFFERENCE;
177177

178-
require(
179-
publish_time <= timestamp(),
180-
PythError::FuturePriceNotAllowed,
181-
);
182-
183178
PriceFeed::new(
184179
Price::new(ema_confidence, exponent, ema_price, publish_time),
185180
price_feed_id,

target_chains/fuel/contracts/pyth-interface/src/errors.sw

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ library;
22

33
pub enum PythError {
44
FeesCanOnlyBePaidInTheBaseAsset: (),
5-
FuturePriceNotAllowed: (),
65
GuardianSetNotFound: (),
76
IncorrectMessageType: (),
87
InsufficientFee: (),

target_chains/fuel/sdk/js/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pythnetwork/pyth-fuel-js",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "Pyth Network Fuel Utils in JS",
55
"homepage": "https://pyth.network",
66
"author": {
@@ -45,6 +45,6 @@
4545
"typescript": "^5.4.5"
4646
},
4747
"dependencies": {
48-
"fuels": "^0.94.5"
48+
"fuels": "^0.96.1"
4949
}
5050
}

0 commit comments

Comments
 (0)