Skip to content

Commit

Permalink
fix price impact, readable utills
Browse files Browse the repository at this point in the history
  • Loading branch information
nissoh committed Jan 15, 2024
1 parent dc5c35d commit 820cf83
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions utils/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ export const readableUSD = readableNumber({ })
export const readablePercentage = (amount: bigint) => readableUnitAmount(formatFixed(amount, 2)) + '%'
export const readableFactorPercentage = (amount: bigint) => readableUnitAmount(formatFixed(amount, FACTOR_PERCISION) * 100) + '%'
export const readableLeverage = (a: bigint, b: bigint) => (b ? readableUnitAmount(formatFixed(a * BASIS_POINTS_DIVISOR / b, 4)) : 0n) + 'x'
export const readableFixedUSD30 = (ammount: bigint) => readableUSD(formatFixed(ammount, USD_DECIMALS))
export const readableUsd = (ammount: bigint) => readableUSD(formatFixed(ammount, USD_DECIMALS))
export const readablePnl = (ammount: bigint) => readableNumber({ signDisplay: "exceptZero" })(formatFixed(ammount, USD_DECIMALS))
export const readableTokenAmountFromUsdAmount = (decimals: number, price: bigint, amount: bigint) => readableUnitAmount(formatFixed(getTokenAmount(price, amount), decimals))
export const readableTokenUsd = (price: bigint, amount: bigint) => readableFixedUSD30(getTokenUsd(price, amount))
export const readableTokenUsd = (price: bigint, amount: bigint) => readableUsd(getTokenUsd(price, amount))
export const readableTokenAmount = (token: viem.Address, amount: bigint) => readableUnitAmount(formatFixed(amount, getTokenDescription(token).decimals))
export const readableTokenAmountLabel = (token: viem.Address, amount: bigint) => readableTokenAmount(token, amount) + ' ' + getTokenDescription(token).symbol
export const readableTokenPrice = (decimals: number, amount: bigint) => readableAccountingAmount(formatFixed(amount, USD_DECIMALS - decimals))
Expand Down
2 changes: 1 addition & 1 deletion utils/src/v2/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function getPriceImpactForPosition(
) {

const longInterestInUsd = marketInfo.usage.longInterestUsd
const shortInterestInUsd = marketInfo.usage.shortInterestInTokens
const shortInterestInUsd = marketInfo.usage.shortInterestUsd


const nextLongUsd = longInterestInUsd + (isLong ? sizeDeltaUsd : 0n)
Expand Down

0 comments on commit 820cf83

Please sign in to comment.