Skip to content

Commit

Permalink
Collateral plugin integration tests (#989)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrent authored Nov 1, 2023
1 parent b8f4d84 commit 7af3d31
Show file tree
Hide file tree
Showing 4 changed files with 801 additions and 23 deletions.
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

0 comments on commit 7af3d31

Please sign in to comment.