-
Notifications
You must be signed in to change notification settings - Fork 0
Prepare contracts for deployment #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.27; | ||
|
||
import "@api3/contracts/interfaces/IApi3ReaderProxy.sol"; | ||
import "./interfaces/IWstETH.sol"; | ||
|
||
/// @title An immutable proxy contract that reads the stETH per wstETH ratio | ||
/// directly from the WstETH contract on Ethereum. | ||
/// @dev This contract implements only the IApi3ReaderProxy interface and not the | ||
/// AggregatorV2V3Interface which is usually implemented by Api3 proxies. The | ||
/// user of this contract needs to be aware of this limitation and only use this | ||
/// contract where the IApi3ReaderProxy interface is expected. | ||
contract WstETHApi3ReaderProxyV1 is IApi3ReaderProxy { | ||
/// @notice The address of the wstETH contract on Ethereum mainnet. | ||
address public constant WST_ETH = | ||
0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0; | ||
Siegrift marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// @inheritdoc IApi3ReaderProxy | ||
/// @dev Returns the stETH/wstETH exchange rate with 18 decimals precision. | ||
/// The timestamp returned is the current block timestamp. | ||
function read() | ||
public | ||
view | ||
override | ||
returns (int224 value, uint32 timestamp) | ||
{ | ||
uint256 stEthPerToken = IWstETH(WST_ETH).stEthPerToken(); | ||
|
||
value = int224(int256(stEthPerToken)); // stEthPerToken value has 18 decimals. | ||
timestamp = uint32(block.timestamp); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.27; | ||
|
||
/// @title A minimal interface for the wstETH contract on Ethereum | ||
/// @dev This interface only includes the stEthPerToken function needed to read | ||
/// the exchange rate between stETH and wstETH. | ||
interface IWstETH { | ||
/// @notice Returns the amount of stETH that corresponds to 1 wstETH | ||
/// @return The stETH/wstETH exchange rate with 18 decimals precision | ||
function stEthPerToken() external view returns (uint256); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ethers } from 'ethers'; | ||
|
||
import { ProductApi3ReaderProxyV1__factory } from '../typechain-types'; | ||
|
||
const deployPriceFeedProxy = async () => { | ||
const provider = new ethers.JsonRpcProvider(process.env.PROVIDER); | ||
const signer = new ethers.Wallet(process.env.PK!, provider); | ||
const productApi3ReaderProxyV1Factory = new ProductApi3ReaderProxyV1__factory(signer); | ||
console.info('Deploying product proxy...'); | ||
const tx = await productApi3ReaderProxyV1Factory.deploy( | ||
'', // TODO: Deploy WstETHApi3ReaderProxyV1.sol | ||
'0x37422cC8e1487a0452cc0D0BF75877d86c63c88A' // https://market.api3.org/ethereum/eth-usd/integrate?dappAlias=morpho-wsteth-usdc-860-lltv | ||
); | ||
const productApi3ReaderProxyV1 = await tx.waitForDeployment(); | ||
console.info('Deployed ProductApi3ReaderProxyV1:', await productApi3ReaderProxyV1.getAddress()); | ||
console.info('ProductApi3ReaderProxyV1.read():', await productApi3ReaderProxyV1.read()); | ||
// Deployed on Base: 0x707991d5533021021cC360dF093f1B396340Ef3E | ||
}; | ||
|
||
deployPriceFeedProxy(); | ||
|
||
// NOTE: https://market.api3.org/ethereum/usdc-usd/integrate?dappAlias=morpho-wsteth-usdc-860-lltv |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to deploy and verify this contract on etherscan. What is the best way to do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current hardhat version uses ignition plugin for deploying contract but I've had some issues with it in the past like trying to get the deployment block for a contract, etc. So on the other repos we usually just rely on hardhat-deploy plugin to handle deployments via deployment scripts. For verifying the contracts we can use hardhat-verify plugin and run it in a deployment script like @api3/contracts does it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's do the HH deploy plugin.
I don't think we need the verify plugin in the repo, but I'll need this for the deployment. Let's quickly sync on that on Slack.