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

Replace toWei/fromWei when base token conversion #1318

Merged
merged 21 commits into from
Mar 16, 2022

Conversation

KatunaNorbert
Copy link
Member

Fixes #1279 .

@@ -366,10 +366,10 @@ export class FixedRateExchange {
const estGas = await this.estSetRate(
address,
exchangeId,
await this.unitsToAmount(exchange.baseToken, String(newRate))
await this.amountToUnits(exchange.baseToken, String(newRate))
Copy link
Contributor

Choose a reason for hiding this comment

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

why noy toString()?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is what was used above so I used to be consistent

Copy link
Contributor

Choose a reason for hiding this comment

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

strange, we always use toString, don't know how that stayed there.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will change it

Copy link
Member

Choose a reason for hiding this comment

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

feel free to update all String(value) in other places if you find more of this 😃

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I will

const estGas = await this.estSetRate(
address,
exchangeId,
this.web3.utils.toWei(String(newRate))
await this.amountToUnits(exchange.baseToken, newRate.toString())
Copy link
Member

@bogdanfazakas bogdanfazakas Mar 4, 2022

Choose a reason for hiding this comment

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

this conversions should also take place in estSetRate() just pass the raw string values to the estimate method and convert them there also

Copy link
Member Author

Choose a reason for hiding this comment

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

right, makes sense

@KatunaNorbert
Copy link
Member Author

I run into an issue when using amountToUnits inside createNftErc20WithFixedRate -> getFreCreationParams with USDC base token to transform the fixed rate value.

When sending the rate to the contract it contains 6 zeros so 1000000 but the transaction is reverted because in the contracts we have a MIN_RATE check which is 10 ** 10.
I think amountToUnits will not work in this case unless we change the contract.

Screenshot 2022-03-07 at 14 44 01

@codeclimate
Copy link

codeclimate bot commented Mar 8, 2022

Code Climate has analyzed commit cee1bc2 and detected 8 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 8

The test coverage on the diff in this pull request is 63.4% (50% is the threshold).

This pull request will bring the total coverage in the repository to 71.2% (-0.2% change).

View more on Code Climate.

@KatunaNorbert KatunaNorbert marked this pull request as ready for review March 8, 2022 13:01
@mihaisc mihaisc self-requested a review March 16, 2022 10:43
@mihaisc mihaisc merged commit a0e4323 into v4main Mar 16, 2022
@mihaisc mihaisc deleted the fix/issue1279-replace-fromWei&toWei branch March 16, 2022 10:44
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.

Stop using toWei/fromWei from web3
3 participants