|
| 1 | +import { BigNumber } from "ethers"; |
| 2 | +import { parseUnits } from "ethers/lib/utils"; |
1 | 3 | import { ethers } from "hardhat";
|
2 | 4 | import { DeployFunction } from "hardhat-deploy/dist/types";
|
3 | 5 | import { HardhatRuntimeEnvironment } from "hardhat/types";
|
4 | 6 |
|
5 |
| -import { ADDRESSES, addr0000, assets } from "../helpers/deploymentConfig"; |
| 7 | +import { |
| 8 | + ADDRESSES, |
| 9 | + DAYS_30, |
| 10 | + addr0000, |
| 11 | + assets, |
| 12 | + getSnapshotGap, |
| 13 | + increaseExchangeRateByPercentage, |
| 14 | +} from "../helpers/deploymentConfig"; |
6 | 15 |
|
7 |
| -const func: DeployFunction = async ({ |
8 |
| - getNamedAccounts, |
9 |
| - deployments, |
10 |
| - network, |
11 |
| - artifacts, |
12 |
| -}: HardhatRuntimeEnvironment) => { |
| 16 | +const func: DeployFunction = async ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) => { |
13 | 17 | const { deploy } = deployments;
|
14 | 18 | const { deployer } = await getNamedAccounts();
|
15 | 19 |
|
16 |
| - console.log(`Deployer ${deployer}`); |
17 |
| - |
18 |
| - const proxyOwnerAddress = network.live ? ADDRESSES[network.name].timelock : deployer; |
19 |
| - |
20 |
| - const { stETHAddress, wstETHAddress } = ADDRESSES[network.name]; |
| 20 | + const { stETHAddress, wstETHAddress, acm } = ADDRESSES[network.name]; |
21 | 21 | const WETHAsset = assets[network.name].find(asset => asset.token === "WETH");
|
22 | 22 | const WETHAddress = WETHAsset?.address ?? addr0000;
|
23 | 23 |
|
24 |
| - const defaultProxyAdmin = await artifacts.readArtifact( |
25 |
| - "hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol:ProxyAdmin", |
26 |
| - ); |
27 |
| - |
28 | 24 | const oracle = await ethers.getContract("ResilientOracle");
|
29 | 25 |
|
30 | 26 | // Equivalence and NonEquivalence is related to if the oracle will
|
31 | 27 | // assume 1/1 price ration between stETH/ETH or
|
32 | 28 | // will get stETH/USD price from secondary market
|
33 | 29 |
|
34 |
| - await deploy("WstETHOracle_Equivalence", { |
35 |
| - contract: "WstETHOracle", |
36 |
| - from: deployer, |
37 |
| - log: true, |
38 |
| - deterministicDeployment: false, |
39 |
| - args: [wstETHAddress, WETHAddress, stETHAddress, oracle.address, true], |
40 |
| - proxy: { |
41 |
| - owner: proxyOwnerAddress, |
42 |
| - proxyContract: "OptimizedTransparentUpgradeableProxy", |
43 |
| - viaAdminContract: { |
44 |
| - name: "DefaultProxyAdmin", |
45 |
| - artifact: defaultProxyAdmin, |
46 |
| - }, |
47 |
| - }, |
48 |
| - }); |
| 30 | + const wstETH_ANNUAL_GROWTH_RATE = ethers.utils.parseUnits("0.067", 18); // 6.7% |
| 31 | + const block = await ethers.provider.getBlock("latest"); |
| 32 | + const stETHContract = await ethers.getContractAt("IStETH", stETHAddress); |
| 33 | + const exchangeRate = await stETHContract.getPooledEthByShares(parseUnits("1", 18)); |
| 34 | + const snapshotGap = BigNumber.from("55"); // 0.55% |
| 35 | + |
| 36 | + if (network.name === "ethereum") { |
| 37 | + await deploy("WstETHOracle_Equivalence", { |
| 38 | + contract: "WstETHOracleV2", |
| 39 | + from: deployer, |
| 40 | + log: true, |
| 41 | + deterministicDeployment: false, |
| 42 | + args: [ |
| 43 | + stETHAddress, |
| 44 | + wstETHAddress, |
| 45 | + WETHAddress, |
| 46 | + oracle.address, |
| 47 | + wstETH_ANNUAL_GROWTH_RATE, |
| 48 | + DAYS_30, |
| 49 | + increaseExchangeRateByPercentage(exchangeRate, snapshotGap), |
| 50 | + block.timestamp, |
| 51 | + acm, |
| 52 | + getSnapshotGap(exchangeRate, snapshotGap.toNumber()), |
| 53 | + ], |
| 54 | + }); |
49 | 55 |
|
50 |
| - await deploy("WstETHOracle_NonEquivalence", { |
51 |
| - contract: "WstETHOracle", |
52 |
| - from: deployer, |
53 |
| - log: true, |
54 |
| - deterministicDeployment: false, |
55 |
| - args: [wstETHAddress, WETHAddress, stETHAddress, oracle.address, false], |
56 |
| - proxy: { |
57 |
| - owner: proxyOwnerAddress, |
58 |
| - proxyContract: "OptimizedTransparentUpgradeableProxy", |
59 |
| - viaAdminContract: { |
60 |
| - name: "DefaultProxyAdmin", |
61 |
| - artifact: defaultProxyAdmin, |
62 |
| - }, |
63 |
| - }, |
64 |
| - }); |
| 56 | + await deploy("WstETHOracle_NonEquivalence", { |
| 57 | + contract: "WstETHOracleV2", |
| 58 | + from: deployer, |
| 59 | + log: true, |
| 60 | + deterministicDeployment: false, |
| 61 | + args: [ |
| 62 | + stETHAddress, |
| 63 | + wstETHAddress, |
| 64 | + stETHAddress, |
| 65 | + oracle.address, |
| 66 | + wstETH_ANNUAL_GROWTH_RATE, |
| 67 | + DAYS_30, |
| 68 | + increaseExchangeRateByPercentage(exchangeRate, snapshotGap), |
| 69 | + block.timestamp, |
| 70 | + acm, |
| 71 | + getSnapshotGap(exchangeRate, snapshotGap.toNumber()), |
| 72 | + ], |
| 73 | + }); |
| 74 | + } else { |
| 75 | + await deploy("WstETHOracle", { |
| 76 | + contract: "WstETHOracleV2", |
| 77 | + from: deployer, |
| 78 | + log: true, |
| 79 | + deterministicDeployment: false, |
| 80 | + args: [ |
| 81 | + stETHAddress, |
| 82 | + wstETHAddress, |
| 83 | + WETHAddress, |
| 84 | + oracle.address, |
| 85 | + wstETH_ANNUAL_GROWTH_RATE, |
| 86 | + DAYS_30, |
| 87 | + increaseExchangeRateByPercentage(exchangeRate, snapshotGap), |
| 88 | + block.timestamp, |
| 89 | + acm, |
| 90 | + getSnapshotGap(exchangeRate, snapshotGap.toNumber()), |
| 91 | + ], |
| 92 | + }); |
| 93 | + } |
65 | 94 | };
|
66 | 95 |
|
67 | 96 | export default func;
|
|
0 commit comments