UNPKG

@lifi/compose-spec

Version:

Public wire-format types and schemas for Compose flows

42 lines (36 loc) 1.47 kB
// Mirrors the Solidity `ProviderKind` enum in // `Yggdrasil-VirtualMachine/src/flashloan/FlashloanLeg.sol`. The numeric // values are wire format; the Rust EVM backend consumes them in // `executeWithFlashloan(adapter, legs, programBytes)`. Drift between this // file and the Solidity source is a bug. export const PROVIDER_KIND = { AAVE_V3: 0, ERC3156: 1, BALANCER_V2: 2, MORPHO_BLUE: 3, } as const; export const providerKindNames = [ "aave-v3", "erc3156", "balancer-v2", "morpho-blue", ] as const; export type ProviderKindName = (typeof providerKindNames)[number]; export const providerKindByName: Record<ProviderKindName, number> = { "aave-v3": PROVIDER_KIND.AAVE_V3, erc3156: PROVIDER_KIND.ERC3156, "balancer-v2": PROVIDER_KIND.BALANCER_V2, "morpho-blue": PROVIDER_KIND.MORPHO_BLUE, }; // The fully-narrowed JSON shape of a `flashloan` MaterialiserInput once it // has crossed from untrusted Flow JSON through structural validation. The // literal `kind: "flashloan"` discriminates inside the `MaterialiserInput` // union; `providerKind` and `amount` are the two flashloan-specific fields. // `amount` is the wire form (decimal-integer string); the flashloan // materialiser's `configSchema` (see compose-builtins/materialisers/flashloan) // validates the shape before any consumer reads it. export interface FlashloanMaterialiserInput { readonly kind: "flashloan"; readonly providerKind: ProviderKindName; readonly amount: string; }