Skip to content
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

draft steth pricer #439

Closed
wants to merge 14 commits into from
Closed

draft steth pricer #439

wants to merge 14 commits into from

Conversation

chudnov
Copy link
Contributor

@chudnov chudnov commented Jul 26, 2021

Task: STETH pricer

High Level Description

Specific Changes

  • Created a new pricer, STETHPricer
  • The Pricer uses the stETH's getPooledEthByShares function to get the price of the stETH token in USD. [reference].
  • The logic is similar to CompoundPricer, where it requires the USD price of the underlying to be committed beforehand.
  • Unit tests for STETHPricer

Code

  • Unit test 100% coverage
  • Does your code follow the naming and code documentation guidelines?

Documentation

  • Is your code up to date with the spec?
  • Have you added your tests to the testing doc?

@antoncoding antoncoding removed their request for review July 29, 2021 16:01
@haythemsellami
Copy link
Member

Sorry for all additional files changes, as needed to lint testing files to CircleCI to pass.

@haythemsellami haythemsellami added the pricer Oracle pricer contract label Aug 4, 2021
// SPDX-License-Identifier: MIT
pragma solidity 0.6.10;

interface STETHInterface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use the wstETH interface here, which doesn't include getPooledEthByShares.


import {ERC20Upgradeable} from "../packages/oz/upgradeability/ERC20Upgradeable.sol";

contract MockSTETHToken is ERC20Upgradeable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a mock for stETH, but we need a wstETH token, which has doesn't have getPooledEthByShares.

/**
* @notice A Pricer contract for a Yearn yToken
*/
contract STETHPricer is OpynPricerInterface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably call it WSTETHPricer as it is pricing wstETH collateral.

* @return price of 1e8 stETH in USD, scaled by 1e8
*/
function _underlyingPriceToSTETHPrice(uint256 _underlyingPrice) private view returns (uint256) {
uint256 pricePerShare = stETH.getPooledEthByShares(1 ether);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we can use stEthPerToken() from the wstETH contract

https://docs.lido.fi/contracts/wsteth

* @param _oracle Opyn Oracle contract address
*/
constructor(
address _stETH,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throughout, I think should change to wstETH to make it clear we are collateralizing with wstETH.

MockPricerInstance,
MockOracleInstance,
MockERC20Instance,
MockSTETHTokenInstance,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests need to be updated w new mocks, interface, functions, etc

@haythemsellami
Copy link
Member

Closing this in favor for #440

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pricer Oracle pricer contract
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants