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

merge #862

Merged
merged 4 commits into from
Dec 17, 2024
Merged

merge #862

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/chains/src/base/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const sUSDz = "0xe31eE12bDFDD0573D634124611e85338e2cBF0cF";
export const fBOMB = "0x74ccbe53F77b08632ce0CB91D3A545bF6B8E0979";
export const KLIMA = "0xDCEFd8C8fCc492630B943ABcaB3429F12Ea9Fea2";
export const uXRP = "0x2615a94df961278DcbC41Fb0a54fEc5f10a693aE";
export const ionicUSDC = "0x19aAB5A4C1803a5Cb82C94134C29bd59FF50D440";
export const ionicWETH = "0x9aB2d181E4b87ba57D5eD564D3eF652C4E710707";

export const assets: SupportedAsset[] = [
{
Expand Down Expand Up @@ -413,6 +415,28 @@ export const assets: SupportedAsset[] = [
initialBorrowCap: parseEther(String(245_000)).toString(),
initialSupplyCap: parseEther(String(200_000)).toString(),
initialCf: "0.65"
},
{
symbol: assetSymbols.ionicUSDC,
underlying: ionicUSDC,
name: "Ionic Ecosystem USDC",
decimals: 18,
oracle: OracleTypes.ERC4626Oracle,
extraDocs: defaultDocs("https://basescan.org", ionicUSDC),
initialSupplyCap: parseEther(String(10_000_000)).toString(),
initialBorrowCap: "1",
initialCf: "0.80"
},
{
symbol: assetSymbols.ionicWETH,
underlying: ionicWETH,
name: "Ionic Ecosystem WETH",
decimals: 18,
oracle: OracleTypes.ERC4626Oracle,
extraDocs: defaultDocs("https://basescan.org", ionicWETH),
initialSupplyCap: parseEther(String(2_000)).toString(),
initialBorrowCap: "1",
initialCf: "0.80"
}
// DO NOT ADD TO MARKET UNLESS PROPER ORACLE IS DEPLOYED
// {
Expand Down
8 changes: 8 additions & 0 deletions packages/chains/src/fraxtal/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const FRAX = "0xfc00000000000000000000000000000000000001";
export const sFRAX = "0xfc00000000000000000000000000000000000008";
export const frxBTC = "0xfc00000000000000000000000000000000000007";
export const insfrxETH = "0xE162075a1C0Ac7e985253972bEcA5e83Da3BBaa4";
export const ION = "0x5BD5c0cB9E4404C63526433BcBd6d133C1d73ffE";

export const assets: SupportedAsset[] = [
{
Expand Down Expand Up @@ -132,6 +133,13 @@ export const assets: SupportedAsset[] = [
initialSupplyCap: parseEther(String(1_500_000)).toString(),
initialBorrowCap: parseEther(String(1_200_000)).toString(),
initialCf: "0.85"
},
{
symbol: assetSymbols.ION,
underlying: ION,
name: "Ion",
decimals: 18,
oracle: OracleTypes.VelodromePriceOracle
}
];

Expand Down
70 changes: 70 additions & 0 deletions packages/contracts/chainDeploy/helpers/oracles/velodromeFraxtal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { prepareAndLogTransaction } from "../logging";
import { DeployResult } from "hardhat-deploy/types";
import { Address, Hex } from "viem";

import { addUnderlyingsToMpo } from "./utils";
import { underlying } from "../utils";
import { AerodromeDeployFnParams } from "../../types";

export const deployVelodromeOracleFraxtal = async ({
viem,
getNamedAccounts,
deployments,
pricesContract,
assets
}: AerodromeDeployFnParams): Promise<{ apo: DeployResult }> => {
const { deployer } = await getNamedAccounts();
const publicClient = await viem.getPublicClient();
let tx: Hex;

//// Velodrome Oracle
const apo = await deployments.deploy("VelodromePriceOracleFraxtal", {
from: deployer,
args: [pricesContract],
log: true,
waitConfirmations: 1
});
if (apo.transactionHash) await publicClient.waitForTransactionReceipt({ hash: apo.transactionHash as Address });
console.log("VelodromePriceOracleFraxtal: ", apo.address);

const velodrome = await viem.getContractAt(
"VelodromePriceOracleFraxtal",
(await deployments.get("VelodromePriceOracleFraxtal")).address as Address
);

const underlyings = assets.map((c) => underlying(assets, c.symbol));

const mpo = await viem.getContractAt(
"MasterPriceOracle",
(await deployments.get("MasterPriceOracle")).address as Address
);
console.log("underlyings: ", underlyings);
await addUnderlyingsToMpo(mpo as any, underlyings, velodrome.address, deployer, publicClient);

const addressesProvider = await viem.getContractAt(
"AddressesProvider",
(await deployments.get("AddressesProvider")).address as Address
);
const velodromeAddress = await addressesProvider.read.getAddress(["VelodromePriceOracleFraxtal"]);
if (velodromeAddress !== velodrome.address) {
if (((await addressesProvider.read.owner()) as Address).toLowerCase() === deployer.toLowerCase()) {
tx = await addressesProvider.write.setAddress(["VelodromePriceOracleFraxtal", velodrome.address]);
await publicClient.waitForTransactionReceipt({ hash: tx });
console.log(`setAddress VelodromePriceOracleFraxtal at ${tx}`);
} else {
await prepareAndLogTransaction({
contractInstance: addressesProvider,
functionName: "setAddress",
args: ["VelodromePriceOracleFraxtal", velodrome.address],
description: "Set VelodromePriceOracleFraxtal address on AddressProvider",
inputs: [
{ internalType: "string", name: "id", type: "string" },
{ internalType: "address", name: "newAddress", type: "address" }
]
});
console.log("Logged Transaction to setAddress VelodromePriceOracleFraxtal on AddressProvider");
}
}

return { apo };
};
12 changes: 11 additions & 1 deletion packages/contracts/chainDeploy/mainnets/fraxtal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fraxtal } from "@ionicprotocol/chains";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Address, zeroAddress, zeroHash } from "viem";
import { ChainlinkSpecificParams, OracleTypes } from "../types";
import { deployApi3Oracle } from "../helpers/oracles/api3";
import { deployVelodromeOracleFraxtal } from "../helpers/oracles/velodromeFraxtal";

const assets = fraxtal.assets;

Expand Down Expand Up @@ -54,6 +54,16 @@ export const deploy = async ({
chainlinkAssets
});

await deployVelodromeOracleFraxtal({
run,
viem,
getNamedAccounts,
deployments,
deployConfig,
assets: fraxtal.assets.filter((asset) => asset.oracle === OracleTypes.VelodromePriceOracle),
pricesContract: "0xe58920a8c684CD3d6dCaC2a41b12998e4CB17EfE"
});

const uniswapV2LiquidatorFunder = await deployments.deploy("UniswapV2LiquidatorFunder", {
from: deployer,
args: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;

import "../BasePriceOracle.sol";

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

interface Prices {
function getRate(address srcToken, address dstToken, bool useSrcWrappers) external view returns (uint256 weightedRate);
}

contract VelodromePriceOracleFraxtal is BasePriceOracle {
Prices immutable prices;

constructor(address _prices) {
prices = Prices(_prices);
}
/**
* @notice Fetches the token/ETH price, with 18 decimals of precision.
* @param underlying The underlying token address for which to get the price.
* @return Price denominated in ETH (scaled by 1e18)
*/
function price(address underlying) external view override returns (uint256) {
return _price(underlying);
}

/**
* @notice Returns the price in ETH of the token underlying `cToken`.
* @dev Implements the `PriceOracle` interface for Ionic pools (and Compound v2).
* @return Price in ETH of the token underlying `cToken`, scaled by `10 ** (36 - underlyingDecimals)`.
*/
function getUnderlyingPrice(ICErc20 cToken) external view override returns (uint256) {
address underlying = cToken.underlying();
// Comptroller needs prices to be scaled by 1e(36 - decimals)
// Since `_price` returns prices scaled by 18 decimals, we must scale them by 1e(36 - 18 - decimals)
return (_price(underlying));
}

/**
* @notice Fetches the token/ETH price, with 18 decimals of precision.
*/
function _price(address token) internal view returns (uint256) {
return prices.getRate(token, 0xFC00000000000000000000000000000000000006, false);
}
}
Loading
Loading