UNPKG

@malda-protocol/protocol-config

Version:

Centralized contract addresses, constants, and token configurations for Malda Protocol

68 lines (67 loc) 2.43 kB
import { z } from 'zod'; import { mainnet, base, linea, sepolia, lineaSepolia, optimismSepolia } from '@wagmi/core/chains'; // Type-safe asset symbols definition export const ASSET_SYMBOLS = { USDC: 'USDC', USDT: 'USDT', WETH: 'WETH', WBTC: 'WBTC', WSTETH: 'wstETH', EZETH: 'ezETH', WEETH: 'weETH', WRSETH: 'wrsETH / rsETH', }; // All supported chains arrays export const PRODUCTION_CHAINS = [mainnet, base, linea]; export const TESTNET_CHAINS = [sepolia, lineaSepolia, optimismSepolia]; export const ALL_CHAINS = [...PRODUCTION_CHAINS, ...TESTNET_CHAINS]; // Zod schemas for runtime validation export const AddressSchema = z.string().regex(/^0x[a-fA-F0-9]{40}$/, 'Invalid Ethereum address'); export const AssetSymbolSchema = z.enum(['USDC', 'USDT', 'WETH', 'WBTC', 'wstETH', 'ezETH', 'weETH', 'wrsETH / rsETH']); export const UnderlyingAssetSchema = z.object({ symbol: AssetSymbolSchema, name: z.string().min(1), decimals: z.number().int().min(0).max(18), addresses: z.record(z.number(), AddressSchema), }); export const ProtocolAssetSchema = UnderlyingAssetSchema.extend({ mToken: AddressSchema, jumpRateModel: AddressSchema, nonGlobalAsset: z.boolean().optional(), supportedChainIds: z.array(z.number()).optional(), }); export const ProtocolConfigSchema = z.object({ hostChainId: z.number(), operator: AddressSchema, priceOracle: AddressSchema, blocksPerYear: z.number().positive(), gasHelper: AddressSchema, migrator: AddressSchema, weth_mToken: AddressSchema, referralSigning: AddressSchema, extensionChains: z .record(z.number(), z.object({ operator: AddressSchema.optional(), priceOracle: AddressSchema.optional(), })) .optional(), assets: z.array(ProtocolAssetSchema), supportedChainIds: z.array(z.number()), }); export const TokenSchema = z.object({ name: z.string().min(1), symbol: AssetSymbolSchema, decimals: z.number().int().min(0).max(18), address: AddressSchema, underlyingAddresses: z.record(z.number(), AddressSchema), supportedChainIds: z.array(z.number()).optional(), }); // Export schemas collection export const schemas = { Address: AddressSchema, AssetSymbol: AssetSymbolSchema, UnderlyingAsset: UnderlyingAssetSchema, ProtocolAsset: ProtocolAssetSchema, ProtocolConfig: ProtocolConfigSchema, Token: TokenSchema, };