Skip to content

Commit

Permalink
Merge pull request #24 from Levana-Protocol/perp-4083/potential-earnings
Browse files Browse the repository at this point in the history
PERP-4083 | Fix potential earnings microunits
  • Loading branch information
lvn-rusty-dragon authored Sep 18, 2024
2 parents bf29c96 + 05942f7 commit 92b46eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions frontend/src/utils/coins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ class Coins extends Asset {
const newUnits = this.units.times(value)
return Coins.fromUnits(this.denom, newUnits)
}

dividedBy(value: BigNumber.Value): Coins {
const newUnits = this.units.dividedBy(value)
return Coins.fromUnits(this.denom, newUnits)
}
}

class USD extends Asset {
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/utils/shares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BigNumber from "bignumber.js"

import type { Market, OutcomeId } from "@api/queries/Market"
import type { Positions } from "@api/queries/Positions"
import type { Coins } from "./coins"
import { Coins } from "./coins"

class Shares {
static precision = 3
Expand Down Expand Up @@ -46,7 +46,10 @@ const getShares = (positions: Positions, outcomeId: OutcomeId): Shares => {
}

const getPotentialWinnings = (market: Market, positionSize: Shares): Coins => {
return market.poolSize.times(positionSize.value)
return Coins.fromUnits(
market.denom,
market.poolSize.getValue().times(positionSize.value),
)
}

export { Shares, getShares, getPotentialWinnings }

0 comments on commit 92b46eb

Please sign in to comment.