1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity 0.8.21 ;
3
+
4
+ import "forge-std/Script.sol " ;
5
+ import "forge-std/console.sol " ;
6
+ import {MorphoPythOracleFactory} from "../src/morpho-pyth/MorphoPythOracleFactory.sol " ;
7
+ import {IMorphoPythOracle} from "../src/morpho-pyth/interfaces/IMorphoPythOracle.sol " ;
8
+ import {IERC4626 } from "../src/interfaces/IERC4626.sol " ;
9
+
10
+ contract MorphoPythOracleDeploy is Script {
11
+ function run () public {
12
+ uint256 deployerPrivateKey = vm.envUint ("PRIVATE_KEY " );
13
+ vm.startBroadcast (deployerPrivateKey);
14
+
15
+ // Get the Pyth contract address for your chain from:
16
+ // https://docs.pyth.network/price-feeds/contract-addresses/evm
17
+ address pythPriceFeedsContract = vm.envAddress ("PYTH_ADDRESS " );
18
+
19
+ // Get the address of the base vault
20
+ address baseVault = vm.envAddress ("BASE_VAULT " );
21
+ // Get the base vault conversion sample
22
+ uint256 baseVaultConversionSample = vm.envUint ("BASE_VAULT_CONVERSION_SAMPLE " );
23
+
24
+ // Get the base Price Feeds from
25
+ // https://www.pyth.network/developers/price-feed-ids
26
+ bytes32 baseFeed1 = vm.envBytes32 ("BASE_PRICE_FEED_1 " );
27
+ bytes32 baseFeed2 = vm.envBytes32 ("BASE_PRICE_FEED_2 " );
28
+ uint256 baseTokenDecimals = vm.envUint ("BASE_TOKEN_DECIMALS " );
29
+
30
+ // Get the address of the quote vault
31
+ address quoteVault = vm.envAddress ("QUOTE_VAULT " );
32
+ // Get the quote vault conversion sample
33
+ uint256 quoteVaultConversionSample = vm.envUint ("QUOTE_VAULT_CONVERSION_SAMPLE " );
34
+
35
+ // Get the quote Price Feeds from
36
+ // https://www.pyth.network/developers/price-feed-ids
37
+ bytes32 quoteFeed1 = vm.envBytes32 ("QUOTE_PRICE_FEED_1 " );
38
+ bytes32 quoteFeed2 = vm.envBytes32 ("QUOTE_PRICE_FEED_2 " );
39
+ uint256 quoteTokenDecimals = vm.envUint ("QUOTE_TOKEN_DECIMALS " );
40
+
41
+ // Set the price feed max age in seconds
42
+ uint256 priceFeedMaxAge = vm.envUint ("PRICE_FEED_MAX_AGE " );
43
+
44
+ // Get the salt for the oracle deployment
45
+ bytes32 salt = vm.envBytes32 ("SALT " );
46
+
47
+ // Get the Factory address on your chain
48
+ address factoryAddress = vm.envAddress ("MORPHO_PYTH_ORACLE_FACTORY " );
49
+
50
+ MorphoPythOracleFactory factory = MorphoPythOracleFactory (factoryAddress);
51
+ IMorphoPythOracle oracle = factory.createMorphoPythOracle (
52
+ pythPriceFeedsContract,
53
+ IERC4626 (baseVault),
54
+ baseVaultConversionSample,
55
+ baseFeed1,
56
+ baseFeed2,
57
+ baseTokenDecimals,
58
+ IERC4626 (quoteVault),
59
+ quoteVaultConversionSample,
60
+ quoteFeed1,
61
+ quoteFeed2,
62
+ quoteTokenDecimals,
63
+ priceFeedMaxAge,
64
+ salt
65
+ );
66
+
67
+ console.log ("Oracle deployed at: " , address (oracle));
68
+
69
+ vm.stopBroadcast ();
70
+ }
71
+ }
0 commit comments