Skip to content

Commit

Permalink
fix(v4-sdk): Fix route encoding v4 (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
hensha256 authored Sep 28, 2024
1 parent 36ea0a4 commit 64f4751
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sdks/v4-sdk/src/entities/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ export class Route<TInput extends Currency, TOutput extends Currency> {
const chainId = pools[0].chainId
const allOnSameChain = pools.every((pool) => pool.chainId === chainId)
invariant(allOnSameChain, 'CHAIN_IDS')
invariant(pools[0].involvesCurrency(input), 'INPUT')
invariant(pools[pools.length - 1].involvesCurrency(output), 'OUTPUT')

invariant(pools[0].involvesCurrency(input) || pools[0].involvesCurrency(input.wrapped), 'INPUT')
invariant(
pools[pools.length - 1].involvesCurrency(output) || pools[pools.length - 1].involvesCurrency(output.wrapped),
'OUTPUT'
)

/**
* Normalizes currency0-currency1 order and selects the next currency/fee step to add to the path
Expand Down

0 comments on commit 64f4751

Please sign in to comment.