Skip to content

Add morpho oracle wrapper (yvvbUSDT/USDC, yvvbUSDC/USDT), ERC-4626 oracle wrapper (yvvbETH), and oracle wrapper aggregator (yvvbUSDT/USD, yvvbUSDC/USD)#4

Draft
PMCaz wants to merge 25 commits intomainfrom
phong/morpho_oracle_wrapper
Draft

Add morpho oracle wrapper (yvvbUSDT/USDC, yvvbUSDC/USDT), ERC-4626 oracle wrapper (yvvbETH), and oracle wrapper aggregator (yvvbUSDT/USD, yvvbUSDC/USD)#4
PMCaz wants to merge 25 commits intomainfrom
phong/morpho_oracle_wrapper

Conversation

@PMCaz
Copy link
Contributor

@PMCaz PMCaz commented Sep 11, 2025

No description provided.

Git-on-my-level and others added 19 commits September 2, 2025 15:08
This commit restores full API3 oracle functionality that was previously removed,
enabling proper oracle configuration for frxUSD and sfrxUSD assets on mainnet.

Changes:
- Restored 15 API3 oracle files from sonic-solidity-contracts
  - Core wrapper contracts (API3Wrapper, API3WrapperWithThresholding, etc.)
  - Interface contracts and mock implementations for testing
  - Test files for API3 oracle functionality
  - Deployment scripts for ETH and USD ecosystems
- Updated configuration files to support API3 oracles
  - Added API3 oracle asset interfaces to config/types.ts
  - Configured frxUSD/USD and sfrxUSD/frxUSD to use API3 oracles
  - Set correct mainnet addresses for frxUSD and sfrxUSD tokens
  - Added proper API3 proxy addresses for mainnet feeds
- Updated deployment and test infrastructure
  - Added API3 mock oracle deployment for local testing
  - Extended test fixtures to support API3 oracle testing
  - Fixed deployment scripts to use correct ETH/USD constants
- Added API3 constants and deploy IDs
- Updated oracle price display and deployment scripts

Mainnet Configuration:
- frxUSD: 0xFB55A212Dd6187bc4B088a79F7ab9d1aeA86E50e
  - API3 feed: 0x4Dc7AAd0DfA29565469172dcaAc33cEd6FFF56B6 (frxUSD/USD)
- sfrxUSD: 0xBA2F8EA0A9e790ffC982F7241bEc17af949C71b3
  - API3 feeds: 0x0F546720261f447A8810A466269BCE6A66Cd1326 (sfrxUSD/frxUSD)
                0x4Dc7AAd0DfA29565469172dcaAc33cEd6FFF56B6 (frxUSD/USD)

All tests passing, deployment successful, and linting clean.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
@PMCaz
Copy link
Contributor Author

PMCaz commented Sep 11, 2025

Deployed MorphoOracleWrappers for yvvbUSDT/USDC and yvvbUSDC/USDT

Found 2 different quote assets for Morpho oracles

Deploying USDT-denominated Morpho oracle wrapper...
  Quote asset: 0x2DCa96907fde857dd3D816880A0df407eeB2D2F2 (USDT)
  Feeds to configure: 1
Deployed USDT-denominated Morpho wrapper at 0xb3A1a12904259A766cA8fe361215E9c64ddEeB3d
  ✅ Set oracle for yvvbUSDC to 0x6d736e00AcD96032d8151b9989E61b5cF090c98c
    🔍 Verifying price conversion accuracy for yvvbUSDC...
    📊 Raw Morpho Feed Price: 1000188463494749815297978662192251117 (1e36 scale)
    🔄 Converted Raw Price: 1000188463494749815297978662192251117 (base currency units)
    📈 Normalized Raw Price: 1.00018846 USDT
    📈 Wrapper Price:       1.00018846 USDT
    📊 Price Difference: 0.00000000 USDT (0.000000%)
    ✅ Price conversion check PASSED: Difference 0.000000% (<0.1% tolerance)
Sanity check passed for yvvbUSDC/USDT: Price 1.000188 USDT (range: [0.8, 1.5])

Deploying USDC-denominated Morpho oracle wrapper...
  Quote asset: 0x203A662b0BD271A6ed5a60EdFbd04bFce608FD36 (USDC)
  Feeds to configure: 1
Deployed USDC-denominated Morpho wrapper at 0x66c1Cb78DA18C3b6cF463421Eefe3757e3aBAa1c
  ✅ Set oracle for yvvbUSDT to 0xD978CE03d8BB0eb3f09cB2a469DbbC25DB42F3Ae
    🔍 Verifying price conversion accuracy for yvvbUSDT...
    📊 Raw Morpho Feed Price: 1001294801702396343076907935434452055 (1e36 scale)
    🔄 Converted Raw Price: 1001294801702396343076907935434452055 (base currency units)
    📈 Normalized Raw Price: 1.00129480 USDC
    📈 Wrapper Price:       1.00129480 USDC
    📊 Price Difference: 0.00000000 USDC (0.000000%)
    ✅ Price conversion check PASSED: Difference 0.000000% (<0.1% tolerance)
Sanity check passed for yvvbUSDT/USDC: Price 1.001295 USDC (range: [0.8, 1.5])
🔮 11_yvvbUSDC_yvvbUSDT_yyvbETH_oracles/01_deploy_morpho_wrapper.ts: ✅

@PMCaz
Copy link
Contributor Author

PMCaz commented Sep 11, 2025

Deployed ERC4626OracleWrapper for yvvbETH/ETH

 yarn hardhat deploy --network katana_mainnet --tags yvvbETH
WARNING: You are currently using Node.js v23.3.0, which is not supported by Hardhat. This can lead to unexpected behavior. See https://hardhat.org/nodejs-versions


Nothing to compile
No need to generate any newer typings.
(node:48579) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Found 1 ERC4626 vaults to deploy individual oracle wrappers for

Deploying ERC4626OracleWrapper for yvvbETH...
deploying "ERC4626OracleWrapper_yvvbETH_ETH" (tx: 0x9e99854cde671b42650f8d04cd856bfe088e1530c9d125abc6f72e9f68e40d06)...: deployed at 0x5Ac510Bc4b77d4CEFe25D57b6e5733E57dce3b0E with 1111986 gas
  Deployed at 0x5Ac510Bc4b77d4CEFe25D57b6e5733E57dce3b0E
  Base currency: 0xEE7D8BCFb72bC1880D0Cf19822eB0A2e6577aB62 (WETH)
  Base currency unit: 1000000000000000000
  ✅ Added vault yvvbETH (0xE007CA01894c863d7898045ed5A3B4Abf0b18f37)
    - Min share supply: 10000000000000000000
    - Underlying asset: 0xEE7D8BCFb72bC1880D0Cf19822eB0A2e6577aB62
    - ✅ Sanity check passed: 1.000826 ETH per vault share
🔮 11_yvvbUSDC_yvvbUSDT_yyvbETH_oracles/03_deploy_eth_erc4626_wrapper.ts: ✅

Current quote matched with Yearn.

Screenshot 2025-09-11 at 21 57 41

Copy link
Contributor

@Git-on-my-level Git-on-my-level left a comment

Choose a reason for hiding this comment

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

There are some significant safety concerns that should be addressed before usage

},
chainlinkCompositeAggregator: {},
oracleWrapperAggregators: {
USDT: {
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 inconsistent with other oracle configs

The key should be the asset for which we are returning the USD price for. However in this case, this isn't for USDT/USD, but rather this is supposed to be for yvvbUSDC/USD

function getPriceInfo(address asset) public view override returns (uint256 price, bool isAlive) {
// Get price info from both wrappers
(uint256 basePrice, bool baseAlive) = BASE_WRAPPER.getPriceInfo(asset);
(uint256 quotePrice, bool quoteAlive) = QUOTE_WRAPPER.getPriceInfo(asset);
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic seems incorrect for the general case

  • Let's say we have 2 feeds we want to compose. Let's say the BASE_WRAPPER provides ETH/USDT and QUOTE_WRAPPER provides USDT/USD
  • Let's say the goal is to get a ETH/USD feed. We pass in getPriceInfo(ETH)
  • This calls BASE_WRAPPER.getPriceInfo(ETH) which returns the ETH/USDT feed -> good
  • QUOTE_WRAPPER.getPriceInfo(ETH) is undefined, it only supports getPriceInfo(USDT) in this case -> bad

The correct asset to pass into QUOTE_WRAPPER is BASE_WRAPPER.baseCurrency

mapping(address => VaultConfig) public vaultConfigs;

/// @notice Maximum allowed price deviation in basis points (5% default)
uint256 public maxDeviation = 500;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should standardize all contracts to use contracts/common/BasisPointConstants.sol

uint256 currentPrice = IERC4626(vault).convertToAssets(_baseCurrencyUnit);

// Apply bounds checking for manipulation resistance
if (config.lastValidPrice > 0 && _priceDeviatesSignificantly(currentPrice, config.lastValidPrice)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Potential deadlock scenario:

  • Vault price stays fixed for a long period of time (e.g. Trevee hack)
  • Vault price suddenly jumps up due to fund recovery
  • Vault always returns old stale price marked as fresh

Base automatically changed from dz/mainnet to main September 18, 2025 03:44
@Git-on-my-level Git-on-my-level marked this pull request as draft October 9, 2025 10:13
@Git-on-my-level
Copy link
Contributor

Deferring ERC4626 integrations due to risk and lack of real yield and lack of harvest mechanism for KAT tokens in Yearn vaults

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants