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 #874

Merged
merged 8 commits into from
Dec 19, 2024
Merged

merge #874

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
16 changes: 15 additions & 1 deletion packages/chains/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,25 @@ import {
import { default as base } from "./base";
import { default as bob } from "./bob";
import { default as fraxtal } from "./fraxtal";
import { default as ink } from "./ink";
import { default as lisk } from "./lisk";
import { default as mode } from "./mode";
import { default as optimism } from "./optimism";
import { default as superseed } from "./superseed";
import { default as worldchain } from "./worldchain";

export { base, bob, lisk, mode, optimism, fraxtal, superseed, worldchain };
export { base, bob, lisk, mode, optimism, fraxtal, superseed, worldchain, ink };

export const vInk: Chain = {
id: 57073,
name: "Ink",
nativeCurrency: {
name: "Ethereum",
symbol: "ETH",
decimals: 18
},
rpcUrls: { default: { http: ["https://rpc-qnd.inkonchain.com", "https://rpc-gel.inkonchain.com"] } }
};

export const chainIdtoChain: { [chainId: number]: Chain } = {
[mode.chainId]: vMode,
Expand All @@ -29,6 +41,7 @@ export const chainIdtoChain: { [chainId: number]: Chain } = {
[bob.chainId]: vBob,
[fraxtal.chainId]: vFraxtal,
[lisk.chainId]: vLisk,
[ink.chainId]: vInk,
[superseed.chainId]: vSuperseed,
[worldchain.chainId]: vWorldchain
};
Expand All @@ -40,6 +53,7 @@ export const chainIdToConfig: { [chainId: number]: ChainConfig } = {
[bob.chainId]: bob,
[fraxtal.chainId]: fraxtal,
[lisk.chainId]: lisk,
[ink.chainId]: ink,
[superseed.chainId]: superseed,
[worldchain.chainId]: worldchain
};
22 changes: 22 additions & 0 deletions packages/chains/src/ink/addresses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { assetSymbols, ChainAddresses, underlying } from "@ionicprotocol/types";
import { zeroAddress } from "viem";

import { assets } from "./assets";

const chainAddresses: ChainAddresses = {
PAIR_INIT_HASH: "", // TODO is this used anywhere?
STABLE_TOKEN: zeroAddress,
UNISWAP_V2_ROUTER: zeroAddress,
UNISWAP_V2_FACTORY: zeroAddress,
UNISWAP_V3: {
FACTORY: zeroAddress,
PAIR_INIT_HASH: "",
QUOTER_V2: zeroAddress // unused
},
UNISWAP_V3_ROUTER: zeroAddress, // universal router, need to check if this works
W_BTC_TOKEN: zeroAddress, // underlying(assets, assetSymbols.WBTC),
W_TOKEN: underlying(assets, assetSymbols.WETH),
W_TOKEN_USD_CHAINLINK_PRICE_FEED: zeroAddress
};

export default chainAddresses;
22 changes: 22 additions & 0 deletions packages/chains/src/ink/assets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { assetSymbols, OracleTypes, SupportedAsset, SupportedChains } from "@ionicprotocol/types";
import { parseEther } from "viem";

import { wrappedAssetDocs } from "../common";

export const WETH = "0x4200000000000000000000000000000000000006";

export const assets: SupportedAsset[] = [
{
symbol: assetSymbols.WETH,
underlying: WETH,
name: "Wrapped Ether",
decimals: 18,
oracle: OracleTypes.FixedNativePriceOracle,
extraDocs: wrappedAssetDocs(SupportedChains.lisk),
initialBorrowCap: parseEther("100").toString(),
initialSupplyCap: parseEther("100").toString(),
initialCf: "0.5"
}
];

export default assets;
5 changes: 5 additions & 0 deletions packages/chains/src/ink/fundingStrategies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { FundingStrategy } from "@ionicprotocol/types";

const fundingStrategies: FundingStrategy[] = [];

export default fundingStrategies;
31 changes: 31 additions & 0 deletions packages/chains/src/ink/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ChainConfig, SupportedChains } from "@ionicprotocol/types";

import deployments from "../../../sdk/deployments/ink.json";

import chainAddresses from "./addresses";
import { assets } from "./assets";
import fundingStrategies from "./fundingStrategies";
import irms from "./irms";
import leveragePairs from "./leveragePairs";
import liquidationDefaults from "./liquidation";
import oracles from "./oracles";
import specificParams from "./params";
import deployedPlugins from "./plugins";
import redemptionStrategies from "./redemptionStrategies";

const chainConfig: ChainConfig = {
chainId: SupportedChains.ink,
chainAddresses,
assets,
irms,
liquidationDefaults,
oracles,
specificParams,
deployedPlugins,
redemptionStrategies,
fundingStrategies,
chainDeployments: deployments.contracts,
leveragePairs
};

export default chainConfig;
7 changes: 7 additions & 0 deletions packages/chains/src/ink/irms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { IrmTypes } from "@ionicprotocol/types";

const baseIrms = [IrmTypes.JumpRateModel];

const irms: IrmTypes[] = [...baseIrms];

export default irms;
5 changes: 5 additions & 0 deletions packages/chains/src/ink/leveragePairs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { LeveragePoolConfig } from "@ionicprotocol/types";

const leveragePairs: LeveragePoolConfig[] = [];

export default leveragePairs;
19 changes: 19 additions & 0 deletions packages/chains/src/ink/liquidation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { LiquidationDefaults, LiquidationStrategy } from "@ionicprotocol/types";
import { zeroAddress } from "viem";

import chainAddresses from "./addresses";
import { WETH } from "./assets";

const liquidationDefaults: LiquidationDefaults = {
DEFAULT_ROUTER: chainAddresses.UNISWAP_V2_ROUTER,
ASSET_SPECIFIC_ROUTER: {},
SUPPORTED_OUTPUT_CURRENCIES: [zeroAddress, WETH],
SUPPORTED_INPUT_CURRENCIES: [zeroAddress, WETH],
LIQUIDATION_STRATEGY: LiquidationStrategy.UNISWAP,
MINIMUM_PROFIT_NATIVE: 0n,
LIQUIDATION_INTERVAL_SECONDS: 20,
jarvisPools: [],
balancerPools: []
};

export default liquidationDefaults;
7 changes: 7 additions & 0 deletions packages/chains/src/ink/oracles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { OracleTypes } from "@ionicprotocol/types";

const baseOracles = [OracleTypes.FixedNativePriceOracle, OracleTypes.MasterPriceOracle, OracleTypes.SimplePriceOracle];

const oracles: OracleTypes[] = [...baseOracles];

export default oracles;
40 changes: 40 additions & 0 deletions packages/chains/src/ink/params.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { assetSymbols, ChainParams } from "@ionicprotocol/types";
import { Address } from "viem";

import chainAddresses from "./addresses";

const specificParams: ChainParams = {
blocksPerYear: BigInt(30 * 60 * 24 * 365), // 30 blocks per minute = 2 sec block time
cgId: "ethereum",
metadata: {
chainIdHex: "0xdef1",
name: "Ink",
shortName: "Ink",
uniswapV3Fees: {},
img: "https://icons.llamao.fi/icons/chains/rsz_lisk.jpg",
blockExplorerUrls: { default: { name: "ink", url: "https://explorer.inkonchain.com/" } },
rpcUrls: {
default: {
http: ["https://rpc-gel.inkonchain.com", "https://rpc-qnd.inkonchain.com"]
},
public: {
http: ["https://rpc-gel.inkonchain.com", "https://rpc-qnd.inkonchain.com"]
}
},
nativeCurrency: {
symbol: "ETH",
name: "ETH"
},
wrappedNativeCurrency: {
symbol: assetSymbols.WETH,
address: chainAddresses.W_TOKEN as Address,
name: "WETH",
decimals: 18,
color: "#7A88A1",
overlayTextColor: "#fff",
logoURL: "https://d1912tcoux65lj.cloudfront.net/network/ethereum.png"
}
}
};

export default specificParams;
5 changes: 5 additions & 0 deletions packages/chains/src/ink/plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { DeployedPlugins } from "@ionicprotocol/types";

const deployedPlugins: DeployedPlugins = {};

export default deployedPlugins;
5 changes: 5 additions & 0 deletions packages/chains/src/ink/redemptionStrategies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { RedemptionStrategy } from "@ionicprotocol/types";

const redemptionStrategies: RedemptionStrategy[] = [];

export default redemptionStrategies;
4 changes: 2 additions & 2 deletions packages/contracts/chainDeploy/helpers/irms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Address, Hash, parseEther } from "viem";
import { mode } from "viem/chains";

import { assetSymbols } from "@ionicprotocol/types";
import { mode as iMode } from "@ionicprotocol/chains";
import { chainIdtoChain, mode as iMode } from "@ionicprotocol/chains";
import { IrmDeployFnParams } from "../types";

import { underlying } from "./utils";
Expand Down Expand Up @@ -48,7 +48,7 @@ export const deployIRMs = async ({
viem,
chainId
}: IrmDeployFnParams): Promise<void> => {
const publicClient = await viem.getPublicClient();
const publicClient = await viem.getPublicClient({ chain: chainIdtoChain[chainId] });
const { deployer } = await getNamedAccounts();
//// IRM MODELS|
const jrm = await deployments.deploy("JumpRateModel", {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Address, Hash, parseEther, PublicClient, zeroAddress } from "viem";
import { AddressesProviderConfigFnParams, LiquidatorConfigFnParams, LiquidatorDeployFnParams } from "../../types";
import { chainIdToConfig } from "@ionicprotocol/chains";
import { chainIdtoChain, chainIdToConfig } from "@ionicprotocol/chains";
import { prepareAndLogTransaction } from "../logging";

export const deployIonicLiquidator = async ({
Expand Down Expand Up @@ -66,10 +66,12 @@ export const deployIonicUniV3Liquidator = async ({
viem,
getNamedAccounts,
deployments,
deployConfig
deployConfig,
chainId
}: LiquidatorDeployFnParams): Promise<string> => {
const { deployer, multisig } = await getNamedAccounts();
const publicClient = await viem.getPublicClient();
const publicClient = await viem.getPublicClient({ chain: chainIdtoChain[chainId] });
const walletClient = await viem.getWalletClient(deployer as Address, { chain: chainIdtoChain[chainId] });

const uniV3Liquidator = await deployments.deploy("IonicUniV3Liquidator", {
from: deployer,
Expand All @@ -90,7 +92,8 @@ export const deployIonicUniV3Liquidator = async ({

const ionicLiquidator = await viem.getContractAt(
"IonicUniV3Liquidator",
(await deployments.get("IonicUniV3Liquidator")).address as Address
(await deployments.get("IonicUniV3Liquidator")).address as Address,
{ client: { public: publicClient, wallet: walletClient } }
);
const uniV3LiquidatorOwner = await ionicLiquidator.read.owner();
console.log(`IonicUniV3Liquidator owner is ${uniV3LiquidatorOwner}`);
Expand All @@ -102,22 +105,27 @@ export const configureIonicLiquidator = async ({
contractName,
viem,
chainId,
deployments
deployments,
getNamedAccounts
}: LiquidatorConfigFnParams): Promise<void> => {
const publicClient = await viem.getPublicClient();
const { deployer } = await getNamedAccounts();
const publicClient = await viem.getPublicClient({ chain: chainIdtoChain[chainId] });
const walletClient = await viem.getWalletClient(deployer as Address, { chain: chainIdtoChain[chainId] });

const strategies: string[] = [];
const arrayOfTrue: boolean[] = [];
const ionicLiquidator = await viem.getContractAt(
contractName,
(await deployments.get(contractName)).address as Address
(await deployments.get(contractName)).address as Address,
{ client: { public: publicClient, wallet: walletClient } }
);

for (const redemptionStrategyConfig of chainIdToConfig[chainId].redemptionStrategies) {
const { strategy } = redemptionStrategyConfig;
const redemptionStrategyContract = await viem.getContractAt(
strategy as string,
(await deployments.get(strategy)).address as Address
(await deployments.get(strategy)).address as Address,
{ client: { public: publicClient, wallet: walletClient } }
);

const whitelistedAlready = await ionicLiquidator.read.redemptionStrategiesWhitelist([
Expand All @@ -133,7 +141,8 @@ export const configureIonicLiquidator = async ({
const { strategy } = fundingStrategy;
const fundingStrategyContract = await viem.getContractAt(
strategy as string,
(await deployments.get(strategy)).address as Address
(await deployments.get(strategy)).address as Address,
{ client: { public: publicClient, wallet: walletClient } }
);

const whitelistedAlready = await ionicLiquidator.read.redemptionStrategiesWhitelist([
Expand All @@ -153,7 +162,9 @@ export const configureIonicLiquidator = async ({
console.log("no redemption strategies for whitelisting");
}

const poolLens = await viem.getContractAt("PoolLens", (await deployments.get("PoolLens")).address as Address);
const poolLens = await viem.getContractAt("PoolLens", (await deployments.get("PoolLens")).address as Address, {
client: { public: publicClient, wallet: walletClient }
});
const healthFactorThreshold = parseEther("1");
const expressRelay = chainIdToConfig[chainId].chainAddresses.EXPRESS_RELAY;

Expand All @@ -180,11 +191,14 @@ export const configureAddressesProviderAddresses = async ({
deployments
}: AddressesProviderConfigFnParams): Promise<void> => {
const { deployer } = await getNamedAccounts();
const publicClient = await viem.getPublicClient();
const publicClient = await viem.getPublicClient({ chain: chainIdtoChain[chainId] });
const walletClient = await viem.getWalletClient(deployer as Address, { chain: chainIdtoChain[chainId] });
const chainConfig = chainIdToConfig[chainId];
const _ap = await deployments.getOrNull("AddressesProvider");
if (_ap) {
const ap = await viem.getContractAt("AddressesProvider", _ap.address as Address);
const ap = await viem.getContractAt("AddressesProvider", _ap.address as Address, {
client: { public: publicClient, wallet: walletClient }
});
/// EXTERNAL ADDRESSES
await configureAddress(
ap,
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/chainDeploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { deploy as deployMode, deployConfig as deployConfigMode } from "./mainne
import { deploy as deployFrax, deployConfig as deployConfigFrax } from "./mainnets/fraxtal";
import { deploy as deployOptimism, deployConfig as deployConfigOptimism } from "./mainnets/optimism";
import { deploy as deployLisk, deployConfig as deployConfigLisk } from "./mainnets/lisk";
import { deploy as deployInk, deployConfig as deployConfigInk } from "./mainnets/ink";
import { deploy as deploySuperseed, deployConfig as deployConfigSuperseed } from "./mainnets/superseed";
import { deploy as deployWorldchain, deployConfig as deployConfigWorldchain } from "./mainnets/worldchain";

Expand All @@ -15,6 +16,7 @@ export const chainDeployConfig: Record<number, { config: ChainDeployConfig; depl
[fraxtal.id]: { config: deployConfigFrax, deployFunc: deployFrax },
[optimism.id]: { config: deployConfigOptimism, deployFunc: deployOptimism },
[lisk.id]: { config: deployConfigLisk, deployFunc: deployLisk },
57073: { config: deployConfigInk, deployFunc: deployInk },
[superseed.id]: { config: deployConfigSuperseed, deployFunc: deploySuperseed },
[worldchain.id]: { config: deployConfigWorldchain, deployFunc: deployWorldchain }
// testnets
Expand Down
Loading
Loading