Skip to content

Commit 5f6b46b

Browse files
authored
Merge pull request #6 from pyth-network/chore(script)-add-read-script
chore(scripts) Add price reading script
2 parents 2689932 + eecae96 commit 5f6b46b

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Compiler files
22
cache/
33
out/
4+
.zkout/
45

56
# Ignores development broadcast logs
67
!/broadcast
78
/broadcast/*/31337/
89
/broadcast/**/dry-run/
910
broadcast/
11+
lib/
1012

1113
# Docs
1214
docs/

scripts/MorphoPythOracleDeploy.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ contract MorphoPythOracleDeploy is Script {
6868

6969
vm.stopBroadcast();
7070
}
71-
}
71+
}

scripts/MorphoPythOracleFactoryDeploy.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ contract MorphoPythOracleFactoryDeploy is Script {
1515

1616
vm.stopBroadcast();
1717
}
18-
}
18+
}

scripts/MorphoPythOracleRead.s.sol

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity 0.8.21;
3+
4+
import "forge-std/Script.sol";
5+
import {console} from "forge-std/console.sol";
6+
import {IMorphoPythOracle} from "../src/morpho-pyth/interfaces/IMorphoPythOracle.sol";
7+
import {IERC4626} from "../src/interfaces/IERC4626.sol";
8+
9+
contract MorphoPythOracleRead is Script {
10+
function run() public {
11+
// Use an RPC fork so external calls hit the real chain state
12+
string memory rpcUrl = vm.envString("RPC");
13+
vm.createSelectFork(rpcUrl);
14+
15+
// Get the Factory address on your chain
16+
address oracleAddress = vm.envAddress("ORACLE_ADDRESS");
17+
console.log("Oracle address:", oracleAddress);
18+
19+
IMorphoPythOracle oracle = IMorphoPythOracle(oracleAddress);
20+
console.log("Pyth address:", address(oracle.pyth()));
21+
22+
console2.log("Max age:", oracle.PRICE_FEED_MAX_AGE());
23+
24+
console2.log("Price:", oracle.price());
25+
}
26+
}

0 commit comments

Comments
 (0)