Skip to content

Commit

Permalink
Merge branch 'development' into feat/markets-ui-update
Browse files Browse the repository at this point in the history
  • Loading branch information
vidvidvid committed Nov 21, 2024
2 parents a0caec1 + 7d24c9e commit 8aa39db
Show file tree
Hide file tree
Showing 45 changed files with 9,203 additions and 1,894 deletions.
44 changes: 39 additions & 5 deletions packages/chains/src/base/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
assetSymbols,
ChainlinkFeedBaseCurrency,
ChainlinkSpecificParams,
DiaSpecificParams,
OracleTypes,
PythSpecificParams,
SupportedAsset,
Expand Down Expand Up @@ -38,6 +39,7 @@ export const uSOL = "0x9B8Df6E244526ab5F6e6400d331DB28C8fdDdb55";
export const uSUI = "0xb0505e5a99abd03d94a1169e638B78EDfEd26ea4";
export const sUSDz = "0xe31eE12bDFDD0573D634124611e85338e2cBF0cF";
export const fBOMB = "0x74ccbe53F77b08632ce0CB91D3A545bF6B8E0979";
export const KLIMA = "0xDCEFd8C8fCc492630B943ABcaB3429F12Ea9Fea2";

export const assets: SupportedAsset[] = [
{
Expand Down Expand Up @@ -143,7 +145,9 @@ export const assets: SupportedAsset[] = [
feedBaseCurrency: ChainlinkFeedBaseCurrency.ETH
},
initialCf: "0.70",
extraDocs: defaultDocs("https://basescan.org", weETH)
extraDocs: defaultDocs("https://basescan.org", weETH),
initialSupplyCap: parseEther(String(1_500)).toString(),
initialBorrowCap: parseEther(String(1_200)).toString()
},
{
symbol: assetSymbols.eUSD,
Expand Down Expand Up @@ -249,8 +253,8 @@ export const assets: SupportedAsset[] = [
aggregator: "0x88Ee016dadDCa8061bf6D566585dF6c8aBfED7bb",
feedBaseCurrency: ChainlinkFeedBaseCurrency.USD
},
initialSupplyCap: parseEther(String(250_000)).toString(),
initialBorrowCap: parseEther(String(120_000)).toString(),
initialSupplyCap: parseEther(String(2_500_000)).toString(),
initialBorrowCap: parseEther(String(2_000_000)).toString(),
initialCf: "0.82",
extraDocs: defaultDocs("https://basescan.org", wUSDM)
},
Expand Down Expand Up @@ -361,9 +365,39 @@ export const assets: SupportedAsset[] = [
aggregator: "0xD89c7fFB39C44b17EAecd8717a75A36c19C07582",
feedBaseCurrency: ChainlinkFeedBaseCurrency.USD
},
initialBorrowCap: parseEther(String(80_000)).toString(),
initialSupplyCap: parseEther(String(100_000)).toString(),
initialBorrowCap: parseEther(String(215_000)).toString(),
initialSupplyCap: parseEther(String(270_000)).toString(),
initialCf: "0.70"
},
{
symbol: assetSymbols.fBOMB,
underlying: fBOMB,
name: "Fantom Bomb",
decimals: 18,
oracle: OracleTypes.ChainlinkPriceOracleV2,
oracleSpecificParams: {
aggregator: "0xFB1267A29C0aa19daae4a483ea895862A69e4AA5", // redstone: https://app.redstone.finance/app/feeds/?search=fbomb&page=1&sortBy=popularity&sortDesc=false&perPage=32
feedBaseCurrency: ChainlinkFeedBaseCurrency.USD
},
extraDocs: defaultDocs("https://basescan.org", fBOMB),
initialCf: "0.50",
initialSupplyCap: parseEther(String(20_000_000)).toString(),
initialBorrowCap: parseEther(String(15_000_000)).toString()
},
{
symbol: assetSymbols.KLIMA,
underlying: KLIMA,
name: "Klima DAO",
decimals: 9,
oracle: OracleTypes.DiaPriceOracle,
oracleSpecificParams: {
feed: "0x12df07B05E9DABE78bD04B90206E31F6f64D75bB",
key: "KLIMA/USD"
} as DiaSpecificParams,
extraDocs: defaultDocs("https://basescan.org", KLIMA),
initialSupplyCap: parseUnits(String(1_500_000), 9).toString(),
initialBorrowCap: parseUnits(String(1_200_000), 9).toString(),
initialCf: "0.55"
}
// DO NOT ADD TO MARKET UNLESS PROPER ORACLE IS DEPLOYED
// {
Expand Down
3 changes: 2 additions & 1 deletion packages/chains/src/base/oracles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const baseOracles = [
OracleTypes.FixedNativePriceOracle,
OracleTypes.MasterPriceOracle,
OracleTypes.SimplePriceOracle,
OracleTypes.PythPriceOracle
OracleTypes.PythPriceOracle,
OracleTypes.DiaPriceOracle
];

const oracles: OracleTypes[] = [...baseOracles, OracleTypes.ChainlinkPriceOracleV2];
Expand Down
93 changes: 93 additions & 0 deletions packages/contracts/chainDeploy/helpers/oracles/dia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { Address, GetContractReturnType, WalletClient } from "viem";

import { prepareAndLogTransaction } from "../logging";

import { addUnderlyingsToMpo } from "./utils";
import { DiaAsset, DiaDeployFnParams } from "../../types";
import { diaPriceOracleAbi } from "../../../../sdk/src/generated";
import { assetSymbols, underlying } from "@ionicprotocol/types";
import { base } from "@ionicprotocol/chains";

export const deployDiaPriceOracle = async ({
viem,
getNamedAccounts,
deployments,
diaAssets,
diaNativeFeed
}: DiaDeployFnParams): Promise<{ diaOracle: GetContractReturnType<typeof diaPriceOracleAbi, WalletClient> }> => {
const { deployer } = await getNamedAccounts();
const publicClient = await viem.getPublicClient();

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

//// Dia Oracle
const dia = await deployments.deploy("DiaPriceOracle", {
from: deployer,
args: [
deployer,
true,
"0x4200000000000000000000000000000000000006",
diaNativeFeed?.feed ?? "0x0000000000000000000000000000000000000000",
diaNativeFeed?.key ?? "",
(await deployments.get("MasterPriceOracle")).address,
underlying(base.assets, assetSymbols.USDC)
],
log: true,
waitConfirmations: 1
});

if (dia.transactionHash) publicClient.waitForTransactionReceipt({ hash: dia.transactionHash as Address });
console.log("DiaPriceOracle: ", dia.address);

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

const diaAssetsToChange: DiaAsset[] = [];
console.log("🚀 ~ diaAssets:", diaAssets);
for (const diaAsset of diaAssets) {
const currentPriceFeed = await diaOracle.read.priceFeeds([diaAsset.underlying]);
console.log("🚀 ~ currentPriceFeed:", currentPriceFeed);
if (currentPriceFeed[0] !== diaAsset.feed || currentPriceFeed[1] !== diaAsset.key) {
diaAssetsToChange.push(diaAsset);
}
}
console.log("🚀 ~ diaAssetsToChange:", diaAssetsToChange);
if (diaAssetsToChange.length > 0) {
if (((await diaOracle.read.admin()) as Address).toLowerCase() === deployer.toLowerCase()) {
const tx = await diaOracle.write.setPriceFeeds([
diaAssetsToChange.map((f) => f.underlying),
diaAssetsToChange.map((f) => f.feed),
diaAssetsToChange.map((f) => f.key)
]);
await publicClient.waitForTransactionReceipt({ hash: tx });
console.log(`Set ${diaAssetsToChange.length} price feeds for DiaPriceOracle at ${tx}`);
} else {
await prepareAndLogTransaction({
contractInstance: diaOracle,
args: [
diaAssetsToChange.map((f) => f.underlying),
diaAssetsToChange.map((f) => f.feed),
diaAssetsToChange.map((f) => f.key)
],
description: `Set ${diaAssetsToChange.length} price feeds for DiaPriceOracle`,
functionName: "setPriceFeeds",
inputs: [
{ internalType: "address[]", name: "underlyings", type: "address[]" },
{ internalType: "bytes32[]", name: "feeds", type: "bytes32[]" },
{ internalType: "string[]", name: "keys", type: "string[]" }
]
});
console.log(`Logged Transaction to set ${diaAssetsToChange.length} price feeds for DiaPriceOracle `);
}
}

const underlyings = diaAssets.map((f) => f.underlying);
await addUnderlyingsToMpo(mpo as any, underlyings, diaOracle.address, deployer, publicClient);

return { diaOracle: diaOracle as any };
};
21 changes: 20 additions & 1 deletion packages/contracts/chainDeploy/mainnets/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Address, zeroAddress } from "viem";
import { ChainlinkSpecificParams, OracleTypes, PythSpecificParams } from "../types";
import { configureAddress } from "../helpers/liquidators/ionicLiquidator";
import { deployDiaPriceOracle } from "../helpers/oracles/dia";
import { DiaSpecificParams } from "@ionicprotocol/types";

const assets = base.assets;

Expand Down Expand Up @@ -61,7 +63,7 @@ export const deploy = async ({
usdToken: base.chainAddresses.STABLE_TOKEN as Address
});

//// ERC4626 Oracle
// //// ERC4626 Oracle
await deployErc4626PriceOracle({
run,
viem,
Expand Down Expand Up @@ -104,6 +106,23 @@ export const deploy = async ({
chainlinkAssets
});

const diaAssets = base.assets
.filter((asset) => asset.oracle === OracleTypes.DiaPriceOracle)
.map((asset) => ({
feed: (asset.oracleSpecificParams as DiaSpecificParams).feed,
underlying: asset.underlying,
key: (asset.oracleSpecificParams as DiaSpecificParams).key,
symbol: asset.symbol
}));
await deployDiaPriceOracle({
run,
viem,
getNamedAccounts,
deployments,
deployConfig,
diaAssets
});

const ap = await viem.getContractAt(
"AddressesProvider",
(await deployments.get("AddressesProvider")).address as Address
Expand Down
7 changes: 4 additions & 3 deletions packages/contracts/chainDeploy/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export type ChainlinkAsset = {

export type DiaAsset = {
symbol: string;
underlying: string;
feed: string;
underlying: Address;
feed: Address;
key: string;
};

Expand Down Expand Up @@ -308,7 +308,8 @@ export enum OracleTypes {
RedstoneAdapterPriceOracle = "RedstoneAdapterPriceOracle",
RedstoneAdapterWrsETHPriceOracle = "RedstoneAdapterWrsETHPriceOracle",
VelodromePriceOracle = "VelodromePriceOracle",
AerodromePriceOracle = "AerodromePriceOracle"
AerodromePriceOracle = "AerodromePriceOracle",
DiaPriceOracle = "DiaPriceOracle"
}

export type ChainAddresses = {
Expand Down
Loading

0 comments on commit 8aa39db

Please sign in to comment.