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

Switch to using bignumber.js library #186

Closed
wants to merge 7 commits into from

Conversation

tatomir-streamflow
Copy link
Contributor

Overview

We want to switch to using bignumber.js library due to more precision when doing operations like division and multiplication and to have consistency across the codebases (to only use 1 big number library).

Open questions

  • How do we want to update our public API?
  • How do we want to version this?

RolginRoman and others added 7 commits July 4, 2024 15:45
@@ -44,6 +44,7 @@
"@solana/wallet-adapter-base": "0.9.19",
"@solana/web3.js": "1.70.1",
"aptos": "1.4.0",
"bignumber.js": "^9.1.2",
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we want to update our public API?
How do we want to version this?
This is just breaking change. We bump major and update README if needed

```javascript
const updateStreamParams: Types.IUpdateData = {
id: "AAAAyotqTZZMAAAAmsD1JAgksT8NVAAAASfrGB5RAAAA", // Identifier of a stream to update.
enableAutomaticWithdrawal: true, // [optional], allows to enable AW if it wasn't, disable is not possible
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are updating this, @Yolley there was some magic combination if I recall, to turn off auto settle?

return this.depositedAmount
.minus(this.withdrawnAmount)
.div(10 ** decimals)
.toNumber();
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change API here not to return number.
@Yolley WDYT?


export const BASE_FEE = 1009900; // Buffer to include usual fees when calculating stream amount
export const WITHDRAW_AVAILABLE_AMOUNT = new BN("18446744073709551615"); // Magical number to withdraw all available amount from a Contract
// this magical number needs updating probably
Copy link
Contributor

Choose a reason for hiding this comment

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

Prob, but let's handle it in bug system, not in comment :)

@@ -1,10 +1,11 @@
import BN from "bn.js";
import BigNumber from "bignumber.js";
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is BN imported above?

import BN from "bn.js";
import { BigNumber } from "ethers";
import BigNumber from "bignumber.js";
import { BigNumber as BigNumberEvm } from "ethers";
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I would love to migrate all to BigNumber, and just to have layers that are converting

@@ -64,6 +64,7 @@
"@streamflow/common": "workspace:*",
"@suiet/wallet-kit": "0.2.22",
"aptos": "1.4.0",
"bignumber.js": "^9.1.2",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove bn below?

Base automatically changed from prerelease/v7 to v7 September 3, 2024 11:40
@tatomir-streamflow
Copy link
Contributor Author

Closing pull request to delete remote branch - having issues pushing new changes after rebasing to v7 so I will reset the "redo" the remote branch

@tatomir-streamflow tatomir-streamflow deleted the tatomir/feature/bignumber-library branch September 3, 2024 15:10
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.

4 participants