Skip to content
Open
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
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"react-toastify": "10.0.5",
"react-use": "17.3.1",
"recharts": "2.12.7",
"regenerator-runtime": "0.14.1",
"reselect": "5.1.0",
"sass": "1.55.0",
"shallowequal": "1.1.0",
Expand Down Expand Up @@ -143,6 +144,7 @@
"@typechain/ethers-v6": "0.5.1",
"@types/react-calendar": "4.1.0",
"@types/react-date-range": "1.4.9",
"@types/regenerator-runtime": "^0",
"@typescript-eslint/eslint-plugin": "8.26.1",
"@typescript-eslint/parser": "8.26.1",
"@vitejs/plugin-react": "4.3.1",
Expand Down Expand Up @@ -189,5 +191,5 @@
"prettier --write"
]
},
"packageManager": "yarn@3.1.0"
"packageManager": "yarn@4.12.0"
}
26 changes: 26 additions & 0 deletions sdk/src/configs/batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
ARBITRUM_SEPOLIA,
AVALANCHE,
AVALANCHE_FUJI,
BASE_SEPOLIA,
BOTANIX,
LOCALHOST,
SOURCE_BASE_MAINNET,
SOURCE_OPTIMISM_SEPOLIA,
SOURCE_SEPOLIA,
Expand Down Expand Up @@ -93,6 +95,18 @@ export const BATCH_CONFIGS: Record<
},
},
},
[BASE_SEPOLIA]: {
http: {
batchSize: 40,
wait: 100,
},
client: {
multicall: {
batchSize: 1024 * 1024,
wait: 100,
},
},
},
[SOURCE_OPTIMISM_SEPOLIA]: {
http: {
batchSize: 40,
Expand All @@ -117,4 +131,16 @@ export const BATCH_CONFIGS: Record<
},
},
},
[LOCALHOST]: {
http: {
batchSize: 0,
wait: 0,
},
client: {
multicall: {
batchSize: 1024 * 1024,
wait: 0,
},
},
},
};
3 changes: 3 additions & 0 deletions sdk/src/configs/chainIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ export const ARBITRUM_SEPOLIA = 421614;
// Testnet source
export const SOURCE_OPTIMISM_SEPOLIA = 11155420;
export const SOURCE_SEPOLIA = 11155111;
// Local development
export const LOCALHOST = 31337;
export const BASE_SEPOLIA = 84532;
75 changes: 69 additions & 6 deletions sdk/src/configs/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import {
avalancheFuji,
base,
Chain,
localhost as viemLocalhost,
optimismSepolia,
sepolia,
baseSepolia,
} from "viem/chains";

import type { GasLimitsConfig } from "types/fees";
Expand All @@ -22,6 +24,8 @@ import {
SOURCE_OPTIMISM_SEPOLIA,
SOURCE_SEPOLIA,
SOURCE_BASE_MAINNET,
BASE_SEPOLIA,
LOCALHOST,
} from "./chainIds";
export {
AVALANCHE,
Expand All @@ -33,20 +37,24 @@ export {
SOURCE_OPTIMISM_SEPOLIA,
SOURCE_SEPOLIA,
SOURCE_BASE_MAINNET,
BASE_SEPOLIA,
LOCALHOST,
};

export const CONTRACTS_CHAIN_IDS: ContractsChainId[] = [ARBITRUM, AVALANCHE, BOTANIX];
export const CONTRACTS_CHAIN_IDS_DEV: ContractsChainId[] = [...CONTRACTS_CHAIN_IDS, AVALANCHE_FUJI, ARBITRUM_SEPOLIA];
export const CONTRACTS_CHAIN_IDS_DEV: ContractsChainId[] = [...CONTRACTS_CHAIN_IDS, AVALANCHE_FUJI, ARBITRUM_SEPOLIA, LOCALHOST];

export type ContractsChainId =
| typeof ARBITRUM
| typeof AVALANCHE
| typeof AVALANCHE_FUJI
| typeof BOTANIX
| typeof ARBITRUM_SEPOLIA;
| typeof ARBITRUM_SEPOLIA
| typeof BASE_SEPOLIA
| typeof LOCALHOST;

export type SettlementChainId = typeof ARBITRUM_SEPOLIA | typeof ARBITRUM | typeof AVALANCHE;
export type SourceChainId = typeof SOURCE_OPTIMISM_SEPOLIA | typeof SOURCE_SEPOLIA | typeof SOURCE_BASE_MAINNET;
export type SettlementChainId = typeof ARBITRUM_SEPOLIA | typeof ARBITRUM | typeof AVALANCHE | typeof BASE_SEPOLIA;
export type SourceChainId = typeof SOURCE_OPTIMISM_SEPOLIA | typeof SOURCE_SEPOLIA | typeof SOURCE_BASE_MAINNET | typeof BASE_SEPOLIA;
export type AnyChainId = ContractsChainId | SettlementChainId | SourceChainId;

export type ChainName =
Expand All @@ -57,7 +65,9 @@ export type ChainName =
| "Optimism Sepolia"
| "Sepolia"
| "Botanix"
| "Base";
| "Base"
| "Base Sepolia"
| "Localhost";

export const CHAIN_NAMES_MAP: Record<AnyChainId, ChainName> = {
[ARBITRUM]: "Arbitrum",
Expand All @@ -68,6 +78,8 @@ export const CHAIN_NAMES_MAP: Record<AnyChainId, ChainName> = {
[SOURCE_OPTIMISM_SEPOLIA]: "Optimism Sepolia",
[SOURCE_SEPOLIA]: "Sepolia",
[SOURCE_BASE_MAINNET]: "Base",
[BASE_SEPOLIA]: "Base Sepolia",
[LOCALHOST]: "Localhost",
};

export const HIGH_EXECUTION_FEES_MAP: Record<ContractsChainId, number> = {
Expand All @@ -76,6 +88,8 @@ export const HIGH_EXECUTION_FEES_MAP: Record<ContractsChainId, number> = {
[AVALANCHE_FUJI]: 5, // 5 USD
[BOTANIX]: 5, // 5 USD
[ARBITRUM_SEPOLIA]: 5, // 5 USD
[BASE_SEPOLIA]: 5, // 5 USD
[LOCALHOST]: 5, // 5 USD
};

// added to maxPriorityFeePerGas
Expand Down Expand Up @@ -103,13 +117,17 @@ export const MAX_PRIORITY_FEE_PER_GAS_MAP: Record<ContractsChainId, bigint | und
[AVALANCHE_FUJI]: 1500000000n,
[ARBITRUM_SEPOLIA]: 1500000000n,
[BOTANIX]: 7n,
[BASE_SEPOLIA]: 1500000000n,
[LOCALHOST]: 1500000000n,
};

export const EXCESSIVE_EXECUTION_FEES_MAP: Partial<Record<ContractsChainId, number>> = {
[ARBITRUM]: 10, // 10 USD
[AVALANCHE]: 10, // 10 USD
[AVALANCHE_FUJI]: 10, // 10 USD
[BOTANIX]: 10, // 10 USD
[BASE_SEPOLIA]: 10, // 10 USD
[LOCALHOST]: 10, // 10 USD
};

// avoid botanix gas spikes when chain is not actively used
Expand All @@ -119,6 +137,7 @@ export const MIN_EXECUTION_FEE_USD: Partial<Record<ContractsChainId, bigint | un
[AVALANCHE]: undefined,
[AVALANCHE_FUJI]: undefined,
[BOTANIX]: 1000000000000000000000000000n, // 1e27 $0.001
[BASE_SEPOLIA]: 1000000000000000000000000000n, // 1e27 $0.001
};

// added to gasPrice
Expand Down Expand Up @@ -173,6 +192,26 @@ export const botanix: Chain = defineChain({
},
});

export const localhost: Chain = defineChain({
id: LOCALHOST,
name: "Localhost",
nativeCurrency: {
name: "Ether",
symbol: "ETH",
decimals: 18,
},
rpcUrls: {
default: {
http: ["http://127.0.0.1:8545"],
},
},
contracts: {
multicall3: {
address: "0xCD8a1C3ba11CF5ECfa6267617243239504a98d90",
},
},
});

const VIEM_CHAIN_BY_CHAIN_ID: Record<AnyChainId, Chain> = {
[AVALANCHE_FUJI]: avalancheFuji,
[ARBITRUM]: arbitrum,
Expand All @@ -182,6 +221,8 @@ const VIEM_CHAIN_BY_CHAIN_ID: Record<AnyChainId, Chain> = {
[SOURCE_OPTIMISM_SEPOLIA]: optimismSepolia,
[SOURCE_SEPOLIA]: sepolia,
[SOURCE_BASE_MAINNET]: base,
[BASE_SEPOLIA]: baseSepolia,
[LOCALHOST]: localhost,
};

export function getChainName(chainId: number): ChainName {
Expand All @@ -205,7 +246,7 @@ export function isContractsChain(chainId: number, dev = false): chainId is Contr
}

export function isTestnetChain(chainId: number): boolean {
return [AVALANCHE_FUJI, ARBITRUM_SEPOLIA].includes(chainId);
return [AVALANCHE_FUJI, ARBITRUM_SEPOLIA, LOCALHOST].includes(chainId);
}

export const EXECUTION_FEE_CONFIG_V2: {
Expand All @@ -230,10 +271,18 @@ export const EXECUTION_FEE_CONFIG_V2: {
shouldUseMaxPriorityFeePerGas: false,
defaultBufferBps: 1000, // 10%
},
[BASE_SEPOLIA]: {
shouldUseMaxPriorityFeePerGas: false,
defaultBufferBps: 1000, // 10%
},
[BOTANIX]: {
shouldUseMaxPriorityFeePerGas: true,
defaultBufferBps: 3000, // 30%
},
[LOCALHOST]: {
shouldUseMaxPriorityFeePerGas: false,
defaultBufferBps: 1000, // 10%
},
};

type StaticGasLimitsConfig = Pick<
Expand Down Expand Up @@ -281,4 +330,18 @@ export const GAS_LIMITS_STATIC_CONFIG: Record<ContractsChainId, StaticGasLimitsC
tokenPermitGasLimit: 90_000n,
gmxAccountCollateralGasLimit: 0n,
},
[LOCALHOST]: {
createOrderGasLimit: 1_000_000n,
updateOrderGasLimit: 800_000n,
cancelOrderGasLimit: 700_000n,
tokenPermitGasLimit: 90_000n,
gmxAccountCollateralGasLimit: 0n,
},
[BASE_SEPOLIA]: {
createOrderGasLimit: 1_000_000n,
updateOrderGasLimit: 800_000n,
cancelOrderGasLimit: 700_000n,
tokenPermitGasLimit: 90_000n,
gmxAccountCollateralGasLimit: 0n,
},
};
Loading