Skip to content

Commit

Permalink
feat: arbitrum (#192)
Browse files Browse the repository at this point in the history
Added Arbitrum chain with ETH, ARB and SolvBTC
  • Loading branch information
palace22 authored Nov 5, 2024
1 parent 41c3117 commit 9c5609e
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/forty-buttons-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@folks-finance/xchain-sdk": patch
---

Added Arbitrum chain with ETH, ARB and SolvBTC
7 changes: 6 additions & 1 deletion src/chains/evm/common/constants/chain.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
arbitrum,
arbitrumSepolia,
avalanche,
avalancheFuji,
Expand All @@ -13,7 +14,7 @@ import {
import type { EvmChainName, EvmFolksChainId } from "../types/chain.js";
import type { Chain } from "viem";

export const MAINNET_EVM_CHAIN_NAMES = ["AVALANCHE", "ETHEREUM", "BASE", "BSC"] as const;
export const MAINNET_EVM_CHAIN_NAMES = ["AVALANCHE", "ETHEREUM", "BASE", "BSC", "ARBITRUM"] as const;
export const TESTNET_EVM_CHAIN_NAMES = [
"AVALANCHE_FUJI",
"ETHEREUM_SEPOLIA",
Expand All @@ -28,6 +29,7 @@ export const MAINNET_EVM_CHAIN_ID = {
ETHEREUM: mainnet.id,
BASE: base.id,
BSC: bsc.id,
ARBITRUM: arbitrum.id,
} as const;

export const TESTNET_EVM_CHAIN_ID = {
Expand All @@ -48,6 +50,7 @@ export const MAINNET_EVM_FOLKS_CHAIN_ID = {
ETHEREUM: 101,
BASE: 102,
BSC: 103,
ARBITRUM: 104,
} as const;

export const TESTNET_EVM_FOLKS_CHAIN_ID = {
Expand All @@ -68,6 +71,7 @@ export const MAINNET_CHAIN_VIEM = {
[EVM_FOLKS_CHAIN_ID.ETHEREUM]: mainnet,
[EVM_FOLKS_CHAIN_ID.BASE]: base,
[EVM_FOLKS_CHAIN_ID.BSC]: bsc,
[EVM_FOLKS_CHAIN_ID.ARBITRUM]: arbitrum,
} as const;
export const TESTNET_CHAIN_VIEM = {
[EVM_FOLKS_CHAIN_ID.AVALANCHE_FUJI]: avalancheFuji,
Expand All @@ -86,6 +90,7 @@ export const MAINNET_CHAIN_NODE = {
[EVM_FOLKS_CHAIN_ID.ETHEREUM]: [...mainnet.rpcUrls.default.http],
[EVM_FOLKS_CHAIN_ID.BASE]: [...base.rpcUrls.default.http],
[EVM_FOLKS_CHAIN_ID.BSC]: [...bsc.rpcUrls.default.http],
[EVM_FOLKS_CHAIN_ID.ARBITRUM]: [...arbitrum.rpcUrls.default.http],
};
export const TESTNET_CHAIN_NODE = {
[EVM_FOLKS_CHAIN_ID.AVALANCHE_FUJI]: [...avalancheFuji.rpcUrls.default.http],
Expand Down
16 changes: 16 additions & 0 deletions src/chains/evm/common/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ export const CONTRACT_SLOT: Partial<
},
},
},
[EVM_FOLKS_CHAIN_ID.ARBITRUM]: {
erc20: {
[MAINNET_FOLKS_TOKEN_ID.USDC]: {
balanceOf: 9n,
allowance: 10n,
},
[MAINNET_FOLKS_TOKEN_ID.ARB]: {
balanceOf: 51n,
allowance: 52n,
},
[MAINNET_FOLKS_TOKEN_ID.SolvBTC]: {
balanceOf: BigInt("37439836327923360225337895871394760624280537466773280374265222508165906222592"),
allowance: BigInt("37439836327923360225337895871394760624280537466773280374265222508165906222593"),
},
},
},
[EVM_FOLKS_CHAIN_ID.AVALANCHE_FUJI]: {
erc20: {
[TESTNET_FOLKS_TOKEN_ID.USDC]: {
Expand Down
20 changes: 20 additions & 0 deletions src/chains/evm/hub/constants/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,26 @@ export const HUB_CHAIN: Record<NetworkType, HubChain> = {
poolAddress: convertToGenericAddress("0xC2FD40D9Ec4Ae7e71068652209EB75258809e131" as EvmAddress, ChainType.EVM),
supportedLoanTypes: new Set([LoanTypeId.DEPOSIT, LoanTypeId.GENERAL]),
},
[MAINNET_FOLKS_TOKEN_ID.ETH_arb]: {
token: {
type: TokenType.NATIVE,
decimals: 18,
},
folksTokenId: MAINNET_FOLKS_TOKEN_ID.ETH_arb,
poolId: MAINNET_POOLS[MAINNET_FOLKS_TOKEN_ID.ETH_arb],
poolAddress: convertToGenericAddress("0x44E0d0809AF8Ee37BFb1A4e75D5EF5B96F6346A3" as EvmAddress, ChainType.EVM),
supportedLoanTypes: new Set([LoanTypeId.DEPOSIT, LoanTypeId.GENERAL]),
},
[MAINNET_FOLKS_TOKEN_ID.ARB]: {
token: {
type: TokenType.ERC20,
decimals: 18,
},
folksTokenId: MAINNET_FOLKS_TOKEN_ID.ARB,
poolId: MAINNET_POOLS[MAINNET_FOLKS_TOKEN_ID.ARB],
poolAddress: convertToGenericAddress("0x1177A3c2CccDb9c50D52Fc2D30a13b2c3C40BCF4" as EvmAddress, ChainType.EVM),
supportedLoanTypes: new Set([LoanTypeId.DEPOSIT, LoanTypeId.GENERAL]),
},
[MAINNET_FOLKS_TOKEN_ID.SolvBTC]: {
token: {
type: TokenType.CROSS_CHAIN,
Expand Down
92 changes: 92 additions & 0 deletions src/common/constants/chain.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
arbitrum,
arbitrumSepolia,
avalanche,
avalancheFuji,
Expand Down Expand Up @@ -71,6 +72,13 @@ export const FOLKS_CHAIN: Record<NetworkType, Partial<Record<FolksChainId, Folks
chainId: bsc.id,
network: NetworkType.MAINNET,
},
[FOLKS_CHAIN_ID.ARBITRUM]: {
chainType: ChainType.EVM,
folksChainId: FOLKS_CHAIN_ID.ARBITRUM,
chainName: arbitrum.name,
chainId: arbitrum.id,
network: NetworkType.MAINNET,
},
} satisfies Record<MainnetFolksChainId, FolksChain>,
[NetworkType.TESTNET]: {
[FOLKS_CHAIN_ID.AVALANCHE_FUJI]: {
Expand Down Expand Up @@ -458,6 +466,90 @@ export const SPOKE_CHAIN: Record<NetworkType, Partial<Record<FolksChainId, Spoke
},
},
},
[FOLKS_CHAIN_ID.ARBITRUM]: {
folksChainId: FOLKS_CHAIN_ID.ARBITRUM,
spokeCommonAddress: convertToGenericAddress(
"0x57D77FD37670e22188d1c92D7cEc931bccf074A4" as EvmAddress,
ChainType.EVM,
),
bridgeRouterAddress: convertToGenericAddress(
"0x4Db12F554623E4B0b3F5bAcF1c8490D4493380A5" as EvmAddress,
ChainType.EVM,
),
adapters: {
[AdapterType.WORMHOLE_DATA]: convertToGenericAddress(
"0x12Db9758c4D9902334C523b94e436258EB54156f" as EvmAddress,
ChainType.EVM,
),
[AdapterType.WORMHOLE_CCTP]: convertToGenericAddress(
"0x802063A23E78D0f5D158feaAc605028Ee490b03b" as EvmAddress,
ChainType.EVM,
),
[AdapterType.CCIP_DATA]: convertToGenericAddress(
"0x7218Bd1050D41A9ECfc517abdd294FB8116aEe81" as EvmAddress,
ChainType.EVM,
),
[AdapterType.CCIP_TOKEN]: convertToGenericAddress(
"0x0700B2cB26688C035bd5dBbdA070Be408c20779c" as EvmAddress,
ChainType.EVM,
),
},
tokens: {
[MAINNET_FOLKS_TOKEN_ID.USDC]: {
token: {
type: TokenType.CROSS_CHAIN,
adapters: [AdapterType.WORMHOLE_CCTP, AdapterType.CCIP_TOKEN],
address: convertToGenericAddress("0xaf88d065e77c8cC2239327C5EDb3A432268e5831" as EvmAddress, ChainType.EVM),
decimals: 6,
},
folksTokenId: MAINNET_FOLKS_TOKEN_ID.USDC,
poolId: MAINNET_POOLS[MAINNET_FOLKS_TOKEN_ID.USDC],
spokeAddress: convertToGenericAddress(
"0xF4c542518320F09943C35Db6773b2f9FeB2F847e" as EvmAddress,
ChainType.EVM,
),
},
[MAINNET_FOLKS_TOKEN_ID.ETH_arb]: {
token: {
type: TokenType.NATIVE,
decimals: 18,
},
folksTokenId: MAINNET_FOLKS_TOKEN_ID.ETH_arb,
poolId: MAINNET_POOLS[MAINNET_FOLKS_TOKEN_ID.ETH_arb],
spokeAddress: convertToGenericAddress(
"0x37d761883a01e9F0B0d7fe59EEC8c21D94393CDD" as EvmAddress,
ChainType.EVM,
),
},
[MAINNET_FOLKS_TOKEN_ID.ARB]: {
token: {
type: TokenType.ERC20,
address: convertToGenericAddress("0x912CE59144191C1204E64559FE8253a0e49E6548" as EvmAddress, ChainType.EVM),
decimals: 18,
},
folksTokenId: MAINNET_FOLKS_TOKEN_ID.ARB,
poolId: MAINNET_POOLS[MAINNET_FOLKS_TOKEN_ID.ARB],
spokeAddress: convertToGenericAddress(
"0x1b2a8d56967d00700DD5C94E27B1a116a1deF8Df" as EvmAddress,
ChainType.EVM,
),
},
[MAINNET_FOLKS_TOKEN_ID.SolvBTC]: {
token: {
type: TokenType.CROSS_CHAIN,
adapters: [AdapterType.CCIP_TOKEN],
address: convertToGenericAddress("0x3647c54c4c2C65bC7a2D63c0Da2809B399DBBDC0" as EvmAddress, ChainType.EVM),
decimals: 18,
},
folksTokenId: MAINNET_FOLKS_TOKEN_ID.SolvBTC,
poolId: MAINNET_POOLS[MAINNET_FOLKS_TOKEN_ID.SolvBTC],
spokeAddress: convertToGenericAddress(
"0x531490B7674ef239C9FEC39d2Cf3Cc10645d14d4" as EvmAddress,
ChainType.EVM,
),
},
},
},
} satisfies Record<MainnetFolksChainId, SpokeChain>,
[NetworkType.TESTNET]: {
[FOLKS_CHAIN_ID.AVALANCHE_FUJI]: {
Expand Down
8 changes: 8 additions & 0 deletions src/common/constants/gmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export const WORMHOLE_DATA: Record<FolksChainId, WormholeData> = {
wormholeChainId: 4,
wormholeRelayer: convertToGenericAddress("0x27428DD2d3DD32A4D7f7C497eAaa23130d894911" as EvmAddress, ChainType.EVM),
},
[FOLKS_CHAIN_ID.ARBITRUM]: {
wormholeChainId: 23,
wormholeRelayer: convertToGenericAddress("0x27428DD2d3DD32A4D7f7C497eAaa23130d894911" as EvmAddress, ChainType.EVM),
},
[FOLKS_CHAIN_ID.AVALANCHE_FUJI]: {
wormholeChainId: 6,
wormholeRelayer: convertToGenericAddress("0xA3cF45939bD6260bcFe3D66bc73d60f19e49a8BB" as EvmAddress, ChainType.EVM),
Expand Down Expand Up @@ -63,6 +67,10 @@ export const CCIP_DATA: Record<FolksChainId, CCIPData> = {
ccipChainId: BigInt("11344663589394136015"),
ccipRouter: convertToGenericAddress("0x34B03Cb9086d7D758AC55af71584F81A598759FE" as EvmAddress, ChainType.EVM),
},
[FOLKS_CHAIN_ID.ARBITRUM]: {
ccipChainId: BigInt("4949039107694359620"),
ccipRouter: convertToGenericAddress("0x141fa059441E0ca23ce184B6A78bafD2A517DdE8" as EvmAddress, ChainType.EVM),
},
[FOLKS_CHAIN_ID.AVALANCHE_FUJI]: {
ccipChainId: BigInt("14767482510784806043"),
ccipRouter: convertToGenericAddress("0xF694E193200268f9a4868e4Aa017A0118C9a8177" as EvmAddress, ChainType.EVM),
Expand Down
2 changes: 2 additions & 0 deletions src/common/constants/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const MAINNET_POOLS = {
[MAINNET_FOLKS_TOKEN_ID.BNB]: 10,
[MAINNET_FOLKS_TOKEN_ID.ETHB_bsc]: 11,
[MAINNET_FOLKS_TOKEN_ID.BTCB_bsc]: 12,
[MAINNET_FOLKS_TOKEN_ID.ETH_arb]: 13,
[MAINNET_FOLKS_TOKEN_ID.ARB]: 14,
[MAINNET_FOLKS_TOKEN_ID.SolvBTC]: 15,
} as const satisfies Record<MainnetFolksTokenId, number>;

Expand Down
2 changes: 2 additions & 0 deletions src/common/types/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const MAINNET_FOLKS_TOKEN_ID = {
BNB: "BNB",
ETHB_bsc: "ETHB_bsc",
BTCB_bsc: "BTCB_bsc",
ETH_arb: "ETH_arb",
ARB: "ARB",
SolvBTC: "SolvBTC",
} as const;
export type MainnetFolksTokenId = (typeof MAINNET_FOLKS_TOKEN_ID)[keyof typeof MAINNET_FOLKS_TOKEN_ID];
Expand Down

0 comments on commit 9c5609e

Please sign in to comment.