Perp queries (#712)
* update assets config and chains
* make clients dynamic
* feat: formatted ChainSelect
* fix infinite rerender on trade page
* feat: added NTRN icon
* fix: fixed ChainInfoID
* fix: fixed autoLendEnabled for NTRN
* fix: fixed the navigation and dependencies
* fix: fixed the pricefeed id
* fix: fixed the header menu
* fix: fixed the trading charts
* fix: fixed the healthbars
* fix: fixed naming of pion-1
* feast: updated xdefi image
* env: updated contracts
* make localStorage chain agnostic
* fix: made the selected chain persistant
* fix: fixed the wallet providers
* fix: updated auto connect
* fix: fixed auto connecting
* fix: added ChainSelect to focusMode
* store raw strings in localstorage
* 🔥 remnove tests
* update caching keys + disconnect wallet on change chain
* update contract types and add perps asset select overlay
* fix build + add perps positions to accounts
* fix healthcomputer errors
* fix healthcomputer errors
---------
Co-authored-by: Linkie Link <linkielink.dev@gmail.com>
This commit is contained in:
parent
a2b6acbccb
commit
1bcf810845
@ -9,10 +9,7 @@ import useLocalStorage from 'hooks/localStorage/useLocalStorage'
|
||||
import useAssetParams from 'hooks/params/useAssetParams'
|
||||
import usePrices from 'hooks/usePrices'
|
||||
import useVaultConfigs from 'hooks/useVaultConfigs'
|
||||
import {
|
||||
Positions,
|
||||
VaultPositionValue,
|
||||
} from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
||||
import { VaultPositionValue } from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
||||
import { VaultConfigBaseForString } from 'types/generated/mars-params/MarsParams.types'
|
||||
import {
|
||||
AssetParamsBaseForAddr,
|
||||
@ -45,7 +42,7 @@ export default function useHealthComputer(account?: Account) {
|
||||
const [slippage] = useLocalStorage<number>(LocalStorageKeys.SLIPPAGE, DEFAULT_SETTINGS.slippage)
|
||||
|
||||
const [healthFactor, setHealthFactor] = useState(0)
|
||||
const positions: Positions | null = useMemo(() => {
|
||||
const positions: PositionsWithoutPerps | null = useMemo(() => {
|
||||
if (!account) return null
|
||||
return convertAccountToPositions(account)
|
||||
}, [account])
|
||||
|
@ -41,7 +41,7 @@ export type UnlockingPositions = VaultUnlockingPosition[]
|
||||
export interface HealthComputer {
|
||||
denoms_data: DenomsData
|
||||
kind: AccountKind
|
||||
positions: Positions
|
||||
positions: PositionsWithoutPerps
|
||||
vaults_data: VaultsData
|
||||
}
|
||||
export interface DenomsData {
|
||||
|
6
src/types/interfaces/perps.d.ts
vendored
6
src/types/interfaces/perps.d.ts
vendored
@ -1 +1,7 @@
|
||||
type OrderDirection = 'long' | 'short' | 'buy' | 'sell'
|
||||
|
||||
// TODO: 📈Remove this type when healthcomputer is implemented
|
||||
type PositionsWithoutPerps = Omit<
|
||||
import('types/generated/mars-credit-manager/MarsCreditManager.types').Positions,
|
||||
'perps'
|
||||
>
|
||||
|
@ -3,10 +3,7 @@ import BigNumber from 'bignumber.js'
|
||||
import { BN_ZERO } from 'constants/math'
|
||||
import { ORACLE_DENOM } from 'constants/oracle'
|
||||
import { BNCoin } from 'types/classes/BNCoin'
|
||||
import {
|
||||
Positions,
|
||||
VaultPosition,
|
||||
} from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
||||
import { VaultPosition } from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
||||
import { byDenom } from 'utils/array'
|
||||
import { BN } from 'utils/helpers'
|
||||
import { convertApyToApr } from 'utils/parsers'
|
||||
@ -171,7 +168,8 @@ export function accumulateAmounts(denom: string, coins: BNCoin[]): BigNumber {
|
||||
return coins.reduce((acc, coin) => acc.plus(getAmount(denom, [coin.toCoin()])), BN_ZERO)
|
||||
}
|
||||
|
||||
export function convertAccountToPositions(account: Account): Positions {
|
||||
// TODO: 📈 Add correct type mapping
|
||||
export function convertAccountToPositions(account: Account): PositionsWithoutPerps {
|
||||
return {
|
||||
account_id: account.id,
|
||||
debts: account.debts.map((debt) => ({
|
||||
|
Loading…
Reference in New Issue
Block a user