update health computer + fix comments
This commit is contained in:
parent
6389155b5a
commit
fb701d871b
@ -152,7 +152,9 @@ export default function useHealthComputer(account?: Account) {
|
||||
if (!healthComputer) return
|
||||
try {
|
||||
setHealthFactor(Number(compute_health_js(healthComputer).max_ltv_health_factor) || 10)
|
||||
} catch (err) {}
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
}, [healthComputer])
|
||||
|
||||
const computeMaxBorrowAmount = useCallback(
|
||||
|
@ -23,7 +23,7 @@ export class BNCoin {
|
||||
toCoin(): Coin {
|
||||
return {
|
||||
denom: this.denom,
|
||||
amount: this.amount.toString(),
|
||||
amount: this.amount.integerValue().toString(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ export class BNCoin {
|
||||
amount: max
|
||||
? 'account_balance'
|
||||
: {
|
||||
exact: this.amount.toString(),
|
||||
exact: this.amount.integerValue().toString(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -41,7 +41,7 @@ export class BNCoin {
|
||||
toSignedCoin(): any {
|
||||
return {
|
||||
denom: this.denom,
|
||||
size: this.amount.toString(),
|
||||
size: this.amount.integerValue().toString(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ export class BNCoin {
|
||||
}
|
||||
|
||||
return {
|
||||
loss: this.toCoin(),
|
||||
loss: this.abs().toCoin(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,12 +4,11 @@ import { BN_ZERO } from 'constants/math'
|
||||
import { ORACLE_DENOM } from 'constants/oracle'
|
||||
import { BNCoin } from 'types/classes/BNCoin'
|
||||
import { VaultPosition } from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
||||
import { Positions } from 'types/generated/mars-rover-health-computer/MarsRoverHealthComputer.types'
|
||||
import { byDenom } from 'utils/array'
|
||||
import { BN } from 'utils/helpers'
|
||||
import { convertApyToApr } from 'utils/parsers'
|
||||
|
||||
import { Positions } from '../types/generated/mars-rover-health-computer/MarsRoverHealthComputer.types'
|
||||
|
||||
export const calculateAccountBalanceValue = (
|
||||
account: Account | AccountChange,
|
||||
prices: BNCoin[],
|
||||
@ -210,24 +209,34 @@ export function convertAccountToPositions(account: Account, prices: BNCoin[]): P
|
||||
size: perpPosition.amount.toString() as any,
|
||||
unrealised_pnl: {
|
||||
coins: {
|
||||
closing_fee: perpPosition.pnl.unrealized.fees.toCoin(),
|
||||
closing_fee: perpPosition.pnl.unrealized.fees.abs().toCoin(),
|
||||
// Used
|
||||
pnl: perpPosition.pnl.unrealized.net.toPnLCoin(), // Used
|
||||
},
|
||||
amounts: {
|
||||
// CHeck if these are correct
|
||||
accrued_funding: perpPosition.pnl.unrealized.funding.amount.toString() as any,
|
||||
opening_fee: perpPosition.pnl.unrealized.fees.amount.toString() as any, // Add openning fee for modifying position
|
||||
closing_fee: perpPosition.pnl.unrealized.fees.amount.toString() as any, // Add closing fee for modifying position
|
||||
pnl: perpPosition.pnl.unrealized.net.amount.toString() as any,
|
||||
price_pnl: perpPosition.pnl.unrealized.price.amount.toString() as any,
|
||||
accrued_funding: perpPosition.pnl.unrealized.funding.amount
|
||||
.integerValue()
|
||||
.toString() as any,
|
||||
opening_fee: perpPosition.pnl.unrealized.fees.amount
|
||||
.abs()
|
||||
.integerValue()
|
||||
.toString() as any, // Add openning fee for modifying position
|
||||
closing_fee: perpPosition.pnl.unrealized.fees.amount
|
||||
.abs()
|
||||
.integerValue()
|
||||
.toString() as any, // Add closing fee for modifying position
|
||||
pnl: perpPosition.pnl.unrealized.net.amount.integerValue().toString() as any,
|
||||
price_pnl: perpPosition.pnl.unrealized.price.amount.integerValue().toString() as any,
|
||||
},
|
||||
values: {
|
||||
// This does not matter for health calculation
|
||||
accrued_funding: perpPosition.pnl.unrealized.funding.amount.toString() as any,
|
||||
closing_fee: perpPosition.pnl.unrealized.fees.amount.toString() as any,
|
||||
pnl: perpPosition.pnl.unrealized.net.amount.toString() as any,
|
||||
price_pnl: perpPosition.pnl.unrealized.price.amount.toString() as any,
|
||||
accrued_funding: perpPosition.pnl.unrealized.funding.amount
|
||||
.integerValue()
|
||||
.toString() as any,
|
||||
closing_fee: perpPosition.pnl.unrealized.fees.amount.integerValue().toString() as any,
|
||||
pnl: perpPosition.pnl.unrealized.net.amount.integerValue().toString() as any,
|
||||
price_pnl: perpPosition.pnl.unrealized.price.amount.integerValue().toString() as any,
|
||||
},
|
||||
},
|
||||
realised_pnl: {
|
||||
|
@ -296,9 +296,7 @@ async function __wbg_load(module, imports) {
|
||||
function __wbg_get_imports() {
|
||||
const imports = {}
|
||||
imports.wbg = {}
|
||||
imports.wbg.__wbg_log_117d9799fa4f6287 = function (arg0, arg1, arg2, arg3) {
|
||||
console.log(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3))
|
||||
}
|
||||
imports.wbg.__wbg_log_117d9799fa4f6287 = function (arg0, arg1, arg2, arg3) {}
|
||||
imports.wbg.__wbindgen_object_clone_ref = function (arg0) {
|
||||
const ret = getObject(arg0)
|
||||
return addHeapObject(ret)
|
||||
|
Loading…
Reference in New Issue
Block a user