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

Feature/scaled sell amount #115

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Feature/scaled sell amount #115

wants to merge 17 commits into from

Conversation

jn-lp
Copy link
Collaborator

@jn-lp jn-lp commented Nov 5, 2024

No description provided.

@jn-lp jn-lp requested review from HvrlK and Gulikovskiy November 5, 2024 11:04
});

initialBuyAmounts.map(async ({ asset, amount }) => {
if (isAddressEqual(asset as Address, sellToken as Address) || amount.isZero()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

are you sure if amount is zero you should return an amount?

swapTarget: constants.AddressZero,
buyAssetMinAmount: scaledSellAmounts[i]!,
swapTarget: zeroAddress,
buyAssetMinAmount: scaledSellAmounts[i],
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can use scaledAmount here

const scaledAmount = scaledSellAmounts[i] as BigNumber;

// If asset is sell token or amount is zero, no swap needed
if (isAddressEqual(asset as Address, sellToken as Address) || scaledAmount.isZero()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

are you sure you need to use a quote with zero amount? Maybe you should skip it?


const amounts = await this.indexRouter.burnAmount(indexToken, sellAmount);

const quotes = await Promise.all(
amounts.map(async ({ amount, asset }) => {
if (!amount || amount.isZero() || asset.toLowerCase() === routerBuyToken.toLowerCase()) {
if (isAddressEqual(asset as Address, routerBuyToken as Address) || !amount || amount.isZero()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

!amount
I am not sure that amount can be nullable/undefined, can you check it please?

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