Skip to content

Commit

Permalink
feat: superseed
Browse files Browse the repository at this point in the history
  • Loading branch information
rhlsthrm committed Nov 26, 2024
1 parent 466685e commit 2e3e91f
Show file tree
Hide file tree
Showing 38 changed files with 4,142 additions and 305 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"packages/contracts"
],
"resolutions": {
"viem": "^2.21.12",
"typescript": "^5.5.3"
"viem": "^2.21.50",
"typescript": "^5.7.2"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
Expand All @@ -31,7 +31,7 @@
"ts-node": "^10.9.1",
"tsc": "^2.0.4",
"tsup": "^8.1.0",
"typescript": "^5.5.3"
"typescript": "^5.7.2"
},
"dependencies": {
"@next/react-dev-overlay": "^14.1.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/bots/liquidator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dotenv": "^16.4.5",
"pino": "^9.2.0",
"pino-pretty": "^11.2.1",
"viem": "^2.21.12"
"viem": "^2.21.50"
},
"devDependencies": {
"eslint": "^8",
Expand All @@ -43,6 +43,6 @@
"prettier": "2.7.1",
"rimraf": "^5.0.7",
"ts-node": "^10.9.2",
"typescript": "^5.5.3"
"typescript": "^5.7.2"
}
}
4 changes: 2 additions & 2 deletions packages/bots/pyth-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
"pino": "^9.2.0",
"pino-pretty": "^11.2.1",
"ts-node-dev": "^2.0.0",
"viem": "^2.21.12"
"viem": "^2.21.50"
},
"devDependencies": {
"eslint": "^8",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"rimraf": "^5.0.7",
"typescript": "^5.5.3"
"typescript": "^5.7.2"
}
}
4 changes: 2 additions & 2 deletions packages/chains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
"dependencies": {
"@ionicprotocol/types": "workspace:*",
"utf-8-validate": "^6.0.4",
"viem": "^2.21.12"
"viem": "^2.21.50"
},
"devDependencies": {
"eslint": "^8",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "3.0.0",
"typescript": "^5.5.3",
"typescript": "^5.7.2",
"typescript-eslint": "^7.14.1"
}
}
8 changes: 6 additions & 2 deletions packages/chains/src/common/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ export const wrappedAssetDocs = (chainId: SupportedChains) => {
swapAddress: "https://velodrome.finance/swap"
},
[SupportedChains.fraxtal]: {
swapName: "Fraxtal",
swapName: "Velodrome",
swapAddress: "https://app.frax.finance/swap/main"
},
[SupportedChains.lisk]: {
swapName: "Lisk",
swapName: "Velodrome",
swapAddress: "https://velodrome.finance/swap"
},
[SupportedChains.superseed]: {
swapName: "Velodrome",
swapAddress: "https://velodrome.finance/swap"
}
}[chainId];
Expand Down
20 changes: 17 additions & 3 deletions packages/chains/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,29 @@ import { default as fraxtal } from "./fraxtal";
import { default as lisk } from "./lisk";
import { default as mode } from "./mode";
import { default as optimism } from "./optimism";
import { default as superseed } from "./superseed";

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

const vSuperseed: Chain = {
id: 5330,
name: "Superseed",
nativeCurrency: {
name: "Ethereum",
symbol: "ETH",
decimals: 18
},
rpcUrls: { default: { http: ["https://rpc-superseed-mainnet-0.t.conduit.xyz"] } }
};

export const chainIdtoChain: { [chainId: number]: Chain } = {
[mode.chainId]: vMode,
[base.chainId]: vBase,
[optimism.chainId]: vOptimism,
[bob.chainId]: vBob,
[fraxtal.chainId]: vFraxtal,
[lisk.chainId]: vLisk
[lisk.chainId]: vLisk,
[superseed.chainId]: vSuperseed
};

export const chainIdToConfig: { [chainId: number]: ChainConfig } = {
Expand All @@ -33,5 +46,6 @@ export const chainIdToConfig: { [chainId: number]: ChainConfig } = {
[optimism.chainId]: optimism,
[bob.chainId]: bob,
[fraxtal.chainId]: fraxtal,
[lisk.chainId]: lisk
[lisk.chainId]: lisk,
[superseed.chainId]: superseed
};
21 changes: 21 additions & 0 deletions packages/chains/src/superseed/addresses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { assetSymbols, ChainAddresses, underlying } from "@ionicprotocol/types";

import { assets } from "./assets";

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

export default chainAddresses;
22 changes: 22 additions & 0 deletions packages/chains/src/superseed/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.superseed),
initialBorrowCap: parseEther("100").toString(),
initialSupplyCap: parseEther("100").toString(),
initialCf: "0.5"
}
];

export default assets;
5 changes: 5 additions & 0 deletions packages/chains/src/superseed/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/superseed/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/superseed.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.superseed,
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/superseed/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/superseed/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/superseed/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/superseed/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/superseed/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: "0x14d2",
name: "Superseed",
shortName: "Superseed",
uniswapV3Fees: {},
img: "https://raw.githubusercontent.com/superseed-xyz/brand-kit/227ecaadf8da2ad9acb208428ff178a2cd345565/logos-wordmarks/logos/small-black.svg",
blockExplorerUrls: { default: { name: "superseed", url: "https://explorer-superseed-mainnet-0.t.conduit.xyz" } },
rpcUrls: {
default: {
http: ["https://mainnet.superseed.xyz"]
},
public: {
http: ["https://mainnet.superseed.xyz"]
}
},
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/superseed/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/superseed/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;
5 changes: 4 additions & 1 deletion packages/contracts/chainDeploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ 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 deploySuperseed, deployConfig as deployConfigSuperseed } from "./mainnets/superseed";
import { superseed } from "@ionicprotocol/chains";

export const chainDeployConfig: Record<number, { config: ChainDeployConfig; deployFunc: any }> = {
// mainnets
[mode.id]: { config: deployConfigMode, deployFunc: deployMode },
[base.id]: { config: deployConfigBase, deployFunc: deployBase },
[fraxtal.id]: { config: deployConfigFrax, deployFunc: deployFrax },
[optimism.id]: { config: deployConfigOptimism, deployFunc: deployOptimism },
[lisk.id]: { config: deployConfigLisk, deployFunc: deployLisk }
[lisk.id]: { config: deployConfigLisk, deployFunc: deployLisk },
[superseed.chainId]: { config: deployConfigSuperseed, deployFunc: deploySuperseed }
// testnets
// local
};
Expand Down
46 changes: 46 additions & 0 deletions packages/contracts/chainDeploy/mainnets/superseed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { superseed } from "@ionicprotocol/chains";

import { ChainDeployConfig } from "../helpers";
import { Address } from "viem";
import { HardhatRuntimeEnvironment } from "hardhat/types";

const assets = superseed.assets;

export const deployConfig: ChainDeployConfig = {
blocksPerYear: Number(superseed.specificParams.blocksPerYear),
cgId: superseed.specificParams.cgId,
nativeTokenName: "Ethereum",
nativeTokenSymbol: "ETH",
stableToken: superseed.chainAddresses.STABLE_TOKEN as Address,
uniswap: {
flashSwapFee: 30, // TODO set the correct fee
hardcoded: [],
uniswapData: [],
uniswapOracleInitialDeployTokens: [],
uniswapV2FactoryAddress: superseed.chainAddresses.UNISWAP_V2_FACTORY as Address,
uniswapV2RouterAddress: superseed.chainAddresses.UNISWAP_V2_ROUTER as Address,
uniswapV3SwapRouter: superseed.chainAddresses.UNISWAP_V3_ROUTER as Address,
uniswapV3Quoter: superseed.chainAddresses.UNISWAP_V3?.QUOTER_V2 as Address
},
wtoken: superseed.chainAddresses.W_TOKEN as Address,
nativeTokenUsdChainlinkFeed: superseed.chainAddresses.W_TOKEN_USD_CHAINLINK_PRICE_FEED as Address
};

export const deploy = async ({
run,
viem,
getNamedAccounts,
deployments
}: HardhatRuntimeEnvironment): Promise<void> => {
const { deployer } = await getNamedAccounts();
const publicClient = await viem.getPublicClient();

//// Uniswap V3 Liquidator Funder
const uniswapV3LiquidatorFunder = await deployments.deploy("UniswapV3LiquidatorFunder", {
from: deployer,
args: [],
log: true,
waitConfirmations: 1
});
console.log("UniswapV3LiquidatorFunder: ", uniswapV3LiquidatorFunder.address);
};
3 changes: 2 additions & 1 deletion packages/contracts/deploy/01-deploy-fee-distributor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DeployFunction } from "hardhat-deploy/types";
import { Address, formatUnits, parseEther, maxUint256, Hash } from "viem";
import { chainIdtoChain } from "@ionicprotocol/chains";

import { ChainDeployConfig, chainDeployConfig } from "../chainDeploy";
import { getCgPrice } from "../chainDeploy/helpers/getCgPrice";
Expand All @@ -9,7 +10,7 @@ const func: DeployFunction = async ({ viem, getNamedAccounts, deployments, getCh
console.log("chainId: ", chainId);

const MIN_BORROW_USD = 0.1;
const publicClient = await viem.getPublicClient();
const publicClient = await viem.getPublicClient({ chain: chainIdtoChain[chainId] });

const { deployer, multisig } = await getNamedAccounts();
console.log("deployer: ", deployer);
Expand Down
1 change: 1 addition & 0 deletions packages/contracts/deployments/superseed/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5330
Loading

0 comments on commit 2e3e91f

Please sign in to comment.