* 🌟 Add HLS Vault Modal * 🛠️ Fix failing build * fix: keep the selected accountId if its present int the url (#588) * Link changelog (#589) * env: update RPC endpoint * feat: added changelog link to the footer version * Refactor balances table (#590) * env: update env.example after last sync * tidy: refactored AccountBalancesTable * fix: updated isCard to hideCard * fix: do update the health on sliding the margin back to 0 (#593) * fix: disable highlighting on non-expandable rows (#592) * Healthfactor adjustments (#594) * fix: do update the health on sliding the margin back to 0 * MP-3531: first updates on the health bars * fix: added exponential function for health percentage * fix: build fix * tidy: refactor * tidy: cleanup * feat: added new curve * fix: base set to 3.5 * env: version update * 🌟 Add HLS Vault Modal * Use `DisplayCurrency` in subtitle header * 🔥Remove redundant component --------- Co-authored-by: Linkie Link <linkielink.dev@gmail.com>
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { cacheFn, positionsCache } from 'api/cache'
|
|
import { getCreditManagerQueryClient } from 'api/cosmwasm-client'
|
|
import getDepositedVaults from 'api/vaults/getDepositedVaults'
|
|
import { BNCoin } from 'types/classes/BNCoin'
|
|
import { Positions } from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
|
|
|
export default async function getAccount(accountIdAndKind: AccountIdAndKind): Promise<Account> {
|
|
const creditManagerQueryClient = await getCreditManagerQueryClient()
|
|
|
|
const accountPosition: Positions = await cacheFn(
|
|
() => creditManagerQueryClient.positions({ accountId: accountIdAndKind.id }),
|
|
positionsCache,
|
|
`account/${accountIdAndKind.id}`,
|
|
)
|
|
|
|
const depositedVaults = await getDepositedVaults(accountIdAndKind.id, accountPosition)
|
|
|
|
if (accountPosition) {
|
|
return {
|
|
id: accountPosition.account_id,
|
|
debts: accountPosition.debts.map((debt) => new BNCoin(debt)),
|
|
lends: accountPosition.lends.map((lend) => new BNCoin(lend)),
|
|
deposits: accountPosition.deposits.map((deposit) => new BNCoin(deposit)),
|
|
vaults: depositedVaults,
|
|
kind: accountIdAndKind.kind,
|
|
}
|
|
}
|
|
|
|
return new Promise((_, reject) => reject('No account found'))
|
|
}
|