@lifi/composer-sdk
Version:
Public Composer SDK for building and submitting flows
546 lines (543 loc) • 13.6 kB
TypeScript
import { IntegerStringInput, Address } from '../types.js';
import '@lifi/compose-spec';
/**
* a number between 0 and 10000
*/
type Between010000 = number;
interface CoreSplitConfig {
bps: Between010000;
}
/**
* 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 InvariantGteConfig {
threshold: IntegerStringInput;
}
interface InvariantGtConfig {
threshold: IntegerStringInput;
}
interface InvariantLteConfig {
threshold: IntegerStringInput;
}
interface InvariantLtConfig {
threshold: IntegerStringInput;
}
interface InvariantEqConfig {
threshold: IntegerStringInput;
}
interface InvariantNeqConfig {
threshold: IntegerStringInput;
}
/**
* a non-negative number
*/
type NonNegative = number;
interface CoreBpsDownConfig {
bps: NonNegative;
}
interface CoreBpsUpConfig {
bps: NonNegative;
}
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;
}
/**
* a string at most 65536 character(s) long
*/
type MaxLength65536 = string;
interface CoreCallConfig {
target: Address;
functionSignature: string;
callType?: 'Call' | 'ValueCall';
args?: ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | (MaxLength65536 | number | boolean | {
$ref: string;
})[])[])[])[])[])[];
approvals?: ({
spender: Address;
} | {
from: 'sender';
})[];
}
interface CoreStaticCallConfig {
target: Address;
functionSignature: string;
args?: ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | (MaxLength65536 | number | boolean | {
$ref: string;
})[])[])[])[])[])[];
}
interface CoreRawCallConfig {
target: Address;
calldata: string;
callType?: 'Call' | 'StaticCall' | 'ValueCall' | 'DelegateCall';
resultType?: string;
}
interface CoreInvokeConfig {
target: Address;
functionSignature: string;
callType?: 'Call' | 'ValueCall';
args?: ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | ((MaxLength65536 | number | boolean | {
$ref: string;
}) | (MaxLength65536 | number | boolean | {
$ref: string;
})[])[])[])[])[])[];
}
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;
}
type ContinuationAssertReadyConfig = {
kind: 'erc20BalanceGte';
chainId: Positive;
token: StartsWith0X;
owner: StartsWith0X;
minAmount: string;
} | {
kind: 'nativeBalanceGte';
chainId: Positive;
owner: StartsWith0X;
minAmount: string;
} | {
kind: 'call';
chainId: Positive;
to: StartsWith0X;
calldata: StartsWith0X;
comparator: 'gte' | 'eq' | 'lte';
value: string;
};
/**
* a string starting with "0x"
*/
type StartsWith0X = string;
interface LifiZapConfig {
resourceOut: {
kind: 'native';
chainId: Positive;
} | {
kind: 'erc20';
token: Address;
chainId: Positive;
};
}
interface LifiZapAsyncConfig {
resourceOut: {
kind: 'native';
chainId: Positive;
} | {
kind: 'erc20';
token: Address;
chainId: Positive;
};
}
interface ParaswapBuyConfig {
resourceOut: {
kind: 'native';
chainId: Positive;
} | {
kind: 'erc20';
token: Address;
chainId: Positive;
};
exactAmountOut: string;
srcDecimals: NonNegative;
destDecimals: NonNegative;
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, ContinuationAssertReadyConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreEmitEvent1Config, CoreEmitEvent2Config, CoreEmitEvent3Config, CoreEmitEvent4Config, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig, InvariantEqConfig, InvariantGtConfig, InvariantGteConfig, InvariantLtConfig, InvariantLteConfig, InvariantNeqConfig, InvariantNumericConfig, InvariantNumericInRangeConfig, LifiFlashloanRepayConfig, LifiSwapConfig, LifiZapAsyncConfig, LifiZapConfig, MaxItems50, MaxLength64, MaxLength65536, MorphoBlueBorrowConfig, MorphoBlueGetPositionConfig, MorphoBlueRepayConfig, MorphoBlueSupplyCollateralConfig, MorphoBlueSupplyConfig, MorphoBlueWithdrawCollateralConfig, MorphoBlueWithdrawConfig, NativeBalancePreconditionConfig, NonNegative, ParaswapBuyConfig, Positive, SlippageGuardConfig, StartsWith0X };