UNPKG

@moonwell-fi/moonwell-sdk

Version:

TypeScript Interface for Moonwell

223 lines 9.05 kB
import { type Address, type Chain, type ChainContract, type Hex, type Narrow, type Prettify, type PublicClient, type Transport } from "viem"; import type { GovernanceToken } from "../definitions/governance.js"; import type { ChainLinkOracleContractReturnType, ComptrollerContractReturnType, CoreRouterContractReturnType, CoreViewsContractReturnType, GovernanceTokenContractReturnType, GovernorContractReturnType, MarketTokenContractReturnType, MaximillionContractReturnType, MorphoBlueContractReturnType, MorphoBundlerContractReturnType, MorphoPublicAllocatorContractReturnType, MorphoVaultContractReturnType, MorphoViewsContractReturnType, MultiRewardDistributorContractReturnType, MultichainGovernorContractReturnType, StakingTokenContractReturnType, TemporalGovernorContractReturnType, TokenContractReturnType, TokenSaleContractReturnType, VoteCollectorContractReturnType, WrappedNativeTokenContractReturnType } from "./contracts.js"; export type TokenConfig = { address: `0x${string}`; decimals: number; name: string; symbol: string; }; export type VaultConfig<tokens> = { vaultToken: keyof tokens; underlyingToken: keyof tokens; campaignId?: string; multiReward?: Address; version?: 1 | 2; deprecated?: boolean; v1VaultKey?: keyof tokens; }; export type MarketConfig<tokens> = { marketToken: keyof tokens; underlyingToken: keyof tokens; deprecated?: boolean; badDebt?: boolean; }; export type MorphoMarketConfig<tokens> = { collateralToken: keyof tokens; loanToken: keyof tokens; id: Hex; deprecated?: boolean; }; export type ContractConfig<tokens> = { stakingToken?: keyof tokens; governanceToken?: keyof tokens; wrappedNativeToken?: keyof tokens; comptroller?: Address; maximillion?: Address; views?: Address; tokenSale?: Address; morphoViews?: Address; morphoViewsV2?: Address; multiRewardDistributor?: Address; temporalGovernor?: Address; voteCollector?: Address; governor?: Address; multichainGovernor?: Address; oracle?: Address; router?: Address; morphoBlue?: Address; morphoBaseBundler?: Address; morphoBundler?: Address; morphoPublicAllocator?: Address; }; export type ContractsConfigReturnType = { stakingToken: TokenContractReturnType; governanceToken: TokenContractReturnType; wrappedNativeToken: TokenContractReturnType; comptroller: ComptrollerContractReturnType; maximillion: MaximillionContractReturnType; views: CoreViewsContractReturnType; tokenSale: TokenSaleContractReturnType; morphoViews: MorphoViewsContractReturnType; morphoViewsV2: MorphoViewsContractReturnType; multiRewardDistributor: MultiRewardDistributorContractReturnType; temporalGovernor: TemporalGovernorContractReturnType; voteCollector: VoteCollectorContractReturnType; governor: GovernorContractReturnType; multichainGovernor: MultichainGovernorContractReturnType; oracle: ChainLinkOracleContractReturnType; router: CoreRouterContractReturnType; morphoBlue: MorphoBlueContractReturnType; morphoBaseBundler: MorphoBundlerContractReturnType; morphoBundler: MorphoBundlerContractReturnType; morphoPublicAllocator: MorphoPublicAllocatorContractReturnType; }; type EnvironmentContractsReturnType = { stakingToken: StakingTokenContractReturnType; wrappedNativeToken: WrappedNativeTokenContractReturnType; governanceToken: GovernanceTokenContractReturnType; comptroller: ComptrollerContractReturnType; maximillion: MaximillionContractReturnType; views: CoreViewsContractReturnType; tokenSale: TokenSaleContractReturnType; morphoViews: MorphoViewsContractReturnType; morphoViewsV2: MorphoViewsContractReturnType; multiRewardDistributor: MultiRewardDistributorContractReturnType; temporalGovernor: TemporalGovernorContractReturnType; voteCollector: VoteCollectorContractReturnType; governor: GovernorContractReturnType; multichainGovernor: MultichainGovernorContractReturnType; oracle: ChainLinkOracleContractReturnType; router: CoreRouterContractReturnType; morphoBlue: MorphoBlueContractReturnType; morphoBundler: MorphoBundlerContractReturnType; morphoBaseBundler: MorphoBundlerContractReturnType; morphoPublicAllocator: MorphoPublicAllocatorContractReturnType; }; type EnvironmentContracts<contracts> = { [K in keyof contracts as K extends keyof EnvironmentContractsReturnType ? K : never]: K extends keyof EnvironmentContractsReturnType ? EnvironmentContractsReturnType[K] : never; }; export type CustomConfigType = { morpho?: { minimalDeployment?: boolean; apiUrl?: string; rewardsApiUrl?: string; }; governance?: { token: GovernanceToken; chainIds: number[]; proposalIdOffset?: number; snapshotEnsName?: string; }; multiRewarder?: { rewardToken: string; }[]; wormhole?: { chainId: number; tokenBridge?: ChainContract | undefined; }; socket?: { gateway?: ChainContract | undefined; }; xWELL?: { bridgeAdapter?: ChainContract | undefined; }; }; export type GetContractConfig<tokens, contract> = contract extends {} ? contract : keyof tokens; export type TokensConfig<tokens> = {} extends tokens ? {} : { [tokenName in keyof tokens]: TokenConfig; }; export type VaultsConfig<vaults, tokens> = {} extends vaults ? {} : { [name in keyof tokens]?: VaultConfig<tokens>; }; export type MarketsConfig<markets, tokens> = {} extends markets ? {} : { [name in keyof tokens]?: MarketConfig<tokens>; }; export type MorphoMarketsConfig<markets, tokens> = {} extends markets ? {} : { [name in keyof markets]: MorphoMarketConfig<tokens>; }; export type ContractsConfig<contracts, tokens> = {} extends contracts ? {} : { [name in keyof ContractConfig<tokens>]?: ContractConfig<tokens>[name]; }; export type CustomConfig<custom> = {} extends custom ? {} : { [name in keyof CustomConfigType]?: CustomConfigType[name]; }; export declare const createTokenConfig: <const tokens>(tokens: TokensConfig<Narrow<tokens>>) => Prettify<tokens>; export declare const createVaultConfig: <const tokens, const vaults>(config: { tokens: TokensConfig<tokens>; vaults: VaultsConfig<vaults, tokens>; }) => Prettify<vaults>; export declare const createMarketConfig: <const tokens, const markets>(config: { tokens: TokensConfig<tokens>; markets: MarketsConfig<markets, tokens>; }) => Prettify<markets>; export declare const createMorphoMarketConfig: <const tokens, const markets>(config: { tokens: TokensConfig<tokens>; markets: MorphoMarketsConfig<markets, tokens>; }) => Prettify<markets>; export declare const createContractsConfig: <const tokens, const contracts>(config: { tokens: TokensConfig<tokens>; contracts: ContractsConfig<contracts, tokens>; }) => Prettify<contracts>; export declare const createCustomConfig: <custom>(custom: CustomConfig<custom>) => Prettify<custom>; export declare const createEnvironmentConfig: <tokens, markets, vaults, morphoMarkets, contracts, custom>(config: { key: string; name: string; chain: Chain; transport: Transport; indexerUrl?: string; governanceIndexerUrl: string; lunarIndexerUrl?: string; onError?: (error: unknown, context: { source: string; chainId: number; }) => void; tokens: TokensConfig<tokens>; markets: MarketsConfig<markets, tokens>; vaults: VaultsConfig<vaults, tokens>; morphoMarkets: MorphoMarketsConfig<morphoMarkets, tokens>; contracts: ContractsConfig<contracts, tokens>; custom: CustomConfig<custom>; }) => Environment<tokens, markets, vaults, contracts, custom>; export type Environment<tokens = any, markets = any, vaults = any, contracts = Partial<ContractsConfigReturnType>, custom = CustomConfigType> = { key: string; name: string; chainId: number; chain: Chain; indexerUrl?: string; governanceIndexerUrl: string; lunarIndexerUrl?: string; onError?: (error: unknown, context: { source: string; chainId: number; }) => void; tokens: { [name in keyof tokens]: TokenContractReturnType; }; markets: { [name in keyof markets]: MarketTokenContractReturnType; }; vaults: { [name in keyof vaults]: MorphoVaultContractReturnType; }; contracts: EnvironmentContracts<contracts>; custom: custom; config: { tokens: { [name in keyof tokens]: TokenConfig; }; markets: { [name in keyof markets]: MarketConfig<Record<string, any>>; }; vaults: { [name in keyof vaults]: VaultConfig<Record<string, any>>; }; morphoMarkets: { [id: string]: MorphoMarketConfig<Record<string, any>>; }; contracts: ContractConfig<Record<string, any>>; }; publicClient: PublicClient; }; export {}; //# sourceMappingURL=config.d.ts.map