Skip to content

Commit

Permalink
fix(v4-sdk): create a deep copy of pools in v4 encodeRouteToPath (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilz authored Nov 27, 2024
1 parent 1eede93 commit a3fce42
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sdks/v4-sdk/src/utils/encodeRouteToPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ export type PathKey = {
}

export const encodeRouteToPath = (route: Route<Currency, Currency>, exactOutput?: boolean): PathKey[] => {
// create a deep copy of pools so that we don't tamper with pool array on route
let pools = route.pools.map((p) => p)
if (exactOutput) pools = pools.reverse()
let startingCurrency = exactOutput ? route.pathOutput : route.pathInput
let pools = exactOutput ? route.pools.reverse() : route.pools
let pathKeys: PathKey[] = []

for (let pool of pools) {
Expand Down

0 comments on commit a3fce42

Please sign in to comment.