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

Collateral plugin integration tests #989

Merged
merged 10 commits into from
Nov 1, 2023
4 changes: 3 additions & 1 deletion common/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export const pow10 = (exponent: BigNumberish): BigNumber => {
// Convert `x` to a new BigNumber with decimals = `decimals`.
// Input should have SCALE_DECIMALS (18) decimal places, and `decimals` should be less than 18.
export const toBNDecimals = (x: BigNumberish, decimals: number): BigNumber => {
return BigNumber.from(x).div(pow10(SCALE_DECIMALS - decimals))
return decimals < SCALE_DECIMALS
? BigNumber.from(x).div(pow10(SCALE_DECIMALS - decimals))
: BigNumber.from(x).mul(pow10(decimals - SCALE_DECIMALS))
}

// Convert to the BigNumber representing a Fix from a BigNumberish.
Expand Down
Loading
Loading