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

Feat/superseed #864

Merged
merged 15 commits into from
Dec 19, 2024
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"packages/contracts"
],
"resolutions": {
"viem": "^2.21.12",
"viem": "^2.21.55",
"typescript": "^5.5.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion 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.55"
},
"devDependencies": {
"eslint": "^8",
Expand Down
8 changes: 3 additions & 5 deletions packages/bots/liquidator/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { APIGatewayEvent, APIGatewayProxyResult, Context } from "aws-lambda";
import axios from "axios";
import { createPublicClient, createWalletClient, fallback, Hex, http } from "viem";
import { createWalletClient, fallback, Hex, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mode } from "viem/chains";
import { BotType } from "@ionicprotocol/sdk";
Expand All @@ -9,8 +9,9 @@
import { liquidatePositions } from "./liquidatePositions";
import { logger } from "./logger";
import { setUpSdk } from "./utils";
import { createIonicPublicClient } from "./utils/client";

const HEARTBEAT_API_URL: any = process.env.UPTIME_LIQUIDATOR_API;

Check warning on line 14 in packages/bots/liquidator/src/index.ts

View workflow job for this annotation

GitHub Actions / lint-bots

Unexpected any. Specify a different type

if (typeof HEARTBEAT_API_URL === "undefined") {
logger.error("Error: UPTIME_LIQUIDATOR_API environment variable is undefined");
Expand All @@ -22,10 +23,7 @@

export const account = privateKeyToAccount(config.adminPrivateKey as Hex);

export const client = createPublicClient({
chain: mode,
transport: fallback(config.rpcUrls.map((url) => http(url))),
});
export const client = createIonicPublicClient(mode, config.rpcUrls);

export const walletClient = createWalletClient({
account,
Expand Down
17 changes: 3 additions & 14 deletions packages/bots/liquidator/src/justSubmit.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
import { Client, OpportunityParams } from "@pythnetwork/express-relay-evm-js";
import { ionicLiquidatorAbi } from "@ionicprotocol/sdk";
import {
createPublicClient,
createWalletClient,
encodeAbiParameters,
encodeFunctionData,
fallback,
Hex,
http,
} from "viem";
import { createWalletClient, encodeAbiParameters, encodeFunctionData, fallback, Hex, http } from "viem";
import { mode } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";

import config from "./config";
import { logger } from "./logger";
import { setUpSdk } from "./utils";
import { createIonicPublicClient } from "./utils/client";

(BigInt.prototype as any).toJSON = function () {

Check warning on line 12 in packages/bots/liquidator/src/justSubmit.ts

View workflow job for this annotation

GitHub Actions / lint-bots

Unexpected any. Specify a different type
return this.toString();
};
const account = privateKeyToAccount(config.adminPrivateKey as Hex);
const publicClient = createPublicClient({
batch: { multicall: { wait: 16 } },
chain: mode,
transport: fallback(config.rpcUrls.map((url) => http(url))),
});
const publicClient = createIonicPublicClient(mode, config.rpcUrls);
const walletClient = createWalletClient({
account,
chain: mode,
Expand Down Expand Up @@ -98,7 +87,7 @@
logger.info("Opportunity:", JSON.stringify(opportunity, null, 2));
try {
await client.submitOpportunity(opportunity);
console.info("Opportunity submitted successfully:", opportunity);

Check warning on line 90 in packages/bots/liquidator/src/justSubmit.ts

View workflow job for this annotation

GitHub Actions / lint-bots

Unexpected console statement
} catch (error) {
const errorMessage = error instanceof Error ? error.message : error;
console.error("Failed to submit opportunity:", {
Expand Down
8 changes: 6 additions & 2 deletions packages/bots/liquidator/src/runPythLiquidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
fallback,
Hex,
http,
type PublicClientConfig,
} from "viem";
import { mode } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";
Expand All @@ -26,11 +27,14 @@ const startTime = Math.floor(new Date().getTime() / 1000);
};

const account = privateKeyToAccount(config.adminPrivateKey as Hex);
const publicClient = createPublicClient({
const clientConfig: PublicClientConfig = {
batch: { multicall: { wait: 16 } },
chain: mode,
transport: fallback(config.rpcUrls.map((url) => http(url))),
});
cacheTime: 4_000,
pollingInterval: 4_000,
};
const publicClient = createPublicClient(clientConfig);
const walletClient = createWalletClient({
account,
chain: mode,
Expand Down
13 changes: 13 additions & 0 deletions packages/bots/liquidator/src/utils/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Chain, createPublicClient, fallback, http, PublicClientConfig } from "viem";

export function createIonicPublicClient(chain: Chain, rpcUrls: string[]) {
const config: PublicClientConfig = {
chain,
transport: fallback(rpcUrls.map((url) => http(url))),
batch: { multicall: { wait: 16 } },
cacheTime: 4_000,
pollingInterval: 4_000,
};

return createPublicClient(config);
}
2 changes: 1 addition & 1 deletion packages/bots/pyth-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"pino": "^9.2.0",
"pino-pretty": "^11.2.1",
"ts-node-dev": "^2.0.0",
"viem": "^2.21.12"
"viem": "^2.21.55"
},
"devDependencies": {
"eslint": "^8",
Expand Down
2 changes: 1 addition & 1 deletion packages/chains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@ionicprotocol/types": "workspace:*",
"utf-8-validate": "^6.0.4",
"viem": "^2.21.12"
"viem": "^2.21.55"
},
"devDependencies": {
"eslint": "^8",
Expand Down
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
};
22 changes: 22 additions & 0 deletions packages/chains/src/superseed/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/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;
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ export const deployIonicUniV3Liquidator = async ({
args: [deployConfig.wtoken, deployConfig.uniswap.uniswapV3Quoter]
}
},
proxyContract: "OpenZeppelinTransparentProxy",
owner: multisig
proxyContract: "OpenZeppelinTransparentProxy"
}
});
if (uniV3Liquidator.transactionHash)
Expand Down
Loading
Loading