Skip to content

Commit

Permalink
feat: added protocol step type + routes can only contain lifi steps (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
H3xept committed Feb 13, 2023
1 parent 6fa45af commit cedfeec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Chain,
ChainId,
ExchangeDefinition,
LifiStep,
Step,
Token,
} from '.'
Expand Down Expand Up @@ -84,7 +85,7 @@ export interface Route {
containsSwitchChain?: boolean // Features required for route execution
infiniteApproval?: boolean // Features used for route execution

steps: Step[]
steps: LifiStep[]

tags?: Order[]
}
Expand Down
14 changes: 12 additions & 2 deletions src/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const emptyExecution: Execution = {
}

// STEP
export type StepType = 'swap' | 'cross' | 'lifi' | 'custom'
export type StepType = 'swap' | 'cross' | 'lifi' | 'custom' | 'protocol'
export type StepTool = string

export interface StepBase {
Expand Down Expand Up @@ -149,6 +149,12 @@ export interface CrossStep extends StepBase {
estimate: Estimate
}

export interface ProtocolStep extends StepBase {
type: 'protocol'
action: Action
estimate: Estimate
}

export function isCrossStep(step: Step): step is CrossStep {
return step.type === 'cross'
}
Expand Down Expand Up @@ -182,4 +188,8 @@ export function isCustomStep(step: Step): step is CustomStep {
return step.type === 'custom'
}

export type Step = SwapStep | CrossStep | LifiStep | CustomStep
export function isProtocolStep(step: Step): step is ProtocolStep {
return step.type === 'protocol'
}

export type Step = SwapStep | CrossStep | LifiStep | CustomStep | ProtocolStep

0 comments on commit cedfeec

Please sign in to comment.