Skip to content

Commit 44de333

Browse files
committed
added scripts
1 parent 3c2b725 commit 44de333

File tree

5 files changed

+111
-4
lines changed

5 files changed

+111
-4
lines changed

.env.example

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
PYTH_ADDRESS=
2+
3+
BASE_VAULT=
4+
BASE_VAULT_CONVERSION_SAMPLE=
5+
6+
BASE_PRICE_FEED_1=
7+
BASE_PRICE_FEED_2=
8+
BASE_TOKEN_DECIMALS=
9+
10+
QUOTE_VAULT=
11+
QUOTE_VAULT_CONVERSION_SAMPLE=
12+
13+
QUOTE_PRICE_FEED_1=
14+
QUOTE_PRICE_FEED_2=
15+
QUOTE_TOKEN_DECIMALS=
16+
17+
PRICE_FEED_MAX_AGE=
18+
SALT=
19+
20+
MORPHO_PYTH_ORACLE_FACTORY=

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ out/
66
!/broadcast
77
/broadcast/*/31337/
88
/broadcast/**/dry-run/
9+
broadcast/
910

1011
# Docs
1112
docs/

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ To do so, call the `createMorphoPythOracle` function with the following paramete
3737
E.g: for a MetaMorpho WETH vault, as `baseVault`, the `baseTokenDecimals` is 18 as WETH has 18 decimals.
3838

3939
### Addresses
40+
4041
TODO:
4142
The address on Ethereum of this factory is [](https://etherscan.io/address/#code).
4243

@@ -72,7 +73,3 @@ npm install @pythnetwork/pyth-sdk-solidity
7273
```
7374

7475
Run test: `forge test`
75-
76-
## Audits
77-
78-
All audits are stored in the [audits](./audits/)' folder.

scripts/MorphoPythOracleDeploy.s.sol

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
8+
contract MorphoPythOracleFactoryDeploy is Script {
9+
function run() public {
10+
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
11+
vm.startBroadcast(deployerPrivateKey);
12+
13+
MorphoPythOracleFactory factory = new MorphoPythOracleFactory();
14+
console.log("Factory deployed at:", address(factory));
15+
16+
vm.stopBroadcast();
17+
}
18+
}

0 commit comments

Comments
 (0)