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

Merged
merged 10 commits into from
Dec 21, 2024
Merged

Merge #883

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
10 changes: 10 additions & 0 deletions .github/workflows/deploy-bots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ jobs:
- name: Checkout
uses: actions/checkout@master

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: "1.5.0"

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand Down Expand Up @@ -403,6 +408,11 @@ jobs:
- name: Checkout
uses: actions/checkout@master

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: "1.5.0"

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
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 @@ -19,9 +19,10 @@ 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 swellchain } from "./swellchain";
import { default as worldchain } from "./worldchain";

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

export const vInk: Chain = {
id: 57073,
Expand All @@ -34,6 +35,17 @@ export const vInk: Chain = {
rpcUrls: { default: { http: ["https://rpc-qnd.inkonchain.com", "https://rpc-gel.inkonchain.com"] } }
};

export const vSwellchain: Chain = {
id: 1923,
name: "Swellchain",
nativeCurrency: {
name: "Ethereum",
symbol: "ETH",
decimals: 18
},
rpcUrls: { default: { http: ["https://rpc.ankr.com/swell", "https://swell-mainnet.alt.technology"] } }
};

export const chainIdtoChain: { [chainId: number]: Chain } = {
[mode.chainId]: vMode,
[base.chainId]: vBase,
Expand All @@ -43,7 +55,8 @@ export const chainIdtoChain: { [chainId: number]: Chain } = {
[lisk.chainId]: vLisk,
[ink.chainId]: vInk,
[superseed.chainId]: vSuperseed,
[worldchain.chainId]: vWorldchain
[worldchain.chainId]: vWorldchain,
[swellchain.chainId]: vSwellchain
};

export const chainIdToConfig: { [chainId: number]: ChainConfig } = {
Expand All @@ -55,5 +68,6 @@ export const chainIdToConfig: { [chainId: number]: ChainConfig } = {
[lisk.chainId]: lisk,
[ink.chainId]: ink,
[superseed.chainId]: superseed,
[worldchain.chainId]: worldchain
[worldchain.chainId]: worldchain,
[swellchain.chainId]: swellchain
};
22 changes: 22 additions & 0 deletions packages/chains/src/swellchain/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: zeroAddress,
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/swellchain/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.worldchain),
initialBorrowCap: parseEther("100").toString(),
initialSupplyCap: parseEther("100").toString(),
initialCf: "0.5"
}
];

export default assets;
5 changes: 5 additions & 0 deletions packages/chains/src/swellchain/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/swellchain/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/swellchain.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.swell,
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/swellchain/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/swellchain/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/swellchain/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/swellchain/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;
42 changes: 42 additions & 0 deletions packages/chains/src/swellchain/params.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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: "0x783",
name: "Swellchain",
shortName: "Swell",
uniswapV3Fees: {},
img: "https://worldcoin-company-website.cdn.prismic.io/worldcoin-company-website/ZxFd_IF3NbkBXsKH_World_logo-01-4-.svg?w=1024",
blockExplorerUrls: {
default: { name: "swellchainexplorer", url: "https://explorer.swellnetwork.io/" }
},
rpcUrls: {
default: {
http: ["https://rpc.ankr.com/swell", "https://swell-mainnet.alt.technology"]
},
public: {
http: ["https://rpc.ankr.com/swell", "https://swell-mainnet.alt.technology"]
}
},
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/swellchain/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/swellchain/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: 3 additions & 1 deletion packages/contracts/chainDeploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { deploy as deployLisk, deployConfig as deployConfigLisk } from "./mainne
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";
import { deploy as deploySwellchain, deployConfig as deployConfigSwellchain } from "./mainnets/swellchain";

export const chainDeployConfig: Record<number, { config: ChainDeployConfig; deployFunc: any }> = {
// mainnets
Expand All @@ -18,7 +19,8 @@ export const chainDeployConfig: Record<number, { config: ChainDeployConfig; depl
[lisk.id]: { config: deployConfigLisk, deployFunc: deployLisk },
57073: { config: deployConfigInk, deployFunc: deployInk },
[superseed.id]: { config: deployConfigSuperseed, deployFunc: deploySuperseed },
[worldchain.id]: { config: deployConfigWorldchain, deployFunc: deployWorldchain }
[worldchain.id]: { config: deployConfigWorldchain, deployFunc: deployWorldchain },
1923: { config: deployConfigSwellchain, deployFunc: deploySwellchain }
// testnets
// local
};
Expand Down
45 changes: 45 additions & 0 deletions packages/contracts/chainDeploy/mainnets/swellchain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { swellchain } from "@ionicprotocol/chains";

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

const assets = swellchain.assets;

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

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

//// Uniswap V3 Liquidator Funder
const uniswapV3LiquidatorFunder = await deployments.deploy("UniswapV3LiquidatorFunder", {
from: deployer,
args: [],
log: true,
waitConfirmations: 1
});
console.log("UniswapV3LiquidatorFunder: ", uniswapV3LiquidatorFunder.address);
};
1 change: 1 addition & 0 deletions packages/contracts/deployments/swellchain/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1923
Loading
Loading