From f1ff3e88d4470430e9a3d928ded1a3a8d41d0825 Mon Sep 17 00:00:00 2001
From: Bob van der Helm <34470358+bobthebuidlr@users.noreply.github.com>
Date: Thu, 23 Mar 2023 15:44:55 +0100
Subject: [PATCH] Mp 2267 rewrite mutations (#137)
* remove react-query
* :heavy_minus_sign: remove unused packages
---
package.json | 4 -
src/components/Account/RiskChart.tsx | 5 +-
.../Navigation/DesktopNavigation.tsx | 2 +-
src/components/Settings.tsx | 2 +-
src/hooks/data/useAccountStats.tsx | 255 ------
.../data/useCalculateMaxBorrowAmount.tsx | 104 ---
src/hooks/data/useCalculateMaxTradeAmount.tsx | 145 ----
.../data/useCalculateMaxWithdrawAmount.tsx | 137 ----
src/hooks/mutations/useBorrowFunds.tsx | 68 --
src/hooks/mutations/useRepayFunds.tsx | 63 --
src/hooks/mutations/useTradeAsset.tsx | 79 --
src/hooks/mutations/useWithdrawFunds.tsx | 68 --
src/hooks/queries/useAllBalances.tsx | 48 --
src/hooks/queries/useAllowedCoins.tsx | 30 -
src/hooks/queries/useBroadcast.tsx | 49 --
.../queries/useCreditAccountPositions.tsx | 55 --
src/hooks/queries/useCreditAccounts.tsx | 53 --
src/hooks/queries/useEstimateFee.tsx | 53 --
src/hooks/queries/useMarkets.tsx | 91 ---
src/hooks/queries/useRedbankBalances.tsx | 47 --
src/hooks/queries/useTokenPrices.tsx | 60 --
src/hooks/{data => }/useAnimations.tsx | 0
src/hooks/{useParams.ts => useParams.tsx} | 0
.../MarsAccountNft.react-query.ts | 574 --------------
.../MarsCreditManager.react-query.ts | 724 -----------------
.../MarsMockCreditManager.react-query.ts | 659 ----------------
.../MarsMockOracle.react-query.ts | 85 --
.../MarsMockRedBank.react-query.ts | 735 ------------------
.../MarsMockVault.react-query.ts | 302 -------
.../MarsRoverHealthComputer.react-query.ts | 33 -
.../MarsRoverHealthTypes.react-query.ts | 128 ---
.../MarsSwapperBase.react-query.ts | 235 ------
.../MarsZapperBase.react-query.ts | 172 ----
yarn.lock | 189 +++--
34 files changed, 92 insertions(+), 5162 deletions(-)
delete mode 100644 src/hooks/data/useAccountStats.tsx
delete mode 100644 src/hooks/data/useCalculateMaxBorrowAmount.tsx
delete mode 100644 src/hooks/data/useCalculateMaxTradeAmount.tsx
delete mode 100644 src/hooks/data/useCalculateMaxWithdrawAmount.tsx
delete mode 100644 src/hooks/mutations/useBorrowFunds.tsx
delete mode 100644 src/hooks/mutations/useRepayFunds.tsx
delete mode 100644 src/hooks/mutations/useTradeAsset.tsx
delete mode 100644 src/hooks/mutations/useWithdrawFunds.tsx
delete mode 100644 src/hooks/queries/useAllBalances.tsx
delete mode 100644 src/hooks/queries/useAllowedCoins.tsx
delete mode 100644 src/hooks/queries/useBroadcast.tsx
delete mode 100644 src/hooks/queries/useCreditAccountPositions.tsx
delete mode 100644 src/hooks/queries/useCreditAccounts.tsx
delete mode 100644 src/hooks/queries/useEstimateFee.tsx
delete mode 100644 src/hooks/queries/useMarkets.tsx
delete mode 100644 src/hooks/queries/useRedbankBalances.tsx
delete mode 100644 src/hooks/queries/useTokenPrices.tsx
rename src/hooks/{data => }/useAnimations.tsx (100%)
rename src/hooks/{useParams.ts => useParams.tsx} (100%)
delete mode 100644 src/types/generated/mars-account-nft/MarsAccountNft.react-query.ts
delete mode 100644 src/types/generated/mars-credit-manager/MarsCreditManager.react-query.ts
delete mode 100644 src/types/generated/mars-mock-credit-manager/MarsMockCreditManager.react-query.ts
delete mode 100644 src/types/generated/mars-mock-oracle/MarsMockOracle.react-query.ts
delete mode 100644 src/types/generated/mars-mock-red-bank/MarsMockRedBank.react-query.ts
delete mode 100644 src/types/generated/mars-mock-vault/MarsMockVault.react-query.ts
delete mode 100644 src/types/generated/mars-rover-health-computer/MarsRoverHealthComputer.react-query.ts
delete mode 100644 src/types/generated/mars-rover-health-types/MarsRoverHealthTypes.react-query.ts
delete mode 100644 src/types/generated/mars-swapper-base/MarsSwapperBase.react-query.ts
delete mode 100644 src/types/generated/mars-zapper-base/MarsZapperBase.react-query.ts
diff --git a/package.json b/package.json
index 67d41701..71478211 100644
--- a/package.json
+++ b/package.json
@@ -14,14 +14,11 @@
"@cosmjs/cosmwasm-stargate": "^0.30.1",
"@cosmjs/stargate": "^0.30.1",
"@marsprotocol/wallet-connector": "^1.5.2",
- "@radix-ui/react-slider": "^1.1.1",
"@sentry/nextjs": "^7.44.2",
- "@tanstack/react-query": "^4.28.0",
"@tanstack/react-table": "^8.7.9",
"@tippyjs/react": "^4.2.6",
"bignumber.js": "^9.1.1",
"classnames": "^2.3.2",
- "graphql": "^16.6.0",
"graphql-request": "^5.2.0",
"moment": "^2.29.4",
"next": "^13.2.4",
@@ -29,7 +26,6 @@
"react-device-detect": "^2.2.3",
"react-dom": "^18.2.0",
"react-draggable": "^4.4.5",
- "react-number-format": "^5.1.4",
"react-spring": "^9.7.1",
"react-toastify": "^9.1.2",
"react-use-clipboard": "^1.0.9",
diff --git a/src/components/Account/RiskChart.tsx b/src/components/Account/RiskChart.tsx
index 89007d4e..a6b77e93 100644
--- a/src/components/Account/RiskChart.tsx
+++ b/src/components/Account/RiskChart.tsx
@@ -12,13 +12,12 @@ import {
import { formatValue } from 'utils/formatters'
import { FormattedNumber } from 'components/FormattedNumber'
import { Text } from 'components/Text'
-import { useAccountStats } from 'hooks/data/useAccountStats'
import useStore from 'store'
export const RiskChart = ({ data }: RiskChartProps) => {
const enableAnimations = useStore((s) => s.enableAnimations)
- const accountStats = useAccountStats()
- const currentRisk = accountStats?.risk ?? 0
+ const accountStats = null
+ const currentRisk = 0
return (
diff --git a/src/components/Navigation/DesktopNavigation.tsx b/src/components/Navigation/DesktopNavigation.tsx
index 402884d9..8d2ba2b9 100644
--- a/src/components/Navigation/DesktopNavigation.tsx
+++ b/src/components/Navigation/DesktopNavigation.tsx
@@ -9,7 +9,7 @@ import { Logo } from 'components/Icons'
import { NavLink } from 'components/Navigation/NavLink'
import Settings from 'components/Settings'
import Wallet from 'components/Wallet/Wallet'
-import { useAnimations } from 'hooks/data/useAnimations'
+import { useAnimations } from 'hooks/useAnimations'
import { getRoute } from 'utils/route'
export const menuTree: { href: RouteSegment; label: string }[] = [
diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx
index 0f27cdf9..5f70a54f 100644
--- a/src/components/Settings.tsx
+++ b/src/components/Settings.tsx
@@ -9,7 +9,7 @@ import Switch from 'components/Switch'
import { Text } from 'components/Text'
import { Tooltip } from 'components/Tooltip'
import { ENABLE_ANIMATIONS_KEY } from 'constants/localStore'
-import { useAnimations } from 'hooks/data/useAnimations'
+import { useAnimations } from 'hooks/useAnimations'
import useStore from 'store'
export default function Settings() {
diff --git a/src/hooks/data/useAccountStats.tsx b/src/hooks/data/useAccountStats.tsx
deleted file mode 100644
index 5a4b763f..00000000
--- a/src/hooks/data/useAccountStats.tsx
+++ /dev/null
@@ -1,255 +0,0 @@
-import BigNumber from 'bignumber.js'
-import { useMemo } from 'react'
-
-import { useCreditAccountPositions } from 'hooks/queries/useCreditAccountPositions'
-import { useMarkets } from 'hooks/queries/useMarkets'
-import { useTokenPrices } from 'hooks/queries/useTokenPrices'
-import useStore from 'store'
-
-// displaying 3 levels of risk based on the weighted average of liquidation LTVs
-// 0.85 -> 25% risk
-// 0.65 - 0.85 -> 50% risk
-// < 0.65 -> 100% risk
-const getRiskFromAverageLiquidationLTVs = (value: number) => {
- if (value >= 0.85) return 0.25
- if (value > 0.65) return 0.5
- return 1
-}
-
-type Asset = {
- amount: string
- denom: string
- liquidationThreshold: string
- basePrice: number
-}
-
-type Debt = {
- amount: string
- denom: string
- basePrice: number
-}
-
-const calculateStatsFromAccountPositions = (assets: Asset[], debts: Debt[]) => {
- const totalPosition = assets.reduce((acc, asset) => {
- const tokenTotalValue = BigNumber(asset.amount).times(asset.basePrice)
-
- return BigNumber(tokenTotalValue).plus(acc).toNumber()
- }, 0)
-
- const totalDebt = debts.reduce((acc, debt) => {
- const tokenTotalValue = BigNumber(debt.amount).times(debt.basePrice)
-
- return BigNumber(tokenTotalValue).plus(acc).toNumber()
- }, 0)
-
- const totalWeightedPositions = assets.reduce((acc, asset) => {
- const assetWeightedValue = BigNumber(asset.amount)
- .times(asset.basePrice)
- .times(asset.liquidationThreshold)
-
- return assetWeightedValue.plus(acc).toNumber()
- }, 0)
-
- const netWorth = BigNumber(totalPosition).minus(totalDebt).toNumber()
-
- const liquidationLTVsWeightedAverage =
- totalWeightedPositions === 0
- ? 0
- : BigNumber(totalWeightedPositions).div(totalPosition).toNumber()
-
- const maxLeverage = BigNumber(1)
- .div(BigNumber(1).minus(liquidationLTVsWeightedAverage))
- .toNumber()
- const currentLeverage = netWorth === 0 ? 0 : BigNumber(totalPosition).div(netWorth).toNumber()
- const health =
- maxLeverage === 0
- ? 1
- : BigNumber(1).minus(BigNumber(currentLeverage).div(maxLeverage)).toNumber() || 1
-
- const risk = liquidationLTVsWeightedAverage
- ? getRiskFromAverageLiquidationLTVs(liquidationLTVsWeightedAverage)
- : 0
-
- return {
- health,
- maxLeverage,
- currentLeverage,
- netWorth,
- risk,
- totalPosition,
- totalDebt,
- }
-}
-
-export const useAccountStats = (actions?: AccountStatsAction[]) => {
- const selectedAccount = useStore((s) => s.selectedAccount)
-
- const { data: positionsData } = useCreditAccountPositions(selectedAccount ?? '')
- const { data: marketsData } = useMarkets()
- const { data: tokenPrices } = useTokenPrices()
-
- const currentStats = useMemo(() => {
- if (!marketsData || !tokenPrices || !positionsData) return null
-
- const assets = positionsData.coins.map((coin) => {
- const market = marketsData[coin.denom]
-
- return {
- amount: coin.amount,
- denom: coin.denom,
- liquidationThreshold: market.liquidation_threshold,
- basePrice: tokenPrices[coin.denom],
- }
- })
-
- const debts = positionsData.debts.map((debt) => {
- return {
- amount: debt.amount,
- denom: debt.denom,
- basePrice: tokenPrices[debt.denom],
- }
- })
-
- const { health, maxLeverage, currentLeverage, netWorth, risk, totalPosition, totalDebt } =
- calculateStatsFromAccountPositions(assets, debts)
-
- return {
- health,
- maxLeverage,
- currentLeverage,
- netWorth,
- risk,
- totalPosition,
- totalDebt,
- assets,
- debts,
- }
- }, [marketsData, positionsData, tokenPrices])
-
- const actionResultStats = useMemo(() => {
- if (!actions) return null
- if (!tokenPrices || !marketsData || !positionsData) return null
-
- let resultPositionsCoins = positionsData.coins.map((coin) => ({ ...coin }))
- let resultPositionsDebts = positionsData.debts.map((debt) => {
- const { shares, ...otherProps } = debt
- return { ...otherProps }
- })
-
- actions.forEach((action) => {
- if (action.amount === 0) return
-
- if (action.type === 'deposit') {
- const index = resultPositionsCoins.findIndex((coin) => coin.denom === action.denom)
-
- if (index !== -1) {
- resultPositionsCoins[index].amount = BigNumber(resultPositionsCoins[index].amount)
- .plus(action.amount)
- .toFixed()
- } else {
- resultPositionsCoins.push({
- amount: action.amount.toString(),
- denom: action.denom,
- })
- }
-
- return
- }
-
- if (action.type === 'withdraw') {
- const index = resultPositionsCoins.findIndex((coin) => coin.denom === action.denom)
-
- if (index !== -1) {
- resultPositionsCoins[index].amount = BigNumber(resultPositionsCoins[index].amount)
- .minus(action.amount)
- .toFixed()
- } else {
- throw new Error('Cannot withdraw more than you have')
- }
-
- return
- }
-
- if (action.type === 'borrow') {
- const indexDebts = resultPositionsDebts.findIndex((coin) => coin.denom === action.denom)
- const indexPositions = resultPositionsCoins.findIndex((coin) => coin.denom === action.denom)
-
- if (indexDebts !== -1) {
- resultPositionsDebts[indexDebts].amount = BigNumber(
- resultPositionsDebts[indexDebts].amount,
- )
- .plus(action.amount)
- .toFixed()
- } else {
- resultPositionsDebts.push({
- amount: action.amount.toString(),
- denom: action.denom,
- })
- }
-
- if (indexPositions !== -1) {
- resultPositionsCoins[indexPositions].amount = BigNumber(
- resultPositionsCoins[indexPositions].amount,
- )
- .plus(action.amount)
- .toFixed()
- } else {
- resultPositionsCoins.push({
- amount: action.amount.toString(),
- denom: action.denom,
- })
- }
-
- return
- }
-
- // TODO: repay
- if (action.type === 'repay') {
- const index = resultPositionsDebts.findIndex((coin) => coin.denom === action.denom)
- resultPositionsDebts[index].amount = BigNumber(resultPositionsDebts[index].amount)
- .minus(action.amount)
- .toFixed()
-
- return
- }
- })
-
- const assets = resultPositionsCoins
- .filter((coin) => coin.amount !== '0')
- .map((coin) => {
- const market = marketsData[coin.denom]
-
- return {
- amount: coin.amount,
- denom: coin.denom,
- liquidationThreshold: market.liquidation_threshold,
- basePrice: tokenPrices[coin.denom],
- }
- })
-
- const debts = resultPositionsDebts.map((debt) => {
- return {
- amount: debt.amount,
- denom: debt.denom,
- basePrice: tokenPrices[debt.denom],
- }
- })
-
- const { health, maxLeverage, currentLeverage, netWorth, risk, totalPosition, totalDebt } =
- calculateStatsFromAccountPositions(assets, debts)
-
- return {
- health,
- maxLeverage,
- currentLeverage,
- netWorth,
- risk,
- totalPosition,
- totalDebt,
- assets,
- debts,
- }
- }, [actions, marketsData, positionsData, tokenPrices])
-
- return actionResultStats || currentStats
-}
diff --git a/src/hooks/data/useCalculateMaxBorrowAmount.tsx b/src/hooks/data/useCalculateMaxBorrowAmount.tsx
deleted file mode 100644
index 2086d054..00000000
--- a/src/hooks/data/useCalculateMaxBorrowAmount.tsx
+++ /dev/null
@@ -1,104 +0,0 @@
-import BigNumber from 'bignumber.js'
-import { useCallback, useMemo } from 'react'
-
-import { useCreditAccountPositions } from 'hooks/queries/useCreditAccountPositions'
-import { useMarkets } from 'hooks/queries/useMarkets'
-import { useRedbankBalances } from 'hooks/queries/useRedbankBalances'
-import { useTokenPrices } from 'hooks/queries/useTokenPrices'
-import { getTokenDecimals } from 'utils/tokens'
-import useStore from 'store'
-import { getMarketAssets } from 'utils/assets'
-
-const getApproximateHourlyInterest = (amount: string, borrowAPY: string) => {
- const hourlyAPY = BigNumber(borrowAPY).div(24 * 365)
-
- return hourlyAPY.times(amount).toNumber()
-}
-
-export const useCalculateMaxBorrowAmount = (denom: string, isUnderCollateralized: boolean) => {
- const selectedAccount = useStore((s) => s.selectedAccount)
- const marketAssets = getMarketAssets()
-
- const { data: positionsData } = useCreditAccountPositions(selectedAccount ?? '')
- const { data: marketsData } = useMarkets()
- const { data: tokenPrices } = useTokenPrices()
- const { data: redbankBalances } = useRedbankBalances()
-
- const getTokenValue = useCallback(
- (amount: string, denom: string) => {
- if (!tokenPrices) return 0
-
- return BigNumber(amount).times(tokenPrices[denom]).toNumber()
- },
- [tokenPrices],
- )
-
- return useMemo(() => {
- if (!marketsData || !tokenPrices || !positionsData || !redbankBalances) return 0
-
- // max ltv adjusted collateral
- const totalWeightedPositions = positionsData?.coins.reduce((acc, coin) => {
- const tokenWeightedValue = BigNumber(getTokenValue(coin.amount, coin.denom)).times(
- Number(marketsData[coin.denom].max_loan_to_value),
- )
-
- return tokenWeightedValue.plus(acc).toNumber()
- }, 0)
-
- // approximate debt value in an hour timespan to avoid throwing on smart contract level
- // due to debt interest being applied
- const totalLiabilitiesValue = positionsData?.debts.reduce((acc, coin) => {
- const estimatedInterestAmount = getApproximateHourlyInterest(
- coin.amount,
- marketsData[coin.denom].borrow_rate,
- )
-
- const tokenDebtValue = BigNumber(getTokenValue(coin.amount, coin.denom)).plus(
- estimatedInterestAmount,
- )
-
- return tokenDebtValue.plus(acc).toNumber()
- }, 0)
-
- const borrowTokenPrice = tokenPrices[denom]
- const tokenDecimals = getTokenDecimals(denom, marketAssets)
-
- let maxAmountCapacity
- if (isUnderCollateralized) {
- // MAX TO CREDIT ACCOUNT
- maxAmountCapacity = BigNumber(totalLiabilitiesValue)
- .minus(totalWeightedPositions)
- .div(borrowTokenPrice * Number(marketsData[denom].max_loan_to_value) - borrowTokenPrice)
- } else {
- // MAX TO WALLET
- maxAmountCapacity = BigNumber(totalWeightedPositions)
- .minus(totalLiabilitiesValue)
- .div(borrowTokenPrice)
- }
-
- const marketLiquidity = BigNumber(
- redbankBalances?.find((asset) => asset.denom.toLowerCase() === denom.toLowerCase())?.amount ||
- 0,
- )
-
- const maxBorrowAmount = maxAmountCapacity.gt(marketLiquidity)
- ? marketLiquidity
- : maxAmountCapacity.gt(0)
- ? maxAmountCapacity
- : 0
-
- return BigNumber(maxBorrowAmount)
- .dividedBy(10 ** tokenDecimals)
- .decimalPlaces(tokenDecimals)
- .toNumber()
- }, [
- denom,
- getTokenValue,
- isUnderCollateralized,
- marketsData,
- positionsData,
- redbankBalances,
- tokenPrices,
- marketAssets,
- ])
-}
diff --git a/src/hooks/data/useCalculateMaxTradeAmount.tsx b/src/hooks/data/useCalculateMaxTradeAmount.tsx
deleted file mode 100644
index caf8fce3..00000000
--- a/src/hooks/data/useCalculateMaxTradeAmount.tsx
+++ /dev/null
@@ -1,145 +0,0 @@
-import BigNumber from 'bignumber.js'
-import { useCallback, useMemo } from 'react'
-
-import { useCreditAccountPositions } from 'hooks/queries/useCreditAccountPositions'
-import { useMarkets } from 'hooks/queries/useMarkets'
-import { useRedbankBalances } from 'hooks/queries/useRedbankBalances'
-import { useTokenPrices } from 'hooks/queries/useTokenPrices'
-import useStore from 'store'
-
-const getApproximateHourlyInterest = (amount: string, borrowAPY: string) => {
- const hourlyAPY = BigNumber(borrowAPY).div(24 * 365)
-
- return hourlyAPY.times(amount).toNumber()
-}
-
-// max trade amount doesnt consider wallet balance as its not relevant
-// the entire token balance within the wallet will always be able to be fully swapped
-export const useCalculateMaxTradeAmount = (
- tokenIn: string,
- tokenOut: string,
- isMargin: boolean,
-) => {
- const selectedAccount = useStore((s) => s.selectedAccount)
-
- const { data: positionsData } = useCreditAccountPositions(selectedAccount ?? '')
- const { data: marketsData } = useMarkets()
- const { data: tokenPrices } = useTokenPrices()
- const { data: redbankBalances } = useRedbankBalances()
-
- const accountAmount = useMemo(() => {
- return BigNumber(
- positionsData?.coins?.find((coin) => coin.denom === tokenIn)?.amount ?? 0,
- ).toNumber()
- }, [positionsData, tokenIn])
-
- const getTokenValue = useCallback(
- (amount: string, denom: string) => {
- if (!tokenPrices) return 0
-
- return BigNumber(amount).times(tokenPrices[denom]).toNumber()
- },
- [tokenPrices],
- )
-
- return useMemo(() => {
- if (!marketsData || !tokenPrices || !positionsData || !redbankBalances || !tokenIn || !tokenOut)
- return 0
-
- const totalWeightedPositions = positionsData.coins.reduce((acc, coin) => {
- const tokenWeightedValue = BigNumber(getTokenValue(coin.amount, coin.denom)).times(
- Number(marketsData[coin.denom].max_loan_to_value),
- )
-
- return tokenWeightedValue.plus(acc).toNumber()
- }, 0)
-
- // approximate debt value in an hour timespan to avoid throwing on smart contract level
- // due to debt interest being applied
- const totalLiabilitiesValue = positionsData.debts.reduce((acc, coin) => {
- const estimatedInterestAmount = getApproximateHourlyInterest(
- coin.amount,
- marketsData[coin.denom].borrow_rate,
- )
-
- const tokenDebtValue = BigNumber(getTokenValue(coin.amount, coin.denom)).plus(
- estimatedInterestAmount,
- )
-
- return tokenDebtValue.plus(acc).toNumber()
- }, 0)
-
- const tokenOutLTV = Number(marketsData[tokenOut].max_loan_to_value)
- const tokenInLTV = Number(marketsData[tokenIn].max_loan_to_value)
-
- // if the target token ltv higher, the full amount will always be able to be swapped
- if (tokenOutLTV < tokenInLTV) {
- // in theory, the most you can swap from x to y while keeping an health factor of 1
- const maxSwapValue = BigNumber(totalLiabilitiesValue)
- .minus(totalWeightedPositions)
- .dividedBy(tokenOutLTV - tokenInLTV)
-
- const maxSwapAmount = maxSwapValue.div(tokenPrices[tokenIn]).decimalPlaces(0)
-
- // if the swappable amount is lower than the account amount, any further calculations are irrelevant
- if (maxSwapAmount.isLessThanOrEqualTo(accountAmount)) return maxSwapAmount.toNumber()
- }
-
- // if margin is disabled, the max swap amount is capped at the account amount
- if (!isMargin) {
- return accountAmount
- }
-
- const estimatedTokenOutAmount = BigNumber(accountAmount).times(
- tokenPrices[tokenIn] / tokenPrices[tokenOut],
- )
-
- let positionsCoins = [...positionsData.coins]
-
- // if the target token is not in the account, add it to the positions
- if (!positionsCoins.find((coin) => coin.denom === tokenOut)) {
- positionsCoins.push({
- amount: '0',
- denom: tokenOut,
- })
- }
-
- // calculate weighted positions assuming the initial swap is made
- const totalWeightedPositionsAfterSwap = positionsCoins
- .filter((coin) => coin.denom !== tokenIn)
- .reduce((acc, coin) => {
- const coinAmount =
- coin.denom === tokenOut
- ? BigNumber(coin.amount).plus(estimatedTokenOutAmount).toString()
- : coin.amount
-
- const tokenWeightedValue = BigNumber(getTokenValue(coinAmount, coin.denom)).times(
- Number(marketsData[coin.denom].max_loan_to_value),
- )
-
- return tokenWeightedValue.plus(acc).toNumber()
- }, 0)
-
- const maxBorrowValue =
- totalWeightedPositionsAfterSwap === 0
- ? 0
- : BigNumber(totalWeightedPositionsAfterSwap)
- .minus(totalLiabilitiesValue)
- .dividedBy(1 - tokenOutLTV)
- .toNumber()
-
- const maxBorrowAmount = BigNumber(maxBorrowValue).dividedBy(tokenPrices[tokenIn]).toNumber()
-
- return BigNumber(accountAmount).plus(maxBorrowAmount).decimalPlaces(0).toNumber()
- }, [
- accountAmount,
- getTokenValue,
- isMargin,
- marketsData,
- positionsData,
- redbankBalances,
- tokenIn,
- tokenOut,
- tokenPrices,
- ])
-}
diff --git a/src/hooks/data/useCalculateMaxWithdrawAmount.tsx b/src/hooks/data/useCalculateMaxWithdrawAmount.tsx
deleted file mode 100644
index bb9d05dd..00000000
--- a/src/hooks/data/useCalculateMaxWithdrawAmount.tsx
+++ /dev/null
@@ -1,137 +0,0 @@
-import BigNumber from 'bignumber.js'
-import { useCallback, useMemo } from 'react'
-
-import { useCreditAccountPositions } from 'hooks/queries/useCreditAccountPositions'
-import { useMarkets } from 'hooks/queries/useMarkets'
-import { useRedbankBalances } from 'hooks/queries/useRedbankBalances'
-import { useTokenPrices } from 'hooks/queries/useTokenPrices'
-import { getTokenDecimals } from 'utils/tokens'
-import useStore from 'store'
-import { getMarketAssets } from 'utils/assets'
-
-const getApproximateHourlyInterest = (amount: string, borrowAPY: string) => {
- const hourlyAPY = BigNumber(borrowAPY).div(24 * 365)
-
- return hourlyAPY.times(amount).toNumber()
-}
-
-export const useCalculateMaxWithdrawAmount = (denom: string, borrow: boolean) => {
- const selectedAccount = useStore((s) => s.selectedAccount)
- const marketAssets = getMarketAssets()
-
- const { data: positionsData } = useCreditAccountPositions(selectedAccount ?? '')
- const { data: marketsData } = useMarkets()
- const { data: tokenPrices } = useTokenPrices()
- const { data: redbankBalances } = useRedbankBalances()
-
- const tokenDecimals = getTokenDecimals(denom, marketAssets)
-
- const getTokenValue = useCallback(
- (amount: string, denom: string) => {
- if (!tokenPrices) return 0
-
- return BigNumber(amount).times(tokenPrices[denom]).toNumber()
- },
- [tokenPrices],
- )
-
- const tokenAmountInCreditAccount = useMemo(() => {
- return positionsData?.coins.find((coin) => coin.denom === denom)?.amount ?? 0
- }, [denom, positionsData])
-
- const maxAmount = useMemo(() => {
- if (!marketsData || !tokenPrices || !positionsData || !redbankBalances || !denom) return 0
-
- const hasDebt = positionsData.debts.length > 0
-
- const borrowTokenPrice = tokenPrices[denom]
- const borrowTokenMaxLTV = Number(marketsData[denom].max_loan_to_value)
-
- // approximate debt value in an hour timespan to avoid throwing on smart contract level
- // due to debt interest being applied
- const totalLiabilitiesValue = positionsData?.debts.reduce((acc, coin) => {
- const estimatedInterestAmount = getApproximateHourlyInterest(
- coin.amount,
- marketsData[coin.denom].borrow_rate,
- )
- const tokenDebtValue = BigNumber(getTokenValue(coin.amount, coin.denom)).plus(
- estimatedInterestAmount,
- )
-
- return tokenDebtValue.plus(acc).toNumber()
- }, 0)
-
- const positionsWeightedAverageWithoutAsset = positionsData?.coins.reduce((acc, coin) => {
- if (coin.denom === denom) return acc
-
- const tokenWeightedValue = BigNumber(getTokenValue(coin.amount, coin.denom)).times(
- Number(marketsData[coin.denom].max_loan_to_value),
- )
-
- return tokenWeightedValue.plus(acc).toNumber()
- }, 0)
-
- const isHealthyAfterFullWithdraw = !hasDebt
- ? true
- : positionsWeightedAverageWithoutAsset / totalLiabilitiesValue > 1
-
- let maxAmountCapacity = 0
-
- if (isHealthyAfterFullWithdraw) {
- const maxBorrow = BigNumber(positionsWeightedAverageWithoutAsset)
- .minus(totalLiabilitiesValue)
- .div(borrowTokenPrice)
-
- maxAmountCapacity = maxBorrow
- .plus(tokenAmountInCreditAccount)
- .decimalPlaces(tokenDecimals)
- .toNumber()
- } else {
- const requiredCollateral = BigNumber(totalLiabilitiesValue)
- .minus(positionsWeightedAverageWithoutAsset)
- .dividedBy(borrowTokenPrice * borrowTokenMaxLTV)
-
- maxAmountCapacity = BigNumber(tokenAmountInCreditAccount)
- .minus(requiredCollateral)
- .decimalPlaces(tokenDecimals)
- .toNumber()
-
- // required collateral might be greater than the amount in the credit account which will result
- // in a negative max amount capacity
- maxAmountCapacity = maxAmountCapacity < 0 ? 0 : maxAmountCapacity
- }
-
- const marketLiquidity = BigNumber(
- redbankBalances?.find((asset) => asset.denom.toLowerCase() === denom.toLowerCase())?.amount ||
- 0,
- )
-
- const maxWithdrawAmount = BigNumber(maxAmountCapacity).gt(marketLiquidity)
- ? marketLiquidity
- : maxAmountCapacity
- const isMaxAmountHigherThanBalance = BigNumber(maxWithdrawAmount).gt(tokenAmountInCreditAccount)
-
- if (!borrow && isMaxAmountHigherThanBalance) {
- return BigNumber(tokenAmountInCreditAccount)
- .div(10 ** tokenDecimals)
- .toNumber()
- }
-
- return BigNumber(maxWithdrawAmount)
- .div(10 ** tokenDecimals)
- .decimalPlaces(tokenDecimals)
- .toNumber()
- }, [
- borrow,
- denom,
- getTokenValue,
- marketsData,
- positionsData,
- redbankBalances,
- tokenAmountInCreditAccount,
- tokenDecimals,
- tokenPrices,
- ])
-
- return maxAmount
-}
diff --git a/src/hooks/mutations/useBorrowFunds.tsx b/src/hooks/mutations/useBorrowFunds.tsx
deleted file mode 100644
index 05db265e..00000000
--- a/src/hooks/mutations/useBorrowFunds.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
-import { useMemo } from 'react'
-
-import useStore from 'store'
-import { queryKeys } from 'types/query-keys-factory'
-import { hardcodedFee } from 'utils/contants'
-
-export const useBorrowFunds = (
- amount: number,
- denom: string,
- withdraw = false,
- options: Omit
,
-) => {
- const creditManagerClient = useStore((s) => s.clients.creditManager)
- const selectedAccount = useStore((s) => s.selectedAccount ?? '')
- const address = useStore((s) => s.address)
- const queryClient = useQueryClient()
- const actions = useMemo(() => {
- if (!withdraw) {
- return [
- {
- borrow: {
- denom: denom,
- amount: String(amount),
- },
- },
- ]
- }
- return [
- {
- borrow: {
- denom: denom,
- amount: String(amount),
- },
- },
- {
- withdraw: {
- denom: denom,
- amount: String(amount),
- },
- },
- ]
- }, [withdraw, denom, amount])
- return useMutation(
- async () =>
- await creditManagerClient?.updateCreditAccount(
- { accountId: selectedAccount, actions },
- hardcodedFee,
- ),
- {
- onSettled: () => {
- queryClient.invalidateQueries(queryKeys.creditAccountsPositions(selectedAccount))
- queryClient.invalidateQueries(queryKeys.redbankBalances())
- // if withdrawing to wallet, need to explicility invalidate balances queries
- if (withdraw) {
- queryClient.invalidateQueries(queryKeys.tokenBalance(address ?? '', denom))
- queryClient.invalidateQueries(queryKeys.allBalances(address ?? ''))
- }
- },
- onError: (err: Error) => {
- useStore.setState({
- toast: { message: err.message, isError: true },
- })
- },
- ...options,
- },
- )
-}
diff --git a/src/hooks/mutations/useRepayFunds.tsx b/src/hooks/mutations/useRepayFunds.tsx
deleted file mode 100644
index a42b0489..00000000
--- a/src/hooks/mutations/useRepayFunds.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
-import { useMemo } from 'react'
-
-import useStore from 'store'
-import { queryKeys } from 'types/query-keys-factory'
-import { hardcodedFee } from 'utils/contants'
-
-export const useRepayFunds = (
- amount: number,
- denom: string,
- options: Omit,
-) => {
- const creditManagerClient = useStore((s) => s.clients.creditManager)
- const selectedAccount = useStore((s) => s.selectedAccount ?? '')
- const address = useStore((s) => s.address)
- const queryClient = useQueryClient()
- const actions = useMemo(() => {
- return [
- {
- deposit: {
- denom: denom,
- amount: String(amount),
- },
- },
- {
- repay: {
- denom: denom,
- amount: {
- exact: String(amount),
- },
- },
- },
- ]
- }, [amount, denom])
- return useMutation(
- async () =>
- await creditManagerClient?.updateCreditAccount(
- { accountId: selectedAccount, actions },
- hardcodedFee,
- undefined,
- [
- {
- denom,
- amount: String(amount),
- },
- ],
- ),
- {
- onSettled: () => {
- queryClient.invalidateQueries(queryKeys.creditAccountsPositions(selectedAccount))
- queryClient.invalidateQueries(queryKeys.tokenBalance(address ?? '', denom))
- queryClient.invalidateQueries(queryKeys.allBalances(address ?? ''))
- queryClient.invalidateQueries(queryKeys.redbankBalances())
- },
- onError: (err: Error) => {
- useStore.setState({
- toast: { message: err.message, isError: true },
- })
- },
- ...options,
- },
- )
-}
diff --git a/src/hooks/mutations/useTradeAsset.tsx b/src/hooks/mutations/useTradeAsset.tsx
deleted file mode 100644
index 97cd2bc5..00000000
--- a/src/hooks/mutations/useTradeAsset.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
-import { useMemo } from 'react'
-
-import useStore from 'store'
-import { Action } from 'types/generated/mars-credit-manager/MarsCreditManager.types'
-import { queryKeys } from 'types/query-keys-factory'
-import { hardcodedFee } from 'utils/contants'
-
-export const useTradeAsset = (
- amount: number,
- borrowAmount: number,
- depositAmount: number,
- tokenIn: string,
- tokenOut: string,
- slippage: number,
- options?: Omit,
-) => {
- const creditManagerClient = useStore((s) => s.clients.creditManager)
- const selectedAccount = useStore((s) => s.selectedAccount ?? '')
- const queryClient = useQueryClient()
- // actions need to be executed in order deposit -> borrow -> swap
- // first two are optional
- const actions = useMemo(() => {
- const actionsBase = [
- {
- swap_exact_in: {
- coin_in: { amount: String(amount), denom: tokenIn },
- denom_out: tokenOut,
- slippage: String(slippage),
- },
- },
- ] as Action[]
- if (borrowAmount > 0) {
- actionsBase.unshift({
- borrow: {
- denom: tokenIn,
- amount: String(borrowAmount),
- },
- })
- }
- if (depositAmount > 0) {
- actionsBase.unshift({
- deposit: {
- denom: tokenIn,
- amount: String(depositAmount),
- },
- })
- }
- return actionsBase
- }, [amount, tokenIn, tokenOut, slippage, borrowAmount, depositAmount])
- return useMutation(
- async () =>
- await creditManagerClient?.updateCreditAccount(
- { accountId: selectedAccount, actions },
- hardcodedFee,
- undefined,
- depositAmount > 0
- ? [
- {
- denom: tokenIn,
- amount: String(depositAmount),
- },
- ]
- : undefined,
- ),
- {
- onSettled: () => {
- queryClient.invalidateQueries(queryKeys.creditAccountsPositions(selectedAccount))
- queryClient.invalidateQueries(queryKeys.redbankBalances())
- },
- onError: (err: Error) => {
- useStore.setState({
- toast: { message: err.message, isError: true },
- })
- },
- ...options,
- },
- )
-}
diff --git a/src/hooks/mutations/useWithdrawFunds.tsx b/src/hooks/mutations/useWithdrawFunds.tsx
deleted file mode 100644
index f41679fa..00000000
--- a/src/hooks/mutations/useWithdrawFunds.tsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import { useMutation, useQueryClient } from '@tanstack/react-query'
-import { useMemo } from 'react'
-
-import useStore from 'store'
-import { queryKeys } from 'types/query-keys-factory'
-import { hardcodedFee } from 'utils/contants'
-
-export const useWithdrawFunds = (
- amount: number,
- borrowAmount: number,
- denom: string,
- options?: {
- onSuccess?: () => void
- },
-) => {
- const selectedAccount = useStore((s) => s.selectedAccount ?? '')
- const address = useStore((s) => s.address)
- const creditManagerClient = useStore((s) => s.clients.creditManager)
- const queryClient = useQueryClient()
- const actions = useMemo(() => {
- if (borrowAmount > 0) {
- return [
- {
- borrow: {
- denom,
- amount: String(borrowAmount),
- },
- },
- {
- withdraw: {
- denom,
- amount: String(amount),
- },
- },
- ]
- }
- return [
- {
- withdraw: {
- denom,
- amount: String(amount),
- },
- },
- ]
- }, [amount, borrowAmount, denom])
- const { onSuccess } = { ...options }
- return useMutation(
- async () =>
- creditManagerClient?.updateCreditAccount(
- { accountId: selectedAccount, actions },
- hardcodedFee,
- ),
- {
- onSuccess: () => {
- queryClient.invalidateQueries(queryKeys.creditAccountsPositions(selectedAccount))
- queryClient.invalidateQueries(queryKeys.tokenBalance(address ?? '', denom))
- queryClient.invalidateQueries(queryKeys.allBalances(address ?? ''))
- queryClient.invalidateQueries(queryKeys.redbankBalances())
- onSuccess && onSuccess()
- },
- onError: (err: Error) => {
- useStore.setState({
- toast: { message: err.message, isError: true },
- })
- },
- },
- )
-}
diff --git a/src/hooks/queries/useAllBalances.tsx b/src/hooks/queries/useAllBalances.tsx
deleted file mode 100644
index b6c7b72b..00000000
--- a/src/hooks/queries/useAllBalances.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-import { Coin } from '@cosmjs/stargate'
-import { useQuery } from '@tanstack/react-query'
-import request, { gql } from 'graphql-request'
-import { useMemo } from 'react'
-
-import { ENV } from 'constants/env'
-import useStore from 'store'
-import { queryKeys } from 'types/query-keys-factory'
-
-interface UserBalanceData {
- balance: {
- balance: Coin[]
- }
-}
-
-export const useAllBalances = () => {
- const address = useStore((s) => s.address)
-
- const result = useQuery(
- queryKeys.allBalances(address ?? ''),
- async () => {
- return await request(
- ENV.URL_GQL!,
- gql`
- query UserBalanceQuery {
- balance: bank {
- balance(
- address: "${address}"
- ) {
- amount
- denom
- }
- }
- }
- `,
- )
- },
- {
- enabled: !!address,
- staleTime: 30000,
- refetchInterval: 30000,
- },
- )
- return {
- ...result,
- data: useMemo(() => result.data && result.data.balance.balance, [result.data]),
- }
-}
diff --git a/src/hooks/queries/useAllowedCoins.tsx b/src/hooks/queries/useAllowedCoins.tsx
deleted file mode 100644
index 971a39fb..00000000
--- a/src/hooks/queries/useAllowedCoins.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { useQuery } from '@tanstack/react-query'
-
-import { ENV } from 'constants/env'
-import useStore from 'store'
-import { queryKeys } from 'types/query-keys-factory'
-
-type Result = string[]
-
-const queryMsg = {
- allowed_coins: {},
-}
-
-export const useAllowedCoins = () => {
- const client = useStore((s) => s.signingClient)
- const creditManagerAddress = ENV.ADDRESS_CREDIT_MANAGER
-
- const result = useQuery(
- queryKeys.allowedCoins(),
- async () => client?.queryContractSmart(creditManagerAddress || '', queryMsg),
- {
- enabled: !!client,
- staleTime: Infinity,
- },
- )
-
- return {
- ...result,
- data: result?.data,
- }
-}
diff --git a/src/hooks/queries/useBroadcast.tsx b/src/hooks/queries/useBroadcast.tsx
deleted file mode 100644
index 4ae3603e..00000000
--- a/src/hooks/queries/useBroadcast.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import { MsgExecuteContract } from '@marsprotocol/wallet-connector'
-import { useQuery } from '@tanstack/react-query'
-import { isMobile } from 'react-device-detect'
-
-import useStore from 'store'
-import { queryKeys } from 'types/query-keys-factory'
-
-export const useBroadcast = (props: UseBroadcast) => {
- const client = useStore((s) => s.client)
- const userWalletAddress = useStore((s) => s.client?.recentWallet.account?.address)
- const sender = props.sender ?? userWalletAddress
-
- return useQuery(
- [queryKeys.broadcastMessages(), props.msg],
- async () => {
- if (!client || !props.contract || !props.msg || !props.fee || !sender) return
-
- try {
- const broadcastOptions = {
- messages: [
- new MsgExecuteContract({
- sender: sender,
- contract: props.contract,
- msg: props.msg,
- funds: props.funds,
- }),
- ],
- feeAmount: props.fee.amount[0].amount,
- gasLimit: props.fee.gas,
- memo: undefined,
- wallet: client.recentWallet,
- mobile: isMobile,
- }
-
- const result = await client.broadcast(broadcastOptions)
-
- if (result.hash) {
- return result
- }
- throw result.rawLogs
- } catch (e) {
- throw e
- }
- },
- {
- enabled: !!sender && !!client && !!props.msg && !!props.contract && !!props.fee,
- },
- )
-}
diff --git a/src/hooks/queries/useCreditAccountPositions.tsx b/src/hooks/queries/useCreditAccountPositions.tsx
deleted file mode 100644
index 9a0720dc..00000000
--- a/src/hooks/queries/useCreditAccountPositions.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { Coin } from '@cosmjs/stargate'
-import { useQuery } from '@tanstack/react-query'
-import { useMemo } from 'react'
-
-import { ENV } from 'constants/env'
-import useStore from 'store'
-import { queryKeys } from 'types/query-keys-factory'
-
-interface DebtAmount {
- amount: string
- denom: string
- shares: string
-}
-
-interface VaultPosition {
- locked: string
- unlocked: string
-}
-
-interface Result {
- account_id: string
- coins: Coin[]
- debts: DebtAmount[]
- vaults: VaultPosition[]
-}
-
-export const useCreditAccountPositions = (accountId: string) => {
- const address = useStore((s) => s.address)
- const client = useStore((s) => s.signingClient)
- const creditManagerAddress = ENV.ADDRESS_CREDIT_MANAGER
-
- const result = useQuery(
- queryKeys.creditAccountsPositions(accountId),
- async () =>
- client?.queryContractSmart(creditManagerAddress || '', {
- positions: {
- account_id: accountId,
- },
- }),
- {
- enabled: !!address && !!client,
- refetchInterval: 30000,
- staleTime: Infinity,
- },
- )
-
- return {
- ...result,
- data: useMemo(() => {
- if (!address) return
-
- return result?.data && { ...result.data }
- }, [result.data, address]),
- }
-}
diff --git a/src/hooks/queries/useCreditAccounts.tsx b/src/hooks/queries/useCreditAccounts.tsx
deleted file mode 100644
index 0580e1b2..00000000
--- a/src/hooks/queries/useCreditAccounts.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-'use client'
-
-import { useQuery } from '@tanstack/react-query'
-import { useMemo } from 'react'
-
-import { ENV } from 'constants/env'
-import useStore from 'store'
-import { queryKeys } from 'types/query-keys-factory'
-
-type Result = {
- tokens: string[]
-}
-
-export const useCreditAccounts = () => {
- const address = useStore((s) => s.address)
- const client = useStore((s) => s.signingClient)
- const selectedAccount = useStore((s) => s.selectedAccount)
- const accountNftAddress = ENV.ADDRESS_ACCOUNT_NFT
- const setSelectedAccount = (account: string) => {
- useStore.setState({ selectedAccount: account })
- }
-
- const queryMsg = useMemo(() => {
- return {
- tokens: {
- owner: address,
- },
- }
- }, [address])
-
- const result = useQuery(
- queryKeys.creditAccounts(address ?? ''),
- async () => client?.queryContractSmart(accountNftAddress || '', queryMsg),
- {
- staleTime: Infinity,
- enabled: !!address && !!client,
- onSuccess: (data) => {
- if (!data.tokens.includes(selectedAccount || '') && data.tokens.length > 0) {
- setSelectedAccount(data.tokens[0])
- }
- },
- },
- )
-
- return {
- ...result,
- data: useMemo(() => {
- if (!address) return []
-
- return result?.data && result.data.tokens
- }, [address, result?.data]),
- }
-}
diff --git a/src/hooks/queries/useEstimateFee.tsx b/src/hooks/queries/useEstimateFee.tsx
deleted file mode 100644
index fb242a05..00000000
--- a/src/hooks/queries/useEstimateFee.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import { MsgExecuteContract } from '@marsprotocol/wallet-connector'
-import { useQuery } from '@tanstack/react-query'
-import BigNumber from 'bignumber.js'
-
-import { GAS_ADJUSTMENT } from 'constants/gas'
-import useStore from 'store'
-import { queryKeys } from 'types/query-keys-factory'
-
-export const useEstimateFee = (props: UseEstimateFee) => {
- const client = useStore((s) => s.client)
- const userWalletAddress = useStore((s) => s.client?.recentWallet.account?.address)
- const sender = props.sender ?? userWalletAddress
-
- return useQuery(
- [queryKeys.estimateFee(), props.msg],
- async () => {
- const gasAdjustment = GAS_ADJUSTMENT
-
- if (!client || !props.contract || !props.msg || !sender) return
-
- try {
- const simulateOptions = {
- messages: [
- new MsgExecuteContract({
- sender: sender,
- contract: props.contract,
- msg: props.msg,
- funds: props.funds,
- }),
- ],
- wallet: client.recentWallet,
- }
-
- const result = await client.simulate(simulateOptions)
-
- if (result.success) {
- return {
- amount: result.fee ? result.fee.amount : [],
- gas: new BigNumber(result.fee ? result.fee.gas : 0)
- .multipliedBy(gasAdjustment)
- .toFixed(0),
- }
- }
- throw result.error
- } catch (e) {
- throw e
- }
- },
- {
- enabled: !!sender && !!client && !!props.msg && !!props.contract,
- },
- )
-}
diff --git a/src/hooks/queries/useMarkets.tsx b/src/hooks/queries/useMarkets.tsx
deleted file mode 100644
index 1d5b65b0..00000000
--- a/src/hooks/queries/useMarkets.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-import { useQuery } from '@tanstack/react-query'
-import { useMemo } from 'react'
-
-export const useMarkets = () => {
- const result = useQuery(
- ['marketInfo'],
- () => ({
- wasm: {
- uosmo: {
- denom: 'uosmo',
- max_loan_to_value: '0.55',
- liquidation_threshold: '0.65',
- liquidation_bonus: '0.1',
- reserve_factor: '0.2',
- interest_rate_model: {
- optimal_utilization_rate: '0.7',
- base: '0.3',
- slope_1: '0.25',
- slope_2: '0.3',
- },
- borrow_index: '1.009983590233269535',
- liquidity_index: '1.002073497939302451',
- borrow_rate: '0.350254719559196173',
- liquidity_rate: '0.039428374060840366',
- indexes_last_updated: 1668271634,
- collateral_total_scaled: '8275583285688290',
- debt_total_scaled: '1155363812346122',
- deposit_enabled: true,
- borrow_enabled: true,
- deposit_cap: '15000000000000',
- },
- 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2': {
- denom: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
- max_loan_to_value: '0.65',
- liquidation_threshold: '0.7',
- liquidation_bonus: '0.1',
- reserve_factor: '0.2',
- interest_rate_model: {
- optimal_utilization_rate: '0.1',
- base: '0.3',
- slope_1: '0.25',
- slope_2: '0.3',
- },
- borrow_index: '1.015550607619308095',
- liquidity_index: '1.003284932040106733',
- borrow_rate: '0.75632500115230499',
- liquidity_rate: '0.435023016254423759',
- indexes_last_updated: 1668273756,
- collateral_total_scaled: '3309105730887721',
- debt_total_scaled: '2350429206911653',
- deposit_enabled: true,
- borrow_enabled: true,
- deposit_cap: '15000000000000',
- },
- 'ibc/E6931F78057F7CC5DA0FD6CEF82FF39373A6E0452BF1FD76910B93292CF356C1': {
- denom: 'ibc/E6931F78057F7CC5DA0FD6CEF82FF39373A6E0452BF1FD76910B93292CF356C1',
- max_loan_to_value: '0.65',
- liquidation_threshold: '0.7',
- liquidation_bonus: '0.1',
- reserve_factor: '0.2',
- interest_rate_model: {
- optimal_utilization_rate: '0.1',
- base: '0.3',
- slope_1: '0.25',
- slope_2: '0.3',
- },
- borrow_index: '1.001519837645865043',
- liquidity_index: '1',
- borrow_rate: '0.3',
- liquidity_rate: '0',
- indexes_last_updated: 1667995650,
- collateral_total_scaled: '1000000000000000',
- debt_total_scaled: '0',
- deposit_enabled: true,
- borrow_enabled: true,
- deposit_cap: '15000000000000',
- },
- },
- }),
- {
- staleTime: Infinity,
- },
- )
-
- return {
- ...result,
- data: useMemo(() => {
- return result?.data && result.data.wasm
- }, [result.data]),
- }
-}
diff --git a/src/hooks/queries/useRedbankBalances.tsx b/src/hooks/queries/useRedbankBalances.tsx
deleted file mode 100644
index b1c809e0..00000000
--- a/src/hooks/queries/useRedbankBalances.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import { Coin } from '@cosmjs/stargate'
-import { useQuery } from '@tanstack/react-query'
-import request, { gql } from 'graphql-request'
-import { useMemo } from 'react'
-
-import { ENV } from 'constants/env'
-import { queryKeys } from 'types/query-keys-factory'
-
-interface Result {
- bank: {
- balance: Coin[]
- }
-}
-
-export const useRedbankBalances = () => {
- const redBankAddress = ENV.ADDRESS_RED_BANK
- const result = useQuery(
- queryKeys.redbankBalances(),
- async () => {
- return await request(
- ENV.URL_GQL!,
- gql`
- query RedbankBalances {
- bank {
- balance(
- address: "${redBankAddress}"
- ) {
- amount
- denom
- }
- }
- }
- `,
- )
- },
- {
- enabled: !!redBankAddress,
- staleTime: 30000,
- refetchInterval: 30000,
- },
- )
-
- return {
- ...result,
- data: useMemo(() => result.data && result.data.bank.balance, [result.data]),
- }
-}
diff --git a/src/hooks/queries/useTokenPrices.tsx b/src/hooks/queries/useTokenPrices.tsx
deleted file mode 100644
index 6129fa99..00000000
--- a/src/hooks/queries/useTokenPrices.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-import { useQuery } from '@tanstack/react-query'
-import { gql, request } from 'graphql-request'
-import { useMemo } from 'react'
-
-import { ENV } from 'constants/env'
-import { queryKeys } from 'types/query-keys-factory'
-import { getMarketAssets } from 'utils/assets'
-
-const fetchTokenPrices = async (
- hiveUrl: string,
- marketAssets: Asset[],
- oracleAddress: string,
-): Promise => {
- return request(
- hiveUrl,
- gql`
- query PriceOracle {
- prices: wasm {
- ${marketAssets.map((token) => {
- return `${token.symbol}: contractQuery(
- contractAddress: "${oracleAddress}"
- query: {
- price: {
- denom: "${token.denom}"
- }
- }
- )`
- })}
- }
- }
- `,
- )
-}
-
-export const useTokenPrices = () => {
- const marketAssets = getMarketAssets()
- const result = useQuery(
- queryKeys.tokenPrices(),
- async () => await fetchTokenPrices(ENV.URL_GQL!, marketAssets, ENV.ADDRESS_ORACLE || ''),
- {
- refetchInterval: 30000,
- staleTime: Infinity,
- },
- )
-
- return {
- ...result,
- data: useMemo(() => {
- if (!result.data) return
-
- return Object.values(result.data?.prices).reduce(
- (acc, entry) => ({
- ...acc,
- [entry.denom]: Number(entry.price),
- }),
- {},
- ) as { [key in string]: number }
- }, [result.data]),
- }
-}
diff --git a/src/hooks/data/useAnimations.tsx b/src/hooks/useAnimations.tsx
similarity index 100%
rename from src/hooks/data/useAnimations.tsx
rename to src/hooks/useAnimations.tsx
diff --git a/src/hooks/useParams.ts b/src/hooks/useParams.tsx
similarity index 100%
rename from src/hooks/useParams.ts
rename to src/hooks/useParams.tsx
diff --git a/src/types/generated/mars-account-nft/MarsAccountNft.react-query.ts b/src/types/generated/mars-account-nft/MarsAccountNft.react-query.ts
deleted file mode 100644
index 2d9f8b27..00000000
--- a/src/types/generated/mars-account-nft/MarsAccountNft.react-query.ts
+++ /dev/null
@@ -1,574 +0,0 @@
-// @ts-nocheck
-/**
- * This file was automatically generated by @cosmwasm/ts-codegen@0.24.0.
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
- * and run the @cosmwasm/ts-codegen generate command to regenerate this file.
- */
-
-import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { ExecuteResult } from '@cosmjs/cosmwasm-stargate'
-import { Coin, StdFee } from '@cosmjs/amino'
-
-import {
- AllNftInfoResponseForEmpty,
- Approval,
- ApprovalResponse,
- ApprovalsResponse,
- Binary,
- ContractInfoResponse,
- Empty,
- ExecuteMsg,
- Expiration,
- InstantiateMsg,
- MinterResponse,
- NftConfigBaseForString,
- NftConfigUpdates,
- NftInfoResponseForEmpty,
- NumTokensResponse,
- OperatorsResponse,
- OwnerOfResponse,
- QueryMsg,
- Timestamp,
- TokensResponse,
- Uint128,
- Uint64,
-} from './MarsAccountNft.types'
-import { MarsAccountNftClient, MarsAccountNftQueryClient } from './MarsAccountNft.client'
-export const marsAccountNftQueryKeys = {
- contract: [
- {
- contract: 'marsAccountNft',
- },
- ] as const,
- address: (contractAddress: string | undefined) =>
- [{ ...marsAccountNftQueryKeys.contract[0], address: contractAddress }] as const,
- config: (contractAddress: string | undefined, args?: Record) =>
- [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'config', args }] as const,
- nextId: (contractAddress: string | undefined, args?: Record) =>
- [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'next_id', args }] as const,
- ownerOf: (contractAddress: string | undefined, args?: Record) =>
- [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'owner_of', args }] as const,
- approval: (contractAddress: string | undefined, args?: Record) =>
- [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'approval', args }] as const,
- approvals: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'approvals', args },
- ] as const,
- allOperators: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'all_operators', args },
- ] as const,
- numTokens: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'num_tokens', args },
- ] as const,
- contractInfo: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'contract_info', args },
- ] as const,
- nftInfo: (contractAddress: string | undefined, args?: Record) =>
- [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'nft_info', args }] as const,
- allNftInfo: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'all_nft_info', args },
- ] as const,
- tokens: (contractAddress: string | undefined, args?: Record) =>
- [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'tokens', args }] as const,
- allTokens: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'all_tokens', args },
- ] as const,
- minter: (contractAddress: string | undefined, args?: Record) =>
- [{ ...marsAccountNftQueryKeys.address(contractAddress)[0], method: 'minter', args }] as const,
-}
-export interface MarsAccountNftReactQuery {
- client: MarsAccountNftQueryClient | undefined
- options?: Omit<
- UseQueryOptions,
- "'queryKey' | 'queryFn' | 'initialData'"
- > & {
- initialData?: undefined
- }
-}
-export interface MarsAccountNftMinterQuery
- extends MarsAccountNftReactQuery {}
-export function useMarsAccountNftMinterQuery({
- client,
- options,
-}: MarsAccountNftMinterQuery) {
- return useQuery(
- marsAccountNftQueryKeys.minter(client?.contractAddress),
- () => (client ? client.minter() : Promise.reject(new Error('Invalid client'))),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftAllTokensQuery
- extends MarsAccountNftReactQuery {
- args: {
- limit?: number
- startAfter?: string
- }
-}
-export function useMarsAccountNftAllTokensQuery({
- client,
- args,
- options,
-}: MarsAccountNftAllTokensQuery) {
- return useQuery(
- marsAccountNftQueryKeys.allTokens(client?.contractAddress, args),
- () =>
- client
- ? client.allTokens({
- limit: args.limit,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftTokensQuery
- extends MarsAccountNftReactQuery {
- args: {
- limit?: number
- owner: string
- startAfter?: string
- }
-}
-export function useMarsAccountNftTokensQuery({
- client,
- args,
- options,
-}: MarsAccountNftTokensQuery) {
- return useQuery(
- marsAccountNftQueryKeys.tokens(client?.contractAddress, args),
- () =>
- client
- ? client.tokens({
- limit: args.limit,
- owner: args.owner,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftAllNftInfoQuery
- extends MarsAccountNftReactQuery {
- args: {
- includeExpired?: boolean
- tokenId: string
- }
-}
-export function useMarsAccountNftAllNftInfoQuery({
- client,
- args,
- options,
-}: MarsAccountNftAllNftInfoQuery) {
- return useQuery(
- marsAccountNftQueryKeys.allNftInfo(client?.contractAddress, args),
- () =>
- client
- ? client.allNftInfo({
- includeExpired: args.includeExpired,
- tokenId: args.tokenId,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftNftInfoQuery
- extends MarsAccountNftReactQuery {
- args: {
- tokenId: string
- }
-}
-export function useMarsAccountNftNftInfoQuery({
- client,
- args,
- options,
-}: MarsAccountNftNftInfoQuery) {
- return useQuery(
- marsAccountNftQueryKeys.nftInfo(client?.contractAddress, args),
- () =>
- client
- ? client.nftInfo({
- tokenId: args.tokenId,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftContractInfoQuery
- extends MarsAccountNftReactQuery {}
-export function useMarsAccountNftContractInfoQuery({
- client,
- options,
-}: MarsAccountNftContractInfoQuery) {
- return useQuery(
- marsAccountNftQueryKeys.contractInfo(client?.contractAddress),
- () => (client ? client.contractInfo() : Promise.reject(new Error('Invalid client'))),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftNumTokensQuery
- extends MarsAccountNftReactQuery {}
-export function useMarsAccountNftNumTokensQuery({
- client,
- options,
-}: MarsAccountNftNumTokensQuery) {
- return useQuery(
- marsAccountNftQueryKeys.numTokens(client?.contractAddress),
- () => (client ? client.numTokens() : Promise.reject(new Error('Invalid client'))),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftAllOperatorsQuery
- extends MarsAccountNftReactQuery {
- args: {
- includeExpired?: boolean
- limit?: number
- owner: string
- startAfter?: string
- }
-}
-export function useMarsAccountNftAllOperatorsQuery({
- client,
- args,
- options,
-}: MarsAccountNftAllOperatorsQuery) {
- return useQuery(
- marsAccountNftQueryKeys.allOperators(client?.contractAddress, args),
- () =>
- client
- ? client.allOperators({
- includeExpired: args.includeExpired,
- limit: args.limit,
- owner: args.owner,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftApprovalsQuery
- extends MarsAccountNftReactQuery {
- args: {
- includeExpired?: boolean
- tokenId: string
- }
-}
-export function useMarsAccountNftApprovalsQuery({
- client,
- args,
- options,
-}: MarsAccountNftApprovalsQuery) {
- return useQuery(
- marsAccountNftQueryKeys.approvals(client?.contractAddress, args),
- () =>
- client
- ? client.approvals({
- includeExpired: args.includeExpired,
- tokenId: args.tokenId,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftApprovalQuery
- extends MarsAccountNftReactQuery {
- args: {
- includeExpired?: boolean
- spender: string
- tokenId: string
- }
-}
-export function useMarsAccountNftApprovalQuery({
- client,
- args,
- options,
-}: MarsAccountNftApprovalQuery) {
- return useQuery(
- marsAccountNftQueryKeys.approval(client?.contractAddress, args),
- () =>
- client
- ? client.approval({
- includeExpired: args.includeExpired,
- spender: args.spender,
- tokenId: args.tokenId,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftOwnerOfQuery
- extends MarsAccountNftReactQuery {
- args: {
- includeExpired?: boolean
- tokenId: string
- }
-}
-export function useMarsAccountNftOwnerOfQuery({
- client,
- args,
- options,
-}: MarsAccountNftOwnerOfQuery) {
- return useQuery(
- marsAccountNftQueryKeys.ownerOf(client?.contractAddress, args),
- () =>
- client
- ? client.ownerOf({
- includeExpired: args.includeExpired,
- tokenId: args.tokenId,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftNextIdQuery extends MarsAccountNftReactQuery {}
-export function useMarsAccountNftNextIdQuery({
- client,
- options,
-}: MarsAccountNftNextIdQuery) {
- return useQuery(
- marsAccountNftQueryKeys.nextId(client?.contractAddress),
- () => (client ? client.nextId() : Promise.reject(new Error('Invalid client'))),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftConfigQuery
- extends MarsAccountNftReactQuery {}
-export function useMarsAccountNftConfigQuery({
- client,
- options,
-}: MarsAccountNftConfigQuery) {
- return useQuery(
- marsAccountNftQueryKeys.config(client?.contractAddress),
- () => (client ? client.config() : Promise.reject(new Error('Invalid client'))),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsAccountNftRevokeAllMutation {
- client: MarsAccountNftClient
- msg: {
- operator: string
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsAccountNftRevokeAllMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) => client.revokeAll(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsAccountNftApproveAllMutation {
- client: MarsAccountNftClient
- msg: {
- expires?: Expiration
- operator: string
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsAccountNftApproveAllMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) => client.approveAll(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsAccountNftRevokeMutation {
- client: MarsAccountNftClient
- msg: {
- spender: string
- tokenId: string
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsAccountNftRevokeMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) => client.revoke(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsAccountNftApproveMutation {
- client: MarsAccountNftClient
- msg: {
- expires?: Expiration
- spender: string
- tokenId: string
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsAccountNftApproveMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) => client.approve(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsAccountNftSendNftMutation {
- client: MarsAccountNftClient
- msg: {
- contract: string
- msg: Binary
- tokenId: string
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsAccountNftSendNftMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) => client.sendNft(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsAccountNftTransferNftMutation {
- client: MarsAccountNftClient
- msg: {
- recipient: string
- tokenId: string
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsAccountNftTransferNftMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) => client.transferNft(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsAccountNftBurnMutation {
- client: MarsAccountNftClient
- msg: {
- tokenId: string
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsAccountNftBurnMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) => client.burn(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsAccountNftMintMutation {
- client: MarsAccountNftClient
- msg: {
- user: string
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsAccountNftMintMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) => client.mint(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsAccountNftAcceptMinterRoleMutation {
- client: MarsAccountNftClient
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsAccountNftAcceptMinterRoleMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, args: { fee, memo, funds } = {} }) => client.acceptMinterRole(fee, memo, funds),
- options,
- )
-}
-export interface MarsAccountNftUpdateConfigMutation {
- client: MarsAccountNftClient
- msg: {
- updates: NftConfigUpdates
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsAccountNftUpdateConfigMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) =>
- client.updateConfig(msg, fee, memo, funds),
- options,
- )
-}
diff --git a/src/types/generated/mars-credit-manager/MarsCreditManager.react-query.ts b/src/types/generated/mars-credit-manager/MarsCreditManager.react-query.ts
deleted file mode 100644
index 907f8a1d..00000000
--- a/src/types/generated/mars-credit-manager/MarsCreditManager.react-query.ts
+++ /dev/null
@@ -1,724 +0,0 @@
-// @ts-nocheck
-/**
- * This file was automatically generated by @cosmwasm/ts-codegen@0.24.0.
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
- * and run the @cosmwasm/ts-codegen generate command to regenerate this file.
- */
-
-import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { ExecuteResult } from '@cosmjs/cosmwasm-stargate'
-import { StdFee } from '@cosmjs/amino'
-
-import {
- Action,
- ActionAmount,
- ActionCoin,
- Addr,
- ArrayOfCoin,
- ArrayOfCoinBalanceResponseItem,
- ArrayOfDebtShares,
- ArrayOfLentShares,
- ArrayOfSharesResponseItem,
- ArrayOfString,
- ArrayOfVaultInfoResponse,
- ArrayOfVaultPositionResponseItem,
- ArrayOfVaultWithBalance,
- CallbackMsg,
- Coin,
- CoinBalanceResponseItem,
- CoinValue,
- ConfigResponse,
- ConfigUpdates,
- DebtAmount,
- DebtShares,
- Decimal,
- ExecuteMsg,
- HealthContractBaseForString,
- InstantiateMsg,
- LentAmount,
- LentShares,
- LockingVaultAmount,
- NftConfigUpdates,
- OracleBaseForString,
- OwnerUpdate,
- Positions,
- QueryMsg,
- RedBankBaseForString,
- SharesResponseItem,
- SwapperBaseForString,
- Uint128,
- UnlockingPositions,
- VaultAmount,
- VaultAmount1,
- VaultBaseForAddr,
- VaultBaseForString,
- VaultConfig,
- VaultInfoResponse,
- VaultInstantiateConfig,
- VaultPosition,
- VaultPositionAmount,
- VaultPositionResponseItem,
- VaultPositionType,
- VaultPositionValue,
- VaultUnlockingPosition,
- VaultWithBalance,
- ZapperBaseForString,
-} from './MarsCreditManager.types'
-import { MarsCreditManagerClient, MarsCreditManagerQueryClient } from './MarsCreditManager.client'
-export const marsCreditManagerQueryKeys = {
- contract: [
- {
- contract: 'marsCreditManager',
- },
- ] as const,
- address: (contractAddress: string | undefined) =>
- [{ ...marsCreditManagerQueryKeys.contract[0], address: contractAddress }] as const,
- config: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsCreditManagerQueryKeys.address(contractAddress)[0], method: 'config', args },
- ] as const,
- vaultInfo: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsCreditManagerQueryKeys.address(contractAddress)[0], method: 'vault_info', args },
- ] as const,
- vaultsInfo: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsCreditManagerQueryKeys.address(contractAddress)[0], method: 'vaults_info', args },
- ] as const,
- allowedCoins: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsCreditManagerQueryKeys.address(contractAddress)[0], method: 'allowed_coins', args },
- ] as const,
- positions: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsCreditManagerQueryKeys.address(contractAddress)[0], method: 'positions', args },
- ] as const,
- allCoinBalances: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_coin_balances',
- args,
- },
- ] as const,
- allDebtShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_debt_shares',
- args,
- },
- ] as const,
- totalDebtShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'total_debt_shares',
- args,
- },
- ] as const,
- allTotalDebtShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_total_debt_shares',
- args,
- },
- ] as const,
- allLentShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_lent_shares',
- args,
- },
- ] as const,
- totalLentShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'total_lent_shares',
- args,
- },
- ] as const,
- allTotalLentShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_total_lent_shares',
- args,
- },
- ] as const,
- allVaultPositions: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_vault_positions',
- args,
- },
- ] as const,
- totalVaultCoinBalance: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'total_vault_coin_balance',
- args,
- },
- ] as const,
- allTotalVaultCoinBalances: (
- contractAddress: string | undefined,
- args?: Record,
- ) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_total_vault_coin_balances',
- args,
- },
- ] as const,
- estimateProvideLiquidity: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'estimate_provide_liquidity',
- args,
- },
- ] as const,
- estimateWithdrawLiquidity: (
- contractAddress: string | undefined,
- args?: Record,
- ) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'estimate_withdraw_liquidity',
- args,
- },
- ] as const,
- vaultPositionValue: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'vault_position_value',
- args,
- },
- ] as const,
-}
-export interface MarsCreditManagerReactQuery {
- client: MarsCreditManagerQueryClient | undefined
- options?: Omit<
- UseQueryOptions,
- "'queryKey' | 'queryFn' | 'initialData'"
- > & {
- initialData?: undefined
- }
-}
-export interface MarsCreditManagerVaultPositionValueQuery
- extends MarsCreditManagerReactQuery {
- args: {
- vaultPosition: VaultPosition
- }
-}
-export function useMarsCreditManagerVaultPositionValueQuery({
- client,
- args,
- options,
-}: MarsCreditManagerVaultPositionValueQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.vaultPositionValue(client?.contractAddress, args),
- () =>
- client
- ? client.vaultPositionValue({
- vaultPosition: args.vaultPosition,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerEstimateWithdrawLiquidityQuery
- extends MarsCreditManagerReactQuery {
- args: {
- lpToken: Coin
- }
-}
-export function useMarsCreditManagerEstimateWithdrawLiquidityQuery({
- client,
- args,
- options,
-}: MarsCreditManagerEstimateWithdrawLiquidityQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.estimateWithdrawLiquidity(client?.contractAddress, args),
- () =>
- client
- ? client.estimateWithdrawLiquidity({
- lpToken: args.lpToken,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerEstimateProvideLiquidityQuery
- extends MarsCreditManagerReactQuery {
- args: {
- coinsIn: Coin[]
- lpTokenOut: string
- }
-}
-export function useMarsCreditManagerEstimateProvideLiquidityQuery({
- client,
- args,
- options,
-}: MarsCreditManagerEstimateProvideLiquidityQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.estimateProvideLiquidity(client?.contractAddress, args),
- () =>
- client
- ? client.estimateProvideLiquidity({
- coinsIn: args.coinsIn,
- lpTokenOut: args.lpTokenOut,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerAllTotalVaultCoinBalancesQuery
- extends MarsCreditManagerReactQuery {
- args: {
- limit?: number
- startAfter?: VaultBaseForString
- }
-}
-export function useMarsCreditManagerAllTotalVaultCoinBalancesQuery<
- TData = ArrayOfVaultWithBalance,
->({ client, args, options }: MarsCreditManagerAllTotalVaultCoinBalancesQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.allTotalVaultCoinBalances(client?.contractAddress, args),
- () =>
- client
- ? client.allTotalVaultCoinBalances({
- limit: args.limit,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerTotalVaultCoinBalanceQuery
- extends MarsCreditManagerReactQuery {
- args: {
- vault: VaultBaseForString
- }
-}
-export function useMarsCreditManagerTotalVaultCoinBalanceQuery({
- client,
- args,
- options,
-}: MarsCreditManagerTotalVaultCoinBalanceQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.totalVaultCoinBalance(client?.contractAddress, args),
- () =>
- client
- ? client.totalVaultCoinBalance({
- vault: args.vault,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerAllVaultPositionsQuery
- extends MarsCreditManagerReactQuery {
- args: {
- limit?: number
- startAfter?: string[][]
- }
-}
-export function useMarsCreditManagerAllVaultPositionsQuery<
- TData = ArrayOfVaultPositionResponseItem,
->({ client, args, options }: MarsCreditManagerAllVaultPositionsQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.allVaultPositions(client?.contractAddress, args),
- () =>
- client
- ? client.allVaultPositions({
- limit: args.limit,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerAllTotalLentSharesQuery
- extends MarsCreditManagerReactQuery {
- args: {
- limit?: number
- startAfter?: string
- }
-}
-export function useMarsCreditManagerAllTotalLentSharesQuery({
- client,
- args,
- options,
-}: MarsCreditManagerAllTotalLentSharesQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.allTotalLentShares(client?.contractAddress, args),
- () =>
- client
- ? client.allTotalLentShares({
- limit: args.limit,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerTotalLentSharesQuery
- extends MarsCreditManagerReactQuery {}
-export function useMarsCreditManagerTotalLentSharesQuery({
- client,
- options,
-}: MarsCreditManagerTotalLentSharesQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.totalLentShares(client?.contractAddress),
- () => (client ? client.totalLentShares() : Promise.reject(new Error('Invalid client'))),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerAllLentSharesQuery
- extends MarsCreditManagerReactQuery {
- args: {
- limit?: number
- startAfter?: string[][]
- }
-}
-export function useMarsCreditManagerAllLentSharesQuery({
- client,
- args,
- options,
-}: MarsCreditManagerAllLentSharesQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.allLentShares(client?.contractAddress, args),
- () =>
- client
- ? client.allLentShares({
- limit: args.limit,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerAllTotalDebtSharesQuery
- extends MarsCreditManagerReactQuery {
- args: {
- limit?: number
- startAfter?: string
- }
-}
-export function useMarsCreditManagerAllTotalDebtSharesQuery({
- client,
- args,
- options,
-}: MarsCreditManagerAllTotalDebtSharesQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.allTotalDebtShares(client?.contractAddress, args),
- () =>
- client
- ? client.allTotalDebtShares({
- limit: args.limit,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerTotalDebtSharesQuery
- extends MarsCreditManagerReactQuery {}
-export function useMarsCreditManagerTotalDebtSharesQuery({
- client,
- options,
-}: MarsCreditManagerTotalDebtSharesQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.totalDebtShares(client?.contractAddress),
- () => (client ? client.totalDebtShares() : Promise.reject(new Error('Invalid client'))),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerAllDebtSharesQuery
- extends MarsCreditManagerReactQuery {
- args: {
- limit?: number
- startAfter?: string[][]
- }
-}
-export function useMarsCreditManagerAllDebtSharesQuery({
- client,
- args,
- options,
-}: MarsCreditManagerAllDebtSharesQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.allDebtShares(client?.contractAddress, args),
- () =>
- client
- ? client.allDebtShares({
- limit: args.limit,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerAllCoinBalancesQuery
- extends MarsCreditManagerReactQuery {
- args: {
- limit?: number
- startAfter?: string[][]
- }
-}
-export function useMarsCreditManagerAllCoinBalancesQuery({
- client,
- args,
- options,
-}: MarsCreditManagerAllCoinBalancesQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.allCoinBalances(client?.contractAddress, args),
- () =>
- client
- ? client.allCoinBalances({
- limit: args.limit,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerPositionsQuery
- extends MarsCreditManagerReactQuery {
- args: {
- accountId: string
- }
-}
-export function useMarsCreditManagerPositionsQuery({
- client,
- args,
- options,
-}: MarsCreditManagerPositionsQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.positions(client?.contractAddress, args),
- () =>
- client
- ? client.positions({
- accountId: args.accountId,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerAllowedCoinsQuery
- extends MarsCreditManagerReactQuery {
- args: {
- limit?: number
- startAfter?: string
- }
-}
-export function useMarsCreditManagerAllowedCoinsQuery({
- client,
- args,
- options,
-}: MarsCreditManagerAllowedCoinsQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.allowedCoins(client?.contractAddress, args),
- () =>
- client
- ? client.allowedCoins({
- limit: args.limit,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerVaultsInfoQuery
- extends MarsCreditManagerReactQuery {
- args: {
- limit?: number
- startAfter?: VaultBaseForString
- }
-}
-export function useMarsCreditManagerVaultsInfoQuery({
- client,
- args,
- options,
-}: MarsCreditManagerVaultsInfoQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.vaultsInfo(client?.contractAddress, args),
- () =>
- client
- ? client.vaultsInfo({
- limit: args.limit,
- startAfter: args.startAfter,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerVaultInfoQuery
- extends MarsCreditManagerReactQuery {
- args: {
- vault: VaultBaseForString
- }
-}
-export function useMarsCreditManagerVaultInfoQuery({
- client,
- args,
- options,
-}: MarsCreditManagerVaultInfoQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.vaultInfo(client?.contractAddress, args),
- () =>
- client
- ? client.vaultInfo({
- vault: args.vault,
- })
- : Promise.reject(new Error('Invalid client')),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerConfigQuery
- extends MarsCreditManagerReactQuery {}
-export function useMarsCreditManagerConfigQuery({
- client,
- options,
-}: MarsCreditManagerConfigQuery) {
- return useQuery(
- marsCreditManagerQueryKeys.config(client?.contractAddress),
- () => (client ? client.config() : Promise.reject(new Error('Invalid client'))),
- { ...options, enabled: !!client && (options?.enabled != undefined ? options.enabled : true) },
- )
-}
-export interface MarsCreditManagerCallbackMutation {
- client: MarsCreditManagerClient
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsCreditManagerCallbackMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) => client.callback(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsCreditManagerUpdateNftConfigMutation {
- client: MarsCreditManagerClient
- msg: {
- updates: NftConfigUpdates
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsCreditManagerUpdateNftConfigMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) =>
- client.updateNftConfig(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsCreditManagerUpdateOwnerMutation {
- client: MarsCreditManagerClient
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsCreditManagerUpdateOwnerMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) => client.updateOwner(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsCreditManagerUpdateConfigMutation {
- client: MarsCreditManagerClient
- msg: {
- updates: ConfigUpdates
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsCreditManagerUpdateConfigMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) =>
- client.updateConfig(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsCreditManagerUpdateCreditAccountMutation {
- client: MarsCreditManagerClient
- msg: {
- accountId: string
- actions: Action[]
- }
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsCreditManagerUpdateCreditAccountMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, msg, args: { fee, memo, funds } = {} }) =>
- client.updateCreditAccount(msg, fee, memo, funds),
- options,
- )
-}
-export interface MarsCreditManagerCreateCreditAccountMutation {
- client: MarsCreditManagerClient
- args?: {
- fee?: number | StdFee | 'auto'
- memo?: string
- funds?: Coin[]
- }
-}
-export function useMarsCreditManagerCreateCreditAccountMutation(
- options?: Omit<
- UseMutationOptions,
- 'mutationFn'
- >,
-) {
- return useMutation(
- ({ client, args: { fee, memo, funds } = {} }) => client.createCreditAccount(fee, memo, funds),
- options,
- )
-}
diff --git a/src/types/generated/mars-mock-credit-manager/MarsMockCreditManager.react-query.ts b/src/types/generated/mars-mock-credit-manager/MarsMockCreditManager.react-query.ts
deleted file mode 100644
index 7a80faca..00000000
--- a/src/types/generated/mars-mock-credit-manager/MarsMockCreditManager.react-query.ts
+++ /dev/null
@@ -1,659 +0,0 @@
-// @ts-nocheck
-/**
- * This file was automatically generated by @cosmwasm/ts-codegen@0.24.0.
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
- * and run the @cosmwasm/ts-codegen generate command to regenerate this file.
- */
-
-import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { ExecuteResult } from '@cosmjs/cosmwasm-stargate'
-import { StdFee } from '@cosmjs/amino'
-
-import {
- Addr,
- ArrayOfCoin,
- ArrayOfCoinBalanceResponseItem,
- ArrayOfDebtShares,
- ArrayOfLentShares,
- ArrayOfSharesResponseItem,
- ArrayOfString,
- ArrayOfVaultInfoResponse,
- ArrayOfVaultPositionResponseItem,
- ArrayOfVaultWithBalance,
- Coin,
- CoinBalanceResponseItem,
- CoinValue,
- ConfigResponse,
- DebtAmount,
- DebtShares,
- Decimal,
- ExecuteMsg,
- InstantiateMsg,
- LentAmount,
- LentShares,
- LockingVaultAmount,
- Positions,
- QueryMsg,
- SharesResponseItem,
- Uint128,
- UnlockingPositions,
- VaultAmount,
- VaultAmount1,
- VaultBaseForAddr,
- VaultBaseForString,
- VaultConfig,
- VaultInfoResponse,
- VaultPosition,
- VaultPositionAmount,
- VaultPositionResponseItem,
- VaultPositionValue,
- VaultUnlockingPosition,
- VaultWithBalance,
-} from './MarsMockCreditManager.types'
-import {
- MarsMockCreditManagerClient,
- MarsMockCreditManagerQueryClient,
-} from './MarsMockCreditManager.client'
-export const marsMockCreditManagerQueryKeys = {
- contract: [
- {
- contract: 'marsMockCreditManager',
- },
- ] as const,
- address: (contractAddress: string | undefined) =>
- [{ ...marsMockCreditManagerQueryKeys.contract[0], address: contractAddress }] as const,
- config: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsMockCreditManagerQueryKeys.address(contractAddress)[0], method: 'config', args },
- ] as const,
- vaultInfo: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsMockCreditManagerQueryKeys.address(contractAddress)[0], method: 'vault_info', args },
- ] as const,
- vaultsInfo: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'vaults_info',
- args,
- },
- ] as const,
- allowedCoins: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'allowed_coins',
- args,
- },
- ] as const,
- positions: (contractAddress: string | undefined, args?: Record) =>
- [
- { ...marsMockCreditManagerQueryKeys.address(contractAddress)[0], method: 'positions', args },
- ] as const,
- allCoinBalances: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_coin_balances',
- args,
- },
- ] as const,
- allDebtShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_debt_shares',
- args,
- },
- ] as const,
- totalDebtShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'total_debt_shares',
- args,
- },
- ] as const,
- allTotalDebtShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_total_debt_shares',
- args,
- },
- ] as const,
- allLentShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_lent_shares',
- args,
- },
- ] as const,
- totalLentShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'total_lent_shares',
- args,
- },
- ] as const,
- allTotalLentShares: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_total_lent_shares',
- args,
- },
- ] as const,
- allVaultPositions: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_vault_positions',
- args,
- },
- ] as const,
- totalVaultCoinBalance: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'total_vault_coin_balance',
- args,
- },
- ] as const,
- allTotalVaultCoinBalances: (
- contractAddress: string | undefined,
- args?: Record,
- ) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'all_total_vault_coin_balances',
- args,
- },
- ] as const,
- estimateProvideLiquidity: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'estimate_provide_liquidity',
- args,
- },
- ] as const,
- estimateWithdrawLiquidity: (
- contractAddress: string | undefined,
- args?: Record,
- ) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'estimate_withdraw_liquidity',
- args,
- },
- ] as const,
- vaultPositionValue: (contractAddress: string | undefined, args?: Record) =>
- [
- {
- ...marsMockCreditManagerQueryKeys.address(contractAddress)[0],
- method: 'vault_position_value',
- args,
- },
- ] as const,
-}
-export interface MarsMockCreditManagerReactQuery {
- client: MarsMockCreditManagerQueryClient | undefined
- options?: Omit<
- UseQueryOptions,
- "'queryKey' | 'queryFn' | 'initialData'"
- > & {
- initialData?: undefined
- }
-}
-export interface MarsMockCreditManagerVaultPositionValueQuery
- extends MarsMockCreditManagerReactQuery {
- args: {
- vaultPosition: VaultPosition
- }
-}
-export function useMarsMockCreditManagerVaultPositionValueQuery