@openocean.finance/widget-types
Version:
Types for the OpenOcean Widget
119 lines • 3.2 kB
TypeScript
import type { TransactionRequest, TypedData } from './api.js';
import type { Token } from './tokens/index.js';
export interface FeeCost {
name: string;
description: string;
percentage: string;
token: Token;
amount: string;
amountUSD: string;
included: boolean;
}
export interface GasCost {
type: 'SUM' | 'APPROVE' | 'SEND' | 'FEE';
price: string;
estimate: string;
limit: string;
amount: string;
amountUSD: string;
token: Token;
}
export interface Action {
fromChainId: number;
fromAmount: string;
fromToken: Token;
fromAddress?: string;
toChainId: number;
toToken: Token;
toAddress?: string;
slippage?: number;
}
export interface Estimate {
tool: string;
fromAmount: string;
fromAmountUSD?: string;
toAmount: string;
toAmountMin: string;
toAmountUSD?: string;
approvalAddress: string;
feeCosts?: FeeCost[];
gasCosts?: GasCost[];
executionDuration: number;
}
export declare const _StepType: readonly ["openocean", "swap", "cross", "protocol", "custom"];
export type StepType = (typeof _StepType)[number];
export type StepTool = string;
export type StepToolDetails = {
key: string;
name: string;
logoURI: string;
};
type StepInformationBase = {
tool: string;
type: string;
action: Action;
estimate: Estimate;
};
export type StepInformation = StepInformationBase & {
createdAt: Date;
gasLimit: string;
stepId: string;
transactionId: string;
intermediateActions: StepInformationBase[];
integrator?: string;
relatedOpenOceanStep?: string[];
};
export interface StepBase {
id: string;
type: StepType;
tool: StepTool;
toolDetails: StepToolDetails;
integrator?: string;
referrer?: string;
action: Action;
estimate?: Estimate;
transactionRequest?: TransactionRequest;
/**
* EIP-712 Typed Data
* @link https://eips.ethereum.org/EIPS/eip-712
*/
typedData?: TypedData[];
}
export interface DestinationCallInfo {
toContractAddress: string;
toContractCallData: string;
toFallbackAddress: string;
callDataGasLimit: string;
}
export type CallAction = Action & DestinationCallInfo;
export interface SwapStep extends StepBase {
type: 'swap';
action: Action;
estimate: Estimate;
}
export interface CrossStep extends StepBase {
type: 'cross';
action: Action;
estimate: Estimate;
}
export interface ProtocolStep extends StepBase {
type: 'protocol';
action: Action;
estimate: Estimate;
}
export interface CustomStep extends StepBase {
type: 'custom';
action: CallAction;
estimate: Estimate;
}
export type Step = SwapStep | CrossStep | CustomStep | ProtocolStep;
export interface OpenOceanStep extends Omit<Step, 'type'> {
type: 'swap' | 'bridge' | 'custom';
includedSteps: Step[];
}
export declare function isSwapStep(step: Step): step is SwapStep;
export declare function isCrossStep(step: Step): step is CrossStep;
export declare function isProtocolStep(step: Step): step is ProtocolStep;
export declare function isCustomStep(step: Step): step is CustomStep;
export {};
//# sourceMappingURL=step.d.ts.map