UNPKG

@lifi/composer-sdk

Version:

Public Composer SDK for building and submitting flows

456 lines (453 loc) 11 kB
import { IntegerStringInput, Address } from '../types.cjs'; import '@lifi/compose-spec'; interface CoreSplitConfig { bps: number; } /** * a positive number */ type Positive = number; /** * a string at most 64 character(s) long */ type MaxLength64 = string; /** * an array of at most 50 item(s) * * @maxItems 50 */ type MaxItems50 = MaxLength64[]; interface LifiSwapConfig { resourceOut: { kind: 'native'; chainId: Positive; } | { kind: 'erc20'; token: Address; chainId: Positive; }; slippage?: number; timing?: { swapStepTimingStrategies?: { strategy: 'minWaitTime'; minWaitTimeMs: number; startingExpectedResults: number; reduceEveryMs: number; }[]; routeTimingStrategies?: { strategy: 'minWaitTime'; minWaitTimeMs: number; startingExpectedResults: number; reduceEveryMs: number; }[]; }; exchanges?: { allow?: MaxItems50; deny?: MaxItems50; prefer?: MaxItems50; }; } interface InvariantNumericConfig { op: 'gte' | 'gt' | 'lte' | 'lt' | 'eq' | 'neq'; threshold: IntegerStringInput; } interface InvariantNumericInRangeConfig { min: IntegerStringInput; max: IntegerStringInput; } interface CoreBpsDownConfig { bps: number; } interface CoreBpsUpConfig { bps: number; } interface CoreApproveConfig { spender: Address; } interface CoreBalanceOfConfig { token: Address; owner?: Address; } interface CoreTransferConfig { amount?: IntegerStringInput; } interface CoreEmitEvent1Config { signature: string; } interface CoreEmitEvent2Config { signature: string; } interface CoreEmitEvent3Config { signature: string; } interface CoreEmitEvent4Config { signature: string; } interface CoreCallConfig { target: Address; functionSignature: string; callType?: 'Call' | 'ValueCall'; args?: Unknown[]; approvals?: { spender: Address; }[]; } interface Unknown { [k: string]: unknown; } interface CoreStaticCallConfig { target: Address; functionSignature: string; args?: Unknown[]; } interface CoreRawCallConfig { target: Address; calldata: string; callType?: 'Call' | 'StaticCall' | 'ValueCall' | 'DelegateCall'; resultType?: string; } interface CoreInvokeConfig { target: Address; functionSignature: string; callType?: 'Call' | 'ValueCall'; args?: Unknown[]; } interface CoreAsResourceConfig { resource: { kind: 'native'; chainId: Positive; } | { kind: 'erc20'; token: Address; chainId: Positive; }; } interface AaveBorrowConfig { pool: string; asset: string; variableDebtToken: string; amount: IntegerStringInput; referralId?: number; } type AaveRepayConfig = { pool: string; mode: 'exact'; } | { pool: string; mode: 'max'; }; interface AaveRepayWithATokensConfig { pool: string; asset: string; } interface AaveClaimRewardsConfig { rewardsController: string; assets: string[]; reward: string; amount?: IntegerStringInput; to?: string; } /** * a number between 0 and 255 */ type Between0255 = number; interface AaveSetEModeConfig { pool: string; category: Between0255; } interface AaveGetHealthFactorConfig { pool: string; user?: string; } type MorphoBlueSupplyCollateralConfig = ({ morpho?: string; onBehalfOf?: string; mode: 'exact'; /** * a string matching the pattern ^0x[0-9a-fA-F]{64}$ */ marketId: string; } | { morpho?: string; onBehalfOf?: string; mode: 'exact'; marketParams: { loanToken: string; collateralToken: string; oracle: string; irm: string; lltv: string; }; }) | ({ morpho?: string; onBehalfOf?: string; mode: 'all'; /** * a string matching the pattern ^0x[0-9a-fA-F]{64}$ */ marketId: string; } | { morpho?: string; onBehalfOf?: string; mode: 'all'; marketParams: { loanToken: string; collateralToken: string; oracle: string; irm: string; lltv: string; }; }); type MorphoBlueWithdrawCollateralConfig = { morpho?: string; amount: IntegerStringInput; onBehalfOf?: string; receiver?: string; /** * a string matching the pattern ^0x[0-9a-fA-F]{64}$ */ marketId: string; } | { morpho?: string; amount: IntegerStringInput; onBehalfOf?: string; receiver?: string; marketParams: { loanToken: string; collateralToken: string; oracle: string; irm: string; lltv: string; }; }; type MorphoBlueBorrowConfig = { morpho?: string; amount: IntegerStringInput; onBehalfOf?: string; receiver?: string; /** * a string matching the pattern ^0x[0-9a-fA-F]{64}$ */ marketId: string; } | { morpho?: string; amount: IntegerStringInput; onBehalfOf?: string; receiver?: string; marketParams: { loanToken: string; collateralToken: string; oracle: string; irm: string; lltv: string; }; }; type MorphoBlueRepayConfig = ({ morpho?: string; mode: 'exact'; /** * a string matching the pattern ^0x[0-9a-fA-F]{64}$ */ marketId: string; } | { morpho?: string; mode: 'exact'; marketParams: { loanToken: string; collateralToken: string; oracle: string; irm: string; lltv: string; }; }) | ({ morpho?: string; mode: 'max'; /** * a string matching the pattern ^0x[0-9a-fA-F]{64}$ */ marketId: string; } | { morpho?: string; mode: 'max'; marketParams: { loanToken: string; collateralToken: string; oracle: string; irm: string; lltv: string; }; }); type MorphoBlueSupplyConfig = { morpho?: string; onBehalfOf?: string; /** * a string matching the pattern ^0x[0-9a-fA-F]{64}$ */ marketId: string; } | { morpho?: string; onBehalfOf?: string; marketParams: { loanToken: string; collateralToken: string; oracle: string; irm: string; lltv: string; }; }; type MorphoBlueWithdrawConfig = ({ morpho?: string; mode: 'exact'; amount: IntegerStringInput; onBehalfOf?: string; receiver?: string; /** * a string matching the pattern ^0x[0-9a-fA-F]{64}$ */ marketId: string; } | { morpho?: string; mode: 'exact'; amount: IntegerStringInput; onBehalfOf?: string; receiver?: string; marketParams: { loanToken: string; collateralToken: string; oracle: string; irm: string; lltv: string; }; }) | ({ morpho?: string; mode: 'max'; onBehalfOf?: string; receiver?: string; /** * a string matching the pattern ^0x[0-9a-fA-F]{64}$ */ marketId: string; } | { morpho?: string; mode: 'max'; onBehalfOf?: string; receiver?: string; marketParams: { loanToken: string; collateralToken: string; oracle: string; irm: string; lltv: string; }; }); type MorphoBlueGetPositionConfig = { morpho?: string; user?: string; /** * a string matching the pattern ^0x[0-9a-fA-F]{64}$ */ marketId: string; } | { morpho?: string; user?: string; marketParams: { loanToken: string; collateralToken: string; oracle: string; irm: string; lltv: string; }; }; interface LifiFlashloanRepayConfig { leg: string; fee?: string; } interface LifiZapConfig { resourceOut: { kind: 'native'; chainId: Positive; } | { kind: 'erc20'; token: Address; chainId: Positive; }; } /** * a non-negative number */ type GreaterThanOrEqualTo0 = number; /** * a number between 0 and 10000 */ type Between010000 = number; interface ParaswapBuyConfig { resourceOut: { kind: 'native'; chainId: Positive; } | { kind: 'erc20'; token: Address; chainId: Positive; }; exactAmountOut: string; srcDecimals: GreaterThanOrEqualTo0; destDecimals: GreaterThanOrEqualTo0; maxSlippageBps?: Between010000; partner?: string; partnerAddress?: string; /** * Integrator fee in basis points; non-negative integer string capped at 9000. */ partnerFeeBps?: string; } interface CorePeekConfig { target: Address; functionSignature: string; args?: string[]; } interface SlippageGuardConfig { port: string; bps: Between010000; } interface CoreNumericInvariantGuardConfig { port: string; op: 'gte' | 'gt' | 'lte' | 'lt' | 'eq' | 'neq'; threshold: IntegerStringInput; } interface BalanceOfMaterialiserConfig { owner: Address; } type DirectDepositMaterialiserConfig = { amount: IntegerStringInput; allowNonExact?: false; } | { amount: IntegerStringInput; allowNonExact: true; } | { allowNonExact: true; simAmount?: string; }; interface CallMaterialiserConfig { target: Address; calldata: string; } interface FlashloanMaterialiserConfig { providerKind: 'aave-v3' | 'erc3156' | 'balancer-v2' | 'morpho-blue'; amount: IntegerStringInput; } interface Erc20BalancePreconditionConfig { wallet: Address; token: Address; balance: IntegerStringInput; } interface NativeBalancePreconditionConfig { wallet: Address; balance: IntegerStringInput; } interface Erc20AllowancePreconditionConfig { owner: Address; spender: Address; token: Address; allowance: IntegerStringInput; } export type { AaveBorrowConfig, AaveClaimRewardsConfig, AaveGetHealthFactorConfig, AaveRepayConfig, AaveRepayWithATokensConfig, AaveSetEModeConfig, BalanceOfMaterialiserConfig, Between010000, Between0255, CallMaterialiserConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreEmitEvent1Config, CoreEmitEvent2Config, CoreEmitEvent3Config, CoreEmitEvent4Config, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig, GreaterThanOrEqualTo0, InvariantNumericConfig, InvariantNumericInRangeConfig, LifiFlashloanRepayConfig, LifiSwapConfig, LifiZapConfig, MaxItems50, MaxLength64, MorphoBlueBorrowConfig, MorphoBlueGetPositionConfig, MorphoBlueRepayConfig, MorphoBlueSupplyCollateralConfig, MorphoBlueSupplyConfig, MorphoBlueWithdrawCollateralConfig, MorphoBlueWithdrawConfig, NativeBalancePreconditionConfig, ParaswapBuyConfig, Positive, SlippageGuardConfig, Unknown };