Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved sorting of trades to eco router #221

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Mi-Lan
Copy link
Collaborator

@Mi-Lan Mi-Lan commented Nov 28, 2022

  • Moved trades type sorting to the sdk so that we have it in one place
  • Added new folder inside trades called ecoRouterTrades which handles trades fetching and trades ordering

@Mi-Lan Mi-Lan changed the title fix: Moved sorting of trades to eco router Moved sorting of trades to eco router Nov 28, 2022
Copy link
Collaborator

@berteotti berteotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a few comments, looks good overall. Will aprove after removing dist folder.

import { EcoRouterResults } from './types'

export async function getTradesPromise(
parsedAmount: CurrencyAmount,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this currencyAmount? We don't know if it's parsed or not so this is an assumption.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be more confusing to call it same as type. What do you mean by well not know if its parsed or not? It always accepts the same type currency with the amount inside that is requested

recipient: receiver,
tradeType: TradeType.EXACT_INPUT,
})
.then((res) => resolve(res ? res : undefined))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this logic makes sense. If it's undefined it will return undefined. Are we turning false, null values into undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is because of type because it should return either trade or undefined

Comment on lines +89 to +93
.catch((error) => {
console.error(error)
errors.push(error)
resolve(undefined)
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are repeating this logic every .catch maybe we can have a function catch error that receives and error and returns undefined (or just return). Calling resolve is the same as calling return, so we can simply that too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm in not sure about this actually because its a promise not a function...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants