Skip to content

Commit

Permalink
refactor: re-deployed contracts and added token pools (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
gidonkatten authored May 28, 2024
1 parent 95a18d1 commit 52b817c
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 32 deletions.
92 changes: 79 additions & 13 deletions src/chains/evm/hub/constants/chain.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { FOLKS_CHAIN_ID } from "../../../../common/constants/chain.js";
import { TESTNET_POOLS } from "../../../../common/constants/pool.js";
import { NetworkType, ChainType } from "../../../../common/types/chain.js";
import { AdapterType } from "../../../../common/types/message.js";
import { LoanType } from "../../../../common/types/module.js";
import { FolksTokenId, TokenType } from "../../../../common/types/token.js";
import { convertToGenericAddress } from "../../../../common/utils/address.js";

import type { FolksChainId } from "../../../../common/types/chain.js";
import type { FolksTokenId } from "../../../../common/types/token.js";
import type { HubChain } from "../types/chain.js";
import type { HubTokenData } from "../types/token.js";

Expand All @@ -29,51 +31,115 @@ export const HUB_CHAIN: Record<NetworkType, HubChain> = {
[NetworkType.TESTNET]: {
folksChainId: FOLKS_CHAIN_ID.AVALANCHE_FUJI,
hubAddress: convertToGenericAddress(
"0xb31b3411B51604fa0058AEf8fc2c1E498e3be4d4",
"0xaFcA3bE824b6210918D3BeB63762D6211f1e91C3",
ChainType.EVM,
),
bridgeRouterAddress: convertToGenericAddress(
"0x63EFE00C08f6AEAA5D469A063c44504369977e8D",
"0x46Db2e9cD0787bF791Df2c9AE9963E296847FF1D",
ChainType.EVM,
),
adapters: {
[AdapterType.HUB]: convertToGenericAddress(
"0x52521e15f9C59aff55650011FAA45De233207bB8",
"0xB01296Ea267463FDe2fcE5Fad5067B4d875A44Ba",
ChainType.EVM,
),
[AdapterType.WORMHOLE_DATA]: convertToGenericAddress(
"0xaf10F2A98012fBA0106d7060069b0019A61137aa",
"0x7A6099E5cE3b66B042c9d11c3D472882bd42e23C",
ChainType.EVM,
),
[AdapterType.WORMHOLE_CCTP]: convertToGenericAddress(
"0x4e10f4dd1211152c901CCcF697aE82fb21920EcB",
"0xf7EB478F95470caF349d999047e1D4A713aD7a7f",
ChainType.EVM,
),
[AdapterType.CCIP_DATA]: convertToGenericAddress(
"0xB97A2FC865464ea740E1b4C47e676D1A91f396e2",
"0x498d72950d7cf912Be48BA5C8894e98A81E204fc",
ChainType.EVM,
),
[AdapterType.CCIP_TOKEN]: convertToGenericAddress(
"0xd698B6cbfEa66675586aEcad5a89ef8385C77c9e",
"0x715Cd24a347552ae07e7d11Df2a59FFcEb2A9b66",
ChainType.EVM,
),
},
oracleManagerAddress: convertToGenericAddress(
"0x1E8F9D289FdE82185824948Ca19965cD489e1616",
"0xc9cb1F8FcfBB804669d44349d44fB14BE4c665F0",
ChainType.EVM,
),
spokeManagerAddress: convertToGenericAddress(
"0xA63303A4a7abF395E8E5598DC5539e03AF149e5E",
"0xf27720C8B9C28d8E23bAA0A64347323FBB151CeD",
ChainType.EVM,
),
accountManagerAddress: convertToGenericAddress(
"0x369367f7A745Ac9003f5D78658F2B0323d3cc370",
"0x5Ff19CF35875C973F63a60e78445F449292c5575",
ChainType.EVM,
),
loanManagerAddress: convertToGenericAddress(
"0x21a91A04e452Ada77bFBF1fCa697F0D70B8917cA",
"0x24f0a8f4D41E8CBe18676F75e0d11b105d1cc0A6",
ChainType.EVM,
),
tokens: {} as Record<FolksTokenId, HubTokenData>,
tokens: {
[FolksTokenId.USDC]: {
tokenType: TokenType.CIRCLE,
folksTokenId: FolksTokenId.USDC,
poolId: TESTNET_POOLS[FolksTokenId.USDC],
poolAddress: convertToGenericAddress(
"0xA9F3dfff0E8939514E7C4A0F8CeB0dBED93BbEA5",
ChainType.EVM,
),
tokenAddress: convertToGenericAddress(
"0x5425890298aed601595a70ab815c96711a31bc65",
ChainType.EVM,
),
tokenDecimals: 6,
supportedLoanTypes: new Set([LoanType.DEPOSIT, LoanType.GENERAL]),
},
[FolksTokenId.AVAX]: {
tokenType: TokenType.NATIVE,
folksTokenId: FolksTokenId.AVAX,
poolId: TESTNET_POOLS[FolksTokenId.AVAX],
poolAddress: convertToGenericAddress(
"0x0922880C7e18112aB479E85Fc190Ba666c3F1020",
ChainType.EVM,
),
tokenAddress: null,
tokenDecimals: 18,
supportedLoanTypes: new Set([LoanType.DEPOSIT, LoanType.GENERAL]),
},
[FolksTokenId.ETH_eth_sep]: {
tokenType: TokenType.NATIVE,
folksTokenId: FolksTokenId.ETH_eth_sep,
poolId: TESTNET_POOLS[FolksTokenId.ETH_eth_sep],
poolAddress: convertToGenericAddress(
"0x58ad9F0e5Ced36401E36594C3265FA7475f24B3d",
ChainType.EVM,
),
tokenAddress: null,
tokenDecimals: 18,
supportedLoanTypes: new Set([LoanType.DEPOSIT, LoanType.GENERAL]),
},
[FolksTokenId.ETH_base_sep]: {
tokenType: TokenType.NATIVE,
folksTokenId: FolksTokenId.ETH_base_sep,
poolId: TESTNET_POOLS[FolksTokenId.ETH_base_sep],
poolAddress: convertToGenericAddress(
"0x9c0D98AFAfB59F3e30F1d3B3221D59ac3A159e0b",
ChainType.EVM,
),
tokenAddress: null,
tokenDecimals: 18,
supportedLoanTypes: new Set([LoanType.DEPOSIT, LoanType.GENERAL]),
},
[FolksTokenId.LINK_eth_sep]: {
tokenType: TokenType.ERC20,
folksTokenId: FolksTokenId.LINK_eth_sep,
poolId: TESTNET_POOLS[FolksTokenId.LINK_eth_sep],
poolAddress: convertToGenericAddress(
"0xc276f7e429F46346c668E1896e527baAD4D21414",
ChainType.EVM,
),
tokenAddress: null,
tokenDecimals: 18,
supportedLoanTypes: new Set([LoanType.DEPOSIT, LoanType.GENERAL]),
},
},
},
};
131 changes: 113 additions & 18 deletions src/common/constants/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import {
} from "../../chains/evm/common/constants/chain.js";
import { NetworkType, ChainType } from "../types/chain.js";
import { AdapterType } from "../types/message.js";
import { FolksTokenId, TokenType } from "../types/token.js";
import { convertToGenericAddress } from "../utils/address.js";

import { TESTNET_POOLS } from "./pool.js";

import type {
FolksChainId,
FolksChain,
Expand Down Expand Up @@ -67,80 +70,172 @@ export const SPOKE_CHAIN: Record<
[FOLKS_CHAIN_ID.AVALANCHE_FUJI]: {
folksChainId: FOLKS_CHAIN_ID.AVALANCHE_FUJI,
spokeCommonAddress: convertToGenericAddress(
"0x20BF45dc0375a60c7203655f1763A7165a889604",
"0x99477F62999AfbE2B0ca9CcAAdC2f2655F8B0C84",
ChainType.EVM,
),
bridgeRouterAddress: convertToGenericAddress(
"0x16ABF55447f61C6F9b811b9a29235339cE3Cb716",
"0xD0Cd0acEaf81fCf9C90ae60102eeC0E6C8095480",
ChainType.EVM,
),
adapters: {
[AdapterType.HUB]: convertToGenericAddress(
"0x52521e15f9C59aff55650011FAA45De233207bB8",
"0xB01296Ea267463FDe2fcE5Fad5067B4d875A44Ba",
ChainType.EVM,
),
},
tokens: {},
tokens: {
[FolksTokenId.USDC]: {
tokenType: TokenType.CIRCLE,
folksTokenId: FolksTokenId.USDC,
poolId: TESTNET_POOLS[FolksTokenId.USDC],
spokeAddress: convertToGenericAddress(
"0xC8ad4B23B4F07A27CDDAB1A8AE2Da54377f87426",
ChainType.EVM,
),
tokenAddress: convertToGenericAddress(
"0x5425890298aed601595a70ab815c96711a31bc65",
ChainType.EVM,
),
tokenDecimals: 6,
},
[FolksTokenId.AVAX]: {
tokenType: TokenType.NATIVE,
folksTokenId: FolksTokenId.AVAX,
poolId: TESTNET_POOLS[FolksTokenId.AVAX],
spokeAddress: convertToGenericAddress(
"0xF18F75595bA066efAdf4b24C7F263ba878C6B6f3",
ChainType.EVM,
),
tokenAddress: null,
tokenDecimals: 18,
},
},
},
[FOLKS_CHAIN_ID.ETHEREUM_SEPOLIA]: {
folksChainId: FOLKS_CHAIN_ID.ETHEREUM_SEPOLIA,
spokeCommonAddress: convertToGenericAddress(
"0x1217Fd6DDa71708FF3A8eB82602777379b59ba64",
"0x132E1514A0aa02601c9eEBE42F8fDbEf11874089",
ChainType.EVM,
),
bridgeRouterAddress: convertToGenericAddress(
"0xc676af388d4caBEb6c2a895412de1a448584377A",
"0x498C9827D5230ACB708710Bd9eB0e1019CC2D711",
ChainType.EVM,
),
adapters: {
[AdapterType.WORMHOLE_DATA]: convertToGenericAddress(
"0x2b1AB136105F05E2F91C3b175Dc1550b4C5EcC9F",
"0xeccb7067D8f0615eCe450236f2DF47b4dcc6ba8B",
ChainType.EVM,
),
[AdapterType.WORMHOLE_CCTP]: convertToGenericAddress(
"0xE562fdBcE03815b11F480b43DA2F4ce527cE526c",
"0xf1565F622FEd835E55aCEacE0D04A4c9786056D2",
ChainType.EVM,
),
[AdapterType.CCIP_DATA]: convertToGenericAddress(
"0x0513f9Cfe9B5Fb3c2948Da7C807B53202f3D3A54",
"0x084A113581915b3eF832E5d5bBdc30073001D4B2",
ChainType.EVM,
),
[AdapterType.CCIP_TOKEN]: convertToGenericAddress(
"0x61173406ac3bdF207b56743D35bC382D54199B18",
"0x59b5cB2c7413608e00CfFe074F2ac57165eB37e0",
ChainType.EVM,
),
},
tokens: {},
tokens: {
[FolksTokenId.USDC]: {
tokenType: TokenType.CIRCLE,
folksTokenId: FolksTokenId.USDC,
poolId: TESTNET_POOLS[FolksTokenId.USDC],
spokeAddress: convertToGenericAddress(
"0x71EEc2B912a3Cef6Bf134899D437Ba17Fc9588D2",
ChainType.EVM,
),
tokenAddress: convertToGenericAddress(
"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
ChainType.EVM,
),
tokenDecimals: 6,
},
[FolksTokenId.ETH_eth_sep]: {
tokenType: TokenType.NATIVE,
folksTokenId: FolksTokenId.ETH_eth_sep,
poolId: TESTNET_POOLS[FolksTokenId.ETH_eth_sep],
spokeAddress: convertToGenericAddress(
"0xD3743aBf2D83725c06b12EC2C97c6b9dAC0D8a6F",
ChainType.EVM,
),
tokenAddress: null,
tokenDecimals: 18,
},
[FolksTokenId.LINK_eth_sep]: {
tokenType: TokenType.ERC20,
folksTokenId: FolksTokenId.LINK_eth_sep,
poolId: TESTNET_POOLS[FolksTokenId.LINK_eth_sep],
spokeAddress: convertToGenericAddress(
"0xF85227ba19CC14e1b3FdcF9B2EBE199d64BE4CE9",
ChainType.EVM,
),
tokenAddress: convertToGenericAddress(
"0x514910771af9ca656af840dff83e8264ecf986ca",
ChainType.EVM,
),
tokenDecimals: 18,
},
},
},
[FOLKS_CHAIN_ID.BASE_SEPOLIA]: {
folksChainId: FOLKS_CHAIN_ID.BASE_SEPOLIA,
spokeCommonAddress: convertToGenericAddress(
"0x1217Fd6DDa71708FF3A8eB82602777379b59ba64",
"0x6Eac0286F42c8C0Cbc9997dB3b01b025EeD794f4",
ChainType.EVM,
),
bridgeRouterAddress: convertToGenericAddress(
"0xc676af388d4caBEb6c2a895412de1a448584377A",
"0xeccb7067D8f0615eCe450236f2DF47b4dcc6ba8B",
ChainType.EVM,
),
adapters: {
[AdapterType.WORMHOLE_DATA]: convertToGenericAddress(
"0xE562fdBcE03815b11F480b43DA2F4ce527cE526c",
"0xf1565F622FEd835E55aCEacE0D04A4c9786056D2",
ChainType.EVM,
),
[AdapterType.WORMHOLE_CCTP]: convertToGenericAddress(
"0x0513f9Cfe9B5Fb3c2948Da7C807B53202f3D3A54",
"0x084A113581915b3eF832E5d5bBdc30073001D4B2",
ChainType.EVM,
),
[AdapterType.CCIP_DATA]: convertToGenericAddress(
"0x61173406ac3bdF207b56743D35bC382D54199B18",
"0x59b5cB2c7413608e00CfFe074F2ac57165eB37e0",
ChainType.EVM,
),
[AdapterType.CCIP_TOKEN]: convertToGenericAddress(
"0xFD80E88Bab1dd4cC3B8604238Dba31d77a5bC128",
"0x132E1514A0aa02601c9eEBE42F8fDbEf11874089",
ChainType.EVM,
),
},
tokens: {},
tokens: {
[FolksTokenId.USDC]: {
tokenType: TokenType.CIRCLE,
folksTokenId: FolksTokenId.USDC,
poolId: TESTNET_POOLS[FolksTokenId.USDC],
spokeAddress: convertToGenericAddress(
"0x6789da551F420bfb607Fffb43bf8936f9dfb7d4C",
ChainType.EVM,
),
tokenAddress: convertToGenericAddress(
"0x036CbD53842c5426634e7929541eC2318f3dCF7e",
ChainType.EVM,
),
tokenDecimals: 6,
},
[FolksTokenId.ETH_base_sep]: {
tokenType: TokenType.NATIVE,
folksTokenId: FolksTokenId.ETH_base_sep,
poolId: TESTNET_POOLS[FolksTokenId.ETH_base_sep],
spokeAddress: convertToGenericAddress(
"0x457f30Bc85E885e4D519975C1dd87F397d4817B7",
ChainType.EVM,
),
tokenAddress: null,
tokenDecimals: 18,
},
},
},
},
};
13 changes: 13 additions & 0 deletions src/common/constants/pool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { FolksTokenId } from "../types/token.js";

export const MAINNET_POOLS = {} as const satisfies Partial<
Record<FolksTokenId, number>
>;

export const TESTNET_POOLS = {
[FolksTokenId.USDC]: 128,
[FolksTokenId.AVAX]: 129,
[FolksTokenId.ETH_eth_sep]: 131,
[FolksTokenId.ETH_base_sep]: 132,
[FolksTokenId.LINK_eth_sep]: 133,
} as const satisfies Partial<Record<FolksTokenId, number>>;
5 changes: 4 additions & 1 deletion src/common/types/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import type { GenericAddress } from "./chain.js";

export enum FolksTokenId {
USDC = "USDC",
ETH = "ETH",
AVAX = "AVAX",
ETH_eth_sep = "ETH_eth_sep",
ETH_base_sep = "ETH_base_sep",
LINK_eth_sep = "LINK_eth_sep",
}

export enum TokenType {
Expand Down

0 comments on commit 52b817c

Please sign in to comment.