Skip to content

Commit 9ef4e63

Browse files
committed
Prepare contracts for deployment
1 parent 7a6f9ab commit 9ef4e63

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

contracts/IWstETH.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.27;
3+
4+
/// @title A minimal interface for the wstETH contract indended to read the
5+
/// stETH value per token value of 1 unit of wstETH.
6+
interface IWstETH {
7+
/// @notice Returns the stETH value per token value of 1 unit of wstETH.
8+
function stEthPerToken() external view returns (uint256);
9+
}

contracts/WstETHApi3ReaderProxyV1.sol

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.27;
3+
4+
import "@api3/contracts/interfaces/IApi3ReaderProxy.sol";
5+
import "./IWstETH.sol";
6+
7+
/// @title An immutable proxy contract that reads the price of wstETH directly
8+
/// from the WstETH contract on Ethereum.
9+
/// @dev This contract implements only the IApi3ReaderProxy and not the
10+
/// AggregatorV2V3Interface which is usually implemented with Api3 proxies. The
11+
/// user of this contract needs to be aware of this and only use this contract
12+
/// where the IApi3ReaderProxy interface is expected.
13+
contract WstETHApi3ReaderProxyV1 is IApi3ReaderProxy {
14+
address public constant WST_ETH =
15+
0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0;
16+
17+
constructor() {}
18+
19+
/// @inheritdoc IApi3ReaderProxy
20+
/// @dev The value returned by this function is the stETH value scaled to 18
21+
/// decimals. The timestamp returned is the current block timestamp.
22+
function read()
23+
public
24+
view
25+
override
26+
returns (int224 value, uint32 timestamp)
27+
{
28+
uint256 stEthPerToken = IWstETH(WST_ETH).stEthPerToken();
29+
30+
value = int224(int256(stEthPerToken)); // stEthPerToken value has 18 decimals.
31+
timestamp = uint32(block.timestamp);
32+
}
33+
}

scripts/deploy-morpho.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ethers } from 'ethers';
2+
3+
import { ProductApi3ReaderProxyV1__factory } from '../typechain-types';
4+
5+
const deployPriceFeedProxy = async () => {
6+
const provider = new ethers.JsonRpcProvider(process.env.PROVIDER);
7+
const signer = new ethers.Wallet(process.env.PK!, provider);
8+
const productApi3ReaderProxyV1Factory = new ProductApi3ReaderProxyV1__factory(signer);
9+
console.info('Deploying product proxy...');
10+
const tx = await productApi3ReaderProxyV1Factory.deploy(
11+
'', // TODO: Deploy WstETHApi3ReaderProxyV1.sol
12+
'0x37422cC8e1487a0452cc0D0BF75877d86c63c88A' // https://market.api3.org/ethereum/eth-usd/integrate?dappAlias=morpho-wsteth-usdc-860-lltv
13+
);
14+
const productApi3ReaderProxyV1 = await tx.waitForDeployment();
15+
console.info('Deployed ProductApi3ReaderProxyV1:', await productApi3ReaderProxyV1.getAddress());
16+
console.info('ProductApi3ReaderProxyV1.read():', await productApi3ReaderProxyV1.read());
17+
// Deployed on Base: 0x707991d5533021021cC360dF093f1B396340Ef3E
18+
};
19+
20+
deployPriceFeedProxy();
21+
22+
// NOTE: https://market.api3.org/ethereum/usdc-usd/integrate?dappAlias=morpho-wsteth-usdc-860-lltv

0 commit comments

Comments
 (0)