From 27cdd1c954078b10f9e94f0bee71a7c93d2a97ab Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Wed, 9 Nov 2022 10:04:06 +0100 Subject: [PATCH] Linter and prettier adjustments (#50) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * tidy: added eslintrc and prettierrc rules * tidy: formated the files via ‚yarn format‘ * import sort improvements * format script regex fix * replace eslint import severity to warning * remove staged file Co-authored-by: Gustavo Mauricio --- .eslintrc.json | 18 ++- .github/dependabot.yml | 8 +- .prettierrc | 4 +- components/Borrow/AssetRow.tsx | 30 ++-- components/Borrow/BorrowTable.tsx | 35 +++-- components/BorrowModal.tsx | 103 +++++++------ components/Button.tsx | 2 +- components/ConnectModal.tsx | 96 ++++++------ components/Container/index.tsx | 1 + components/CreditManager/index.tsx | 75 ++++----- components/FundAccountModal.tsx | 105 ++++++------- components/Layout/Layout.module.css | 2 +- components/Layout/index.tsx | 3 +- components/Navigation.tsx | 73 ++++----- components/ProgressBar.tsx | 4 +- components/RepayModal.tsx | 91 +++++------ components/SearchInput.tsx | 24 +-- components/SemiCircleProgress.tsx | 8 +- components/Slider.tsx | 14 +- components/Spinner.tsx | 26 ++-- components/Tooltip.tsx | 4 +- components/Wallet.tsx | 51 +++--- components/WithdrawModal.tsx | 145 +++++++++--------- hooks/mutations/useBorrowFunds.tsx | 10 +- hooks/mutations/useCreateCreditAccount.tsx | 8 +- hooks/mutations/useDeleteCreditAccount.tsx | 8 +- hooks/mutations/useDepositCreditAccount.tsx | 10 +- hooks/mutations/useRepayFunds.tsx | 12 +- hooks/mutations/useWithdrawFunds.tsx | 10 +- hooks/useAccountStats.tsx | 5 +- hooks/useAllBalances.tsx | 2 +- hooks/useAllowedCoins.tsx | 4 +- hooks/useCalculateMaxBorrowAmount.tsx | 13 +- hooks/useCalculateMaxWithdrawAmount.tsx | 17 +- hooks/useCreditAccountPositions.tsx | 6 +- hooks/useCreditAccounts.tsx | 4 +- hooks/useMarkets.tsx | 2 +- hooks/useRedbankBalances.tsx | 6 +- hooks/useTokenBalance.tsx | 6 +- hooks/useTokenPrices.tsx | 2 +- package.json | 2 + pages/_app.tsx | 17 +- pages/borrow.tsx | 30 ++-- pages/council.tsx | 1 + pages/earn.tsx | 7 +- pages/index.tsx | 98 ++++++------ pages/portfolio.tsx | 22 +-- pages/trade.tsx | 7 +- stores/useCreditManagerStore.tsx | 6 +- stores/useWalletStore.tsx | 22 +-- .../account-nft/AccountNft.client.ts | 27 ++-- .../account-nft/AccountNft.react-query.ts | 31 ++-- types/generated/account-nft/bundle.ts | 2 +- .../credit-manager/CreditManager.client.ts | 53 +++---- .../CreditManager.react-query.ts | 57 +++---- types/generated/credit-manager/bundle.ts | 2 +- .../MarsOracleAdapter.client.ts | 19 +-- .../MarsOracleAdapter.react-query.ts | 23 +-- types/generated/mars-oracle-adapter/bundle.ts | 2 +- .../mock-oracle/MockOracle.client.ts | 9 +- .../mock-oracle/MockOracle.react-query.ts | 13 +- types/generated/mock-oracle/bundle.ts | 2 +- .../mock-red-bank/MockRedBank.client.ts | 17 +- .../mock-red-bank/MockRedBank.react-query.ts | 21 +-- types/generated/mock-red-bank/bundle.ts | 2 +- .../generated/mock-vault/MockVault.client.ts | 11 +- .../mock-vault/MockVault.react-query.ts | 15 +- types/generated/mock-vault/bundle.ts | 2 +- .../swapper-base/SwapperBase.client.ts | 23 +-- .../swapper-base/SwapperBase.react-query.ts | 27 ++-- types/generated/swapper-base/bundle.ts | 2 +- utils/experimental-chains.ts | 3 +- utils/formatters.ts | 2 +- yarn.lock | 2 +- 74 files changed, 839 insertions(+), 787 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index bffb357a..740bc29a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,19 @@ { - "extends": "next/core-web-vitals" + "extends": "next/core-web-vitals", + "rules": { + "sort-imports": [ + "warn", + { + "ignoreCase": true, + "ignoreDeclarationSort": true + } + ], + "import/order": [ + "warn", + { + "newlines-between": "always", + "groups": ["external", "builtin", "internal", "sibling", "parent", "index"] + } + ] + } } diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f7ef610e..0d2720dc 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,8 +5,8 @@ version: 2 updates: - - package-ecosystem: "npm" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: 'npm' # See documentation for possible values + directory: '/' # Location of package manifests schedule: - interval: "weekly" - target-branch: "develop" + interval: 'weekly' + target-branch: 'develop' diff --git a/.prettierrc b/.prettierrc index b52a92b1..8c32ca31 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,7 @@ { "singleQuote": true, + "jsxSingleQuote": true, "semi": false, - "printWidth": 100 + "printWidth": 100, + "trailingComma": "all" } diff --git a/components/Borrow/AssetRow.tsx b/components/Borrow/AssetRow.tsx index bf58f211..d8af98f7 100644 --- a/components/Borrow/AssetRow.tsx +++ b/components/Borrow/AssetRow.tsx @@ -1,6 +1,6 @@ -import React, { useState } from 'react' import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/solid' import Image from 'next/image' +import React, { useState } from 'react' import Button from 'components/Button' import { formatCurrency } from 'utils/formatters' @@ -27,39 +27,39 @@ const AssetRow = ({ data, onBorrowClick, onRepayClick }: AssetRowProps) => { return (
setIsExpanded((current) => !current)} > -
-
- token -
+
+
+ token +
{data.symbol}
-
{data.chain}
+
{data.chain}
-
+
{data.borrowRate ? `${(data.borrowRate * 100).toFixed(2)}%` : '-'}
-
+
{data.borrowed ? (
-
{data.borrowed.amount}
+
{data.borrowed.amount}
{formatCurrency(data.borrowed.value)}
) : ( '-' )}
-
{data.marketLiquidity}
-
- {isExpanded ? : } +
{data.marketLiquidity}
+
+ {isExpanded ? : }
{isExpanded && ( -
+
Additional Stuff Placeholder
-
+
- ) + ), ) Button.displayName = 'Button' diff --git a/components/ConnectModal.tsx b/components/ConnectModal.tsx index 09dc21d4..94a68af4 100644 --- a/components/ConnectModal.tsx +++ b/components/ConnectModal.tsx @@ -1,15 +1,15 @@ -import React, { Fragment, useState } from 'react' -import Image from 'next/image' -import { Dialog, Transition } from '@headlessui/react' -import { toast } from 'react-toastify' import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' import { Coin } from '@cosmjs/stargate' +import { Dialog, Transition } from '@headlessui/react' +import Image from 'next/image' +import React, { Fragment, useState } from 'react' +import { toast } from 'react-toastify' -import { getInjectiveAddress } from 'utils/address' -import { getExperimentalChainConfigBasedOnChainId } from 'utils/experimental-chains' -import { ChainId, Wallet } from 'types' import useWalletStore from 'stores/useWalletStore' +import { ChainId, Wallet } from 'types' +import { getInjectiveAddress } from 'utils/address' import { chain } from 'utils/chains' +import { getExperimentalChainConfigBasedOnChainId } from 'utils/experimental-chains' type Props = { isOpen: boolean @@ -83,68 +83,68 @@ const ConnectModal = ({ isOpen, onClose }: Props) => { return ( - + -
+
-
-
+
+
- - + + Connect your wallet {isLoading ? ( -
+
- Loading... + Loading...
) : ( -
+ diff --git a/components/Container/index.tsx b/components/Container/index.tsx index b11bf22f..16b89b8c 100644 --- a/components/Container/index.tsx +++ b/components/Container/index.tsx @@ -1,4 +1,5 @@ import React from 'react' + import styles from './Container.module.css' type Props = { diff --git a/components/CreditManager/index.tsx b/components/CreditManager/index.tsx index bd0bca89..b086e60f 100644 --- a/components/CreditManager/index.tsx +++ b/components/CreditManager/index.tsx @@ -1,18 +1,19 @@ -import React, { useRef, useState } from 'react' import BigNumber from 'bignumber.js' +import React, { useRef, useState } from 'react' -import Button from '../Button' -import { formatCurrency } from 'utils/formatters' +import ContainerSecondary from 'components/ContainerSecondary' +import FundAccountModal from 'components/FundAccountModal' +import WithdrawModal from 'components/WithdrawModal' +import useAccountStats from 'hooks/useAccountStats' +import useCreditAccountPositions from 'hooks/useCreditAccountPositions' +import useMarkets from 'hooks/useMarkets' +import useTokenPrices from 'hooks/useTokenPrices' import useCreditManagerStore from 'stores/useCreditManagerStore' import useWalletStore from 'stores/useWalletStore' -import useCreditAccountPositions from 'hooks/useCreditAccountPositions' +import { formatCurrency } from 'utils/formatters' import { getTokenDecimals, getTokenSymbol } from 'utils/tokens' -import useTokenPrices from 'hooks/useTokenPrices' -import useAccountStats from 'hooks/useAccountStats' -import useMarkets from 'hooks/useMarkets' -import ContainerSecondary from 'components/ContainerSecondary' -import WithdrawModal from 'components/WithdrawModal' -import FundAccountModal from 'components/FundAccountModal' + +import Button from '../Button' const CreditManager = () => { const [showFundWalletModal, setShowFundWalletModal] = useState(false) @@ -25,7 +26,7 @@ const CreditManager = () => { const selectedAccount = useCreditManagerStore((s) => s.selectedAccount) const { data: positionsData, isLoading: isLoadingPositions } = useCreditAccountPositions( - selectedAccount ?? '' + selectedAccount ?? '', ) const { data: tokenPrices } = useTokenPrices() @@ -45,17 +46,17 @@ const CreditManager = () => { if (!address) { return ( -
+
You must have a connected wallet
) } return ( -
- +
+ - -
+ +
Total Position:
-
{formatCurrency(accountStats?.totalPosition ?? 0)}
+
{formatCurrency(accountStats?.totalPosition ?? 0)}
-
+
Total Liabilities:
-
{formatCurrency(accountStats?.totalDebt ?? 0)}
+
{formatCurrency(accountStats?.totalDebt ?? 0)}
-

Balances

+

Balances

{isLoadingPositions ? (
Loading...
) : ( <> -
-
Asset
-
Value
-
Size
-
APY
+
+
Asset
+
Value
+
Size
+
APY
{positionsData?.coins.map((coin) => ( -
-
{getTokenSymbol(coin.denom)}
-
+
+
{getTokenSymbol(coin.denom)}
+
{formatCurrency(getTokenTotalUSDValue(coin.amount, coin.denom))}
-
+
{BigNumber(coin.amount) .div(10 ** getTokenDecimals(coin.denom)) .toNumber() @@ -110,16 +111,16 @@ const CreditManager = () => { maximumFractionDigits: getTokenDecimals(coin.denom), })}
-
-
+
-
))} {positionsData?.debts.map((coin) => ( -
-
{getTokenSymbol(coin.denom)}
-
+
+
{getTokenSymbol(coin.denom)}
+
-{formatCurrency(getTokenTotalUSDValue(coin.amount, coin.denom))}
-
+
- {BigNumber(coin.amount) .div(10 ** getTokenDecimals(coin.denom)) @@ -128,7 +129,7 @@ const CreditManager = () => { maximumFractionDigits: 6, })}
-
+
-{(Number(marketsData?.[coin.denom].borrow_rate) * 100).toFixed(1)}%
diff --git a/components/FundAccountModal.tsx b/components/FundAccountModal.tsx index f942d14e..a72d092f 100644 --- a/components/FundAccountModal.tsx +++ b/components/FundAccountModal.tsx @@ -1,19 +1,20 @@ -import React, { useEffect, useMemo, useState } from 'react' -import Image from 'next/image' -import { Transition, Dialog, Switch } from '@headlessui/react' +import { Dialog, Switch, Transition } from '@headlessui/react' import BigNumber from 'bignumber.js' +import Image from 'next/image' +import React, { useEffect, useMemo, useState } from 'react' import { toast } from 'react-toastify' import useLocalStorageState from 'use-local-storage-state' -import { getTokenDecimals, getTokenSymbol } from 'utils/tokens' -import ContainerSecondary from './ContainerSecondary' -import useCreditManagerStore from 'stores/useCreditManagerStore' -import Button from './Button' -import Spinner from './Spinner' +import Slider from 'components/Slider' +import useDepositCreditAccount from 'hooks/mutations/useDepositCreditAccount' import useAllBalances from 'hooks/useAllBalances' import useAllowedCoins from 'hooks/useAllowedCoins' -import useDepositCreditAccount from 'hooks/mutations/useDepositCreditAccount' -import Slider from 'components/Slider' +import useCreditManagerStore from 'stores/useCreditManagerStore' +import { getTokenDecimals, getTokenSymbol } from 'utils/tokens' + +import Button from './Button' +import ContainerSecondary from './ContainerSecondary' +import Spinner from './Spinner' const FundAccountModal = ({ show, onClose }: any) => { const [amount, setAmount] = useState(0) @@ -39,7 +40,7 @@ const FundAccountModal = ({ show, onClose }: any) => { toast.success(`${amount} ${getTokenSymbol(selectedToken)} successfully Deposited`) onClose() }, - } + }, ) useEffect(() => { @@ -71,55 +72,55 @@ const FundAccountModal = ({ show, onClose }: any) => { return ( - + -
+
-
-
+
+
- + {isLoading && ( -
+
)} -
+
-

About

-

+

About

+

Bringing the next generation of video creation to the Metaverse.
Powered by deep-learning.

- mars + mars
-
- +
+ Fund Account {selectedAccount} - -

+ +

Transfer assets from your injective wallet to your Mars credit account. If you don’t have any assets in your injective wallet use the injective bridge to transfer funds to your injective wallet. @@ -128,11 +129,11 @@ const FundAccountModal = ({ show, onClose }: any) => {

Loading...

) : ( <> -
-
-
Asset:
+
+
+
Asset:
-
-
Amount:
+
+
Amount:
handleValueChange(e.target.valueAsNumber)} onBlur={(e) => { if (e.target.value === '') setAmount(0) @@ -161,9 +162,9 @@ const FundAccountModal = ({ show, onClose }: any) => { />
-

In wallet: {walletAmount.toLocaleString()}

+

In wallet: {walletAmount.toLocaleString()}

{ const decimal = value[0] / 100 @@ -178,10 +179,10 @@ const FundAccountModal = ({ show, onClose }: any) => { )} - +
-

Lending Assets

-
+

Lending Assets

+
Lend assets from account to earn yield.
@@ -201,7 +202,7 @@ const FundAccountModal = ({ show, onClose }: any) => {
-

{address}

+

{address}

-
-

About

-

Subaccount {selectedAccount}

-
+
+

About

+

Subaccount {selectedAccount}

+
{accountStats && ( -
+

{formatCurrency(accountStats.netWorth)}

{/* TOOLTIP */}
- +
)}
-
-
+
+
Total Position:
-
+
{formatCurrency(accountStats?.totalPosition ?? 0)}
-
+
Total Liabilities:
-
+
{formatCurrency(accountStats?.totalDebt ?? 0)}
-
-

Balances

+
+

Balances

{isLoadingPositions ? (
Loading...
) : ( - - +
+ - + {positionsData?.coins.map((coin) => ( - + - + ))} {positionsData?.debts.map((coin) => ( - - + + @@ -307,7 +308,7 @@ const WithdrawModal = ({ show, onClose }: any) => { maximumFractionDigits: 6, })} - diff --git a/hooks/mutations/useBorrowFunds.tsx b/hooks/mutations/useBorrowFunds.tsx index 8a277a51..5234227e 100644 --- a/hooks/mutations/useBorrowFunds.tsx +++ b/hooks/mutations/useBorrowFunds.tsx @@ -2,16 +2,16 @@ import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react import { useMemo } from 'react' import { toast } from 'react-toastify' -import useWalletStore from 'stores/useWalletStore' -import { hardcodedFee } from 'utils/contants' import useCreditManagerStore from 'stores/useCreditManagerStore' +import useWalletStore from 'stores/useWalletStore' import { queryKeys } from 'types/query-keys-factory' +import { hardcodedFee } from 'utils/contants' const useBorrowFunds = ( amount: number, denom: string, withdraw = false, - options: Omit + options: Omit, ) => { const creditManagerClient = useWalletStore((s) => s.clients.creditManager) const selectedAccount = useCreditManagerStore((s) => s.selectedAccount ?? '') @@ -51,7 +51,7 @@ const useBorrowFunds = ( async () => await creditManagerClient?.updateCreditAccount( { accountId: selectedAccount, actions }, - hardcodedFee + hardcodedFee, ), { onSettled: () => { @@ -68,7 +68,7 @@ const useBorrowFunds = ( toast.error(err.message) }, ...options, - } + }, ) } diff --git a/hooks/mutations/useCreateCreditAccount.tsx b/hooks/mutations/useCreateCreditAccount.tsx index 8408ff1d..018391a1 100644 --- a/hooks/mutations/useCreateCreditAccount.tsx +++ b/hooks/mutations/useCreateCreditAccount.tsx @@ -1,11 +1,11 @@ import { useMutation, useQueryClient } from '@tanstack/react-query' import { toast } from 'react-toastify' -import useWalletStore from 'stores/useWalletStore' import { contractAddresses } from 'config/contracts' -import { hardcodedFee } from 'utils/contants' import useCreditManagerStore from 'stores/useCreditManagerStore' +import useWalletStore from 'stores/useWalletStore' import { queryKeys } from 'types/query-keys-factory' +import { hardcodedFee } from 'utils/contants' // 200000 gas used const executeMsg = { @@ -25,7 +25,7 @@ const useCreateCreditAccount = () => { address, contractAddresses.creditManager, executeMsg, - hardcodedFee + hardcodedFee, ), { onSettled: () => { @@ -42,7 +42,7 @@ const useCreateCreditAccount = () => { setSelectedAccount(createdID) toast.success('New account created') }, - } + }, ) } diff --git a/hooks/mutations/useDeleteCreditAccount.tsx b/hooks/mutations/useDeleteCreditAccount.tsx index 712b9146..9ff41be3 100644 --- a/hooks/mutations/useDeleteCreditAccount.tsx +++ b/hooks/mutations/useDeleteCreditAccount.tsx @@ -1,10 +1,10 @@ import { useMutation, useQueryClient } from '@tanstack/react-query' import { toast } from 'react-toastify' -import useWalletStore from 'stores/useWalletStore' import { contractAddresses } from 'config/contracts' -import { hardcodedFee } from 'utils/contants' +import useWalletStore from 'stores/useWalletStore' import { queryKeys } from 'types/query-keys-factory' +import { hardcodedFee } from 'utils/contants' const useCreateCreditAccount = (accountId: string) => { const signingClient = useWalletStore((s) => s.signingClient) @@ -22,7 +22,7 @@ const useCreateCreditAccount = (accountId: string) => { token_id: accountId, }, }, - hardcodedFee + hardcodedFee, ), { onSettled: () => { @@ -34,7 +34,7 @@ const useCreateCreditAccount = (accountId: string) => { onSuccess: () => { toast.success('Credit Account Deleted') }, - } + }, ) } diff --git a/hooks/mutations/useDepositCreditAccount.tsx b/hooks/mutations/useDepositCreditAccount.tsx index 1e2a617d..d835978c 100644 --- a/hooks/mutations/useDepositCreditAccount.tsx +++ b/hooks/mutations/useDepositCreditAccount.tsx @@ -1,10 +1,10 @@ import { useMutation, useQueryClient } from '@tanstack/react-query' import { toast } from 'react-toastify' -import useWalletStore from 'stores/useWalletStore' import { contractAddresses } from 'config/contracts' -import { hardcodedFee } from 'utils/contants' +import useWalletStore from 'stores/useWalletStore' import { queryKeys } from 'types/query-keys-factory' +import { hardcodedFee } from 'utils/contants' const useDepositCreditAccount = ( accountId: string, @@ -12,7 +12,7 @@ const useDepositCreditAccount = ( amount: number, options?: { onSuccess?: () => void - } + }, ) => { const signingClient = useWalletStore((s) => s.signingClient) const address = useWalletStore((s) => s.address) @@ -44,7 +44,7 @@ const useDepositCreditAccount = ( denom, amount: String(amount), }, - ] + ], ), { onError: (err: Error) => { @@ -57,7 +57,7 @@ const useDepositCreditAccount = ( options?.onSuccess && options.onSuccess() }, - } + }, ) } diff --git a/hooks/mutations/useRepayFunds.tsx b/hooks/mutations/useRepayFunds.tsx index 7c41a509..fb4ee003 100644 --- a/hooks/mutations/useRepayFunds.tsx +++ b/hooks/mutations/useRepayFunds.tsx @@ -1,13 +1,13 @@ import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query' +import BigNumber from 'bignumber.js' import { useMemo } from 'react' import { toast } from 'react-toastify' -import BigNumber from 'bignumber.js' -import useWalletStore from 'stores/useWalletStore' import { contractAddresses } from 'config/contracts' -import { hardcodedFee } from 'utils/contants' import useCreditManagerStore from 'stores/useCreditManagerStore' +import useWalletStore from 'stores/useWalletStore' import { queryKeys } from 'types/query-keys-factory' +import { hardcodedFee } from 'utils/contants' import { getTokenDecimals } from 'utils/tokens' // 0.001% buffer / slippage to avoid repay action from not fully repaying the debt amount @@ -16,7 +16,7 @@ const REPAY_BUFFER = 1.00001 const useRepayFunds = ( amount: number, denom: string, - options: Omit + options: Omit, ) => { const signingClient = useWalletStore((s) => s.signingClient) const selectedAccount = useCreditManagerStore((s) => s.selectedAccount) @@ -61,7 +61,7 @@ const useRepayFunds = ( denom, amount: adjustedAmount, }, - ] + ], ), { onSettled: () => { @@ -74,7 +74,7 @@ const useRepayFunds = ( toast.error(err.message) }, ...options, - } + }, ) } diff --git a/hooks/mutations/useWithdrawFunds.tsx b/hooks/mutations/useWithdrawFunds.tsx index e0310a64..2457a252 100644 --- a/hooks/mutations/useWithdrawFunds.tsx +++ b/hooks/mutations/useWithdrawFunds.tsx @@ -2,10 +2,10 @@ import { useMutation, useQueryClient } from '@tanstack/react-query' import { useMemo } from 'react' import { toast } from 'react-toastify' -import useWalletStore from 'stores/useWalletStore' -import { hardcodedFee } from 'utils/contants' import useCreditManagerStore from 'stores/useCreditManagerStore' +import useWalletStore from 'stores/useWalletStore' import { queryKeys } from 'types/query-keys-factory' +import { hardcodedFee } from 'utils/contants' const useWithdrawFunds = ( amount: number, @@ -13,7 +13,7 @@ const useWithdrawFunds = ( denom: string, options?: { onSuccess?: () => void - } + }, ) => { const selectedAccount = useCreditManagerStore((s) => s.selectedAccount ?? '') const address = useWalletStore((s) => s.address) @@ -55,7 +55,7 @@ const useWithdrawFunds = ( async () => creditManagerClient?.updateCreditAccount( { accountId: selectedAccount, actions }, - hardcodedFee + hardcodedFee, ), { onSuccess: () => { @@ -69,7 +69,7 @@ const useWithdrawFunds = ( onError: (err: Error) => { toast.error(err.message) }, - } + }, ) } diff --git a/hooks/useAccountStats.tsx b/hooks/useAccountStats.tsx index bbe6ae75..10dd0d73 100644 --- a/hooks/useAccountStats.tsx +++ b/hooks/useAccountStats.tsx @@ -1,8 +1,9 @@ -import { useMemo } from 'react' import BigNumber from 'bignumber.js' +import { useMemo } from 'react' import useCreditManagerStore from 'stores/useCreditManagerStore' import { getTokenDecimals } from 'utils/tokens' + import useCreditAccountPositions from './useCreditAccountPositions' import useMarkets from './useMarkets' import useTokenPrices from './useTokenPrices' @@ -49,7 +50,7 @@ const useAccountStats = () => { const totalWeightedPositions = positionsData.coins.reduce((acc, coin) => { const tokenWeightedValue = BigNumber(getTokenTotalUSDValue(coin.amount, coin.denom)).times( - Number(marketsData[coin.denom].liquidation_threshold) + Number(marketsData[coin.denom].liquidation_threshold), ) return tokenWeightedValue.plus(acc).toNumber() diff --git a/hooks/useAllBalances.tsx b/hooks/useAllBalances.tsx index 78d1b802..77759e2b 100644 --- a/hooks/useAllBalances.tsx +++ b/hooks/useAllBalances.tsx @@ -17,7 +17,7 @@ const useAllBalances = () => { { enabled: !!address, staleTime: Infinity, - } + }, ) return { diff --git a/hooks/useAllowedCoins.tsx b/hooks/useAllowedCoins.tsx index 44a36489..ebd0a49f 100644 --- a/hooks/useAllowedCoins.tsx +++ b/hooks/useAllowedCoins.tsx @@ -1,7 +1,7 @@ import { useQuery } from '@tanstack/react-query' -import useWalletStore from 'stores/useWalletStore' import { contractAddresses } from 'config/contracts' +import useWalletStore from 'stores/useWalletStore' import { queryKeys } from 'types/query-keys-factory' type Result = string[] @@ -19,7 +19,7 @@ const useAllowedCoins = () => { { enabled: !!client, staleTime: Infinity, - } + }, ) return { diff --git a/hooks/useCalculateMaxBorrowAmount.tsx b/hooks/useCalculateMaxBorrowAmount.tsx index 6fe4cc1e..ffcab6d6 100644 --- a/hooks/useCalculateMaxBorrowAmount.tsx +++ b/hooks/useCalculateMaxBorrowAmount.tsx @@ -1,12 +1,13 @@ -import { useCallback, useMemo } from 'react' import BigNumber from 'bignumber.js' +import { useCallback, useMemo } from 'react' import useCreditManagerStore from 'stores/useCreditManagerStore' import { getTokenDecimals } from 'utils/tokens' + import useCreditAccountPositions from './useCreditAccountPositions' import useMarkets from './useMarkets' -import useTokenPrices from './useTokenPrices' import useRedbankBalances from './useRedbankBalances' +import useTokenPrices from './useTokenPrices' const getApproximateHourlyInterest = (amount: string, borrowAPY: string) => { const hourlyAPY = BigNumber(borrowAPY).div(24 * 365) @@ -28,7 +29,7 @@ const useCalculateMaxBorrowAmount = (denom: string, isUnderCollateralized: boole return BigNumber(amount).times(tokenPrices[denom]).toNumber() }, - [tokenPrices] + [tokenPrices], ) return useMemo(() => { @@ -37,7 +38,7 @@ const useCalculateMaxBorrowAmount = (denom: string, isUnderCollateralized: boole // 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) + Number(marketsData[coin.denom].max_loan_to_value), ) return tokenWeightedValue.plus(acc).toNumber() @@ -48,11 +49,11 @@ const useCalculateMaxBorrowAmount = (denom: string, isUnderCollateralized: boole const totalLiabilitiesValue = positionsData?.debts.reduce((acc, coin) => { const estimatedInterestAmount = getApproximateHourlyInterest( coin.amount, - marketsData[coin.denom].borrow_rate + marketsData[coin.denom].borrow_rate, ) const tokenDebtValue = BigNumber(getTokenValue(coin.amount, coin.denom)).plus( - estimatedInterestAmount + estimatedInterestAmount, ) return tokenDebtValue.plus(acc).toNumber() diff --git a/hooks/useCalculateMaxWithdrawAmount.tsx b/hooks/useCalculateMaxWithdrawAmount.tsx index 4c8dc8fb..722c91e6 100644 --- a/hooks/useCalculateMaxWithdrawAmount.tsx +++ b/hooks/useCalculateMaxWithdrawAmount.tsx @@ -1,11 +1,12 @@ -import { useCallback, useMemo } from 'react' import BigNumber from 'bignumber.js' +import { useCallback, useMemo } from 'react' -import { getTokenDecimals } from 'utils/tokens' -import useCreditAccountPositions from './useCreditAccountPositions' import useCreditManagerStore from 'stores/useCreditManagerStore' -import useTokenPrices from './useTokenPrices' +import { getTokenDecimals } from 'utils/tokens' + +import useCreditAccountPositions from './useCreditAccountPositions' import useMarkets from './useMarkets' +import useTokenPrices from './useTokenPrices' const getApproximateHourlyInterest = (amount: string, borrowAPY: string) => { const hourlyAPY = BigNumber(borrowAPY).div(24 * 365) @@ -28,7 +29,7 @@ const useCalculateMaxWithdrawAmount = (denom: string, borrow: boolean) => { return BigNumber(amount).times(tokenPrices[denom]).toNumber() }, - [tokenPrices] + [tokenPrices], ) const tokenAmountInCreditAccount = useMemo(() => { @@ -48,10 +49,10 @@ const useCalculateMaxWithdrawAmount = (denom: string, borrow: boolean) => { const totalLiabilitiesValue = positionsData?.debts.reduce((acc, coin) => { const estimatedInterestAmount = getApproximateHourlyInterest( coin.amount, - marketsData[coin.denom].borrow_rate + marketsData[coin.denom].borrow_rate, ) const tokenDebtValue = BigNumber(getTokenValue(coin.amount, coin.denom)).plus( - estimatedInterestAmount + estimatedInterestAmount, ) return tokenDebtValue.plus(acc).toNumber() @@ -61,7 +62,7 @@ const useCalculateMaxWithdrawAmount = (denom: string, borrow: boolean) => { if (coin.denom === denom) return acc const tokenWeightedValue = BigNumber(getTokenValue(coin.amount, coin.denom)).times( - Number(marketsData[coin.denom].max_loan_to_value) + Number(marketsData[coin.denom].max_loan_to_value), ) return tokenWeightedValue.plus(acc).toNumber() diff --git a/hooks/useCreditAccountPositions.tsx b/hooks/useCreditAccountPositions.tsx index 40a16709..a425617e 100644 --- a/hooks/useCreditAccountPositions.tsx +++ b/hooks/useCreditAccountPositions.tsx @@ -1,9 +1,9 @@ +import { Coin } from '@cosmjs/stargate' import { useQuery } from '@tanstack/react-query' import { useMemo } from 'react' -import { Coin } from '@cosmjs/stargate' -import useWalletStore from 'stores/useWalletStore' import { contractAddresses } from 'config/contracts' +import useWalletStore from 'stores/useWalletStore' import { queryKeys } from 'types/query-keys-factory' interface DebtAmount { @@ -40,7 +40,7 @@ const useCreditAccountPositions = (accountId: string) => { enabled: !!address && !!client, refetchInterval: 30000, staleTime: Infinity, - } + }, ) return { diff --git a/hooks/useCreditAccounts.tsx b/hooks/useCreditAccounts.tsx index 70491d85..82b9c112 100644 --- a/hooks/useCreditAccounts.tsx +++ b/hooks/useCreditAccounts.tsx @@ -1,9 +1,9 @@ import { useQuery } from '@tanstack/react-query' import { useMemo } from 'react' -import useWalletStore from 'stores/useWalletStore' import { contractAddresses } from 'config/contracts' import useCreditManagerStore from 'stores/useCreditManagerStore' +import useWalletStore from 'stores/useWalletStore' import { queryKeys } from 'types/query-keys-factory' type Result = { @@ -35,7 +35,7 @@ const useCreditAccounts = () => { creditManagerActions.setSelectedAccount(data.tokens[0]) } }, - } + }, ) return { diff --git a/hooks/useMarkets.tsx b/hooks/useMarkets.tsx index bf42ecde..58b3f7ef 100644 --- a/hooks/useMarkets.tsx +++ b/hooks/useMarkets.tsx @@ -86,7 +86,7 @@ const useMarkets = () => { }), { staleTime: Infinity, - } + }, ) return { diff --git a/hooks/useRedbankBalances.tsx b/hooks/useRedbankBalances.tsx index 4fb96a58..14541d4b 100644 --- a/hooks/useRedbankBalances.tsx +++ b/hooks/useRedbankBalances.tsx @@ -1,6 +1,6 @@ -import { useMemo } from 'react' -import { useQuery } from '@tanstack/react-query' import { Coin } from '@cosmjs/stargate' +import { useQuery } from '@tanstack/react-query' +import { useMemo } from 'react' import { contractAddresses } from 'config/contracts' import { queryKeys } from 'types/query-keys-factory' @@ -50,7 +50,7 @@ const useRedbankBalances = () => { ...acc, [coin.denom]: coin.amount, }), - {} + {}, ) as { [key in string]: string } }, [result.data]), } diff --git a/hooks/useTokenBalance.tsx b/hooks/useTokenBalance.tsx index d6f334d2..57357ccf 100644 --- a/hooks/useTokenBalance.tsx +++ b/hooks/useTokenBalance.tsx @@ -2,8 +2,8 @@ import { useQuery } from '@tanstack/react-query' import BigNumber from 'bignumber.js' import useWalletStore from 'stores/useWalletStore' -import { chain } from 'utils/chains' import { queryKeys } from 'types/query-keys-factory' +import { chain } from 'utils/chains' type Result = { balance: { @@ -21,11 +21,11 @@ const useTokenBalance = (denom?: string) => { fetch( `${chain.rest}/cosmos/bank/v1beta1/balances/${address}/by_denom?denom=${ denom || chain.stakeCurrency.coinMinimalDenom - }` + }`, ).then((res) => res.json()), { enabled: !!address, - } + }, ) return { diff --git a/hooks/useTokenPrices.tsx b/hooks/useTokenPrices.tsx index e4f56b49..83e7218e 100644 --- a/hooks/useTokenPrices.tsx +++ b/hooks/useTokenPrices.tsx @@ -9,7 +9,7 @@ const useTokenPrices = () => { }), { staleTime: Infinity, - } + }, ) } diff --git a/package.json b/package.json index f3fa48dd..00259a9c 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "scripts": { "dev": "next dev", "build": "next build", + "format": "eslint . --ext=ts,tsx --fix && prettier --write ./**/*.ts ./**/*.tsx", "start": "next start", "lint": "next lint" }, @@ -41,6 +42,7 @@ "autoprefixer": "^10.4.13", "eslint": "8.23.0", "eslint-config-next": "12.3.1", + "eslint-plugin-import": "^2.26.0", "postcss": "^8.4.16", "prettier": "^2.7.1", "prettier-plugin-tailwindcss": "^0.1.13", diff --git a/pages/_app.tsx b/pages/_app.tsx index e8f18733..1499de96 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -1,13 +1,14 @@ -import { useEffect } from 'react' +import 'react-toastify/dist/ReactToastify.min.css' +import '../styles/globals.css' + +import detectEthereumProvider from '@metamask/detect-provider' +import { QueryClient, QueryClientProvider } from '@tanstack/react-query' +import { ReactQueryDevtools } from '@tanstack/react-query-devtools' import type { AppProps } from 'next/app' import Head from 'next/head' +import { useEffect } from 'react' import { ToastContainer, Zoom } from 'react-toastify' -import 'react-toastify/dist/ReactToastify.min.css' -import { QueryClient, QueryClientProvider } from '@tanstack/react-query' -import detectEthereumProvider from '@metamask/detect-provider' -import { ReactQueryDevtools } from '@tanstack/react-query-devtools' -import '../styles/globals.css' import Layout from 'components/Layout' import useWalletStore from 'stores/useWalletStore' @@ -38,7 +39,7 @@ function MyApp({ Component, pageProps }: AppProps) { Mars V2 {/* */} - + @@ -48,7 +49,7 @@ function MyApp({ Component, pageProps }: AppProps) { { } return ( -
-
- +
+
+
-

Borrowings

+

Borrowings

{
-

Available to Borrow

+

Available to Borrow

{ diff --git a/pages/earn.tsx b/pages/earn.tsx index f77c384c..44edb990 100644 --- a/pages/earn.tsx +++ b/pages/earn.tsx @@ -1,11 +1,12 @@ import React from 'react' + import Container from 'components/Container' const Earn = () => { return ( -
- Yield Module - Placeholder +
+ Yield Module + Placeholder
) } diff --git a/pages/index.tsx b/pages/index.tsx index 26195bec..8019bef8 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,23 +1,23 @@ -import React, { useEffect, useState } from 'react' -import type { NextPage } from 'next' // import Head from "next/head"; // import Image from "next/image"; // import styles from "../styles/Home.module.css"; import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' -// import { Coin } from "@cosmjs/stargate"; -import { toast } from 'react-toastify' -import BigNumber from 'bignumber.js' import { useQueryClient } from '@tanstack/react-query' +import BigNumber from 'bignumber.js' +import type { NextPage } from 'next' +import React, { useEffect, useState } from 'react' +import { toast } from 'react-toastify' -import Container from 'components/Container' import Button from 'components/Button' -import useWalletStore from 'stores/useWalletStore' -import { chain } from 'utils/chains' -import { contractAddresses } from 'config/contracts' -import { hardcodedFee } from 'utils/contants' +import Container from 'components/Container' import Spinner from 'components/Spinner' +import { contractAddresses } from 'config/contracts' +// import { Coin } from "@cosmjs/stargate"; import useCreditManagerStore from 'stores/useCreditManagerStore' +import useWalletStore from 'stores/useWalletStore' import { queryKeys } from 'types/query-keys-factory' +import { chain } from 'utils/chains' +import { hardcodedFee } from 'utils/contants' const Home: NextPage = () => { const [sendAmount, setSendAmount] = useState('') @@ -73,7 +73,7 @@ const Home: NextPage = () => { .toString(), }, ], - hardcodedFee + hardcodedFee, ) console.log('txResponse', res) @@ -81,13 +81,13 @@ const Home: NextPage = () => { , - { autoClose: false } + { autoClose: false }, ) } catch (e: any) { console.log(e) @@ -111,7 +111,7 @@ const Home: NextPage = () => { address, contractAddresses.creditManager, executeMsg, - hardcodedFee + hardcodedFee, ) console.log('mint result', createResult) @@ -119,13 +119,13 @@ const Home: NextPage = () => { , - { autoClose: false } + { autoClose: false }, ) queryClient.invalidateQueries(queryKeys.creditAccounts(address)) @@ -149,7 +149,7 @@ const Home: NextPage = () => { const allTokensResponse = await signingClient?.queryContractSmart( contractAddresses.accountNft, - allTokensQueryMsg + allTokensQueryMsg, ) setAllTokens(allTokensResponse.tokens) @@ -179,7 +179,7 @@ const Home: NextPage = () => { const tokensResponse = await signingClient?.queryContractSmart( contractAddresses.accountNft, - tokensQueryMsg + tokensQueryMsg, ) console.log('res tokens', tokensResponse) @@ -219,7 +219,7 @@ const Home: NextPage = () => { address, contractAddresses.creditManager, executeMsg, - hardcodedFee + hardcodedFee, ) console.log('borrow result', borrowResult) @@ -227,13 +227,13 @@ const Home: NextPage = () => { , - { autoClose: false } + { autoClose: false }, ) queryClient.invalidateQueries(queryKeys.creditAccounts(address)) @@ -248,64 +248,64 @@ const Home: NextPage = () => { } return ( -
+
-

Send Tokens

-
+

Send Tokens

+

Address:

setRecipientAddress(e.target.value)} />

Amount:

setSendAmount(e.target.value)} />
- -

Create Credit Account (Mint NFT)

-
-

Get all Credit Accounts

-
-

Borrow OSMO

+

Borrow OSMO

setBorrowAmount(e.target.valueAsNumber)} /> -
{allTokens && ( -
-
-
All Tokens
-

- {allTokens.length} total

+
+
+
All Tokens
+

- {allTokens.length} total

{allTokens.map((token) => (

{token}

@@ -314,9 +314,9 @@ const Home: NextPage = () => { )} {walletTokens && ( <> -
-
Your Tokens
-

- {walletTokens.length} total

+
+
Your Tokens
+

- {walletTokens.length} total

{walletTokens.map((token) => (

{token}

@@ -324,7 +324,7 @@ const Home: NextPage = () => { )}
- {error &&
{error}
} + {error &&
{error}
} {isLoading && (
diff --git a/pages/portfolio.tsx b/pages/portfolio.tsx index 1dc073dd..df9cde29 100644 --- a/pages/portfolio.tsx +++ b/pages/portfolio.tsx @@ -48,39 +48,39 @@ const mockedAccounts = [ const Portfolio = () => { return ( -
- Portfolio Module -
+
+ Portfolio Module +
{mockedAccounts.map((account) => ( -

{account.label}

-
+

{account.label}

+

{formatCurrency(account.networth)}

-

Net worth

+

Net worth

{formatCurrency(account.totalPositionValue)}

-

Total Position Value

+

Total Position Value

{formatCurrency(account.debt)}

-

Debt

+

Debt

0 ? 'text-green-400' : 'text-red-500'}`}> {account.profit > 0 && '+'} {formatCurrency(account.profit)}

-

P&L

+

P&L

{account.leverage}

-

Current Leverage

+

Current Leverage

{account.maxLeverage}

-

Max Leverage

+

Max Leverage

diff --git a/pages/trade.tsx b/pages/trade.tsx index 14a352af..108eb70f 100644 --- a/pages/trade.tsx +++ b/pages/trade.tsx @@ -1,12 +1,13 @@ import React from 'react' + import Container from 'components/Container' const Trade = () => { return (
-
- Graph/Tradingview Module -
+
+ Graph/Tradingview Module +
Buy/Sell module Orderbook module (optional)
diff --git a/stores/useCreditManagerStore.tsx b/stores/useCreditManagerStore.tsx index 668887c7..c7c7fb84 100644 --- a/stores/useCreditManagerStore.tsx +++ b/stores/useCreditManagerStore.tsx @@ -28,10 +28,10 @@ const useCreditManagerStore = create()( name: 'creditManager', partialize: (state) => Object.fromEntries( - Object.entries(state).filter(([key]) => ['selectedAccount'].includes(key)) + Object.entries(state).filter(([key]) => ['selectedAccount'].includes(key)), ), - } - ) + }, + ), ) export default useCreditManagerStore diff --git a/stores/useWalletStore.tsx b/stores/useWalletStore.tsx index 133d5635..35546299 100644 --- a/stores/useWalletStore.tsx +++ b/stores/useWalletStore.tsx @@ -1,12 +1,12 @@ +import { CosmWasmClient, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' import create from 'zustand' import { persist } from 'zustand/middleware' -import { Wallet } from 'types' -import { CosmWasmClient, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' -import { chain } from 'utils/chains' import { contractAddresses } from 'config/contracts' +import { Wallet } from 'types' import { AccountNftClient } from 'types/generated/account-nft/AccountNft.client' import { CreditManagerClient } from 'types/generated/credit-manager/CreditManager.client' +import { chain } from 'utils/chains' interface WalletStore { address: string @@ -45,12 +45,12 @@ const useWalletStore = create()( const accountNft = new AccountNftClient( signingClient, address, - contractAddresses.accountNft + contractAddresses.accountNft, ) const creditManager = new CreditManagerClient( signingClient, address, - contractAddresses.creditManager + contractAddresses.creditManager, ) set(() => ({ @@ -70,7 +70,7 @@ const useWalletStore = create()( const address = key.bech32Address const signingClientInstance = await SigningCosmWasmClient.connectWithSigner( chain.rpc, - offlineSigner + offlineSigner, ) get().actions.initClients(address, signingClientInstance) @@ -91,7 +91,7 @@ const useWalletStore = create()( const offlineSigner = window.keplr.getOfflineSigner(chain.chainId) const signingClientInstance = await SigningCosmWasmClient.connectWithSigner( chain.rpc, - offlineSigner + offlineSigner, ) get().actions.initClients(address, signingClientInstance) @@ -106,11 +106,11 @@ const useWalletStore = create()( partialize: (state) => Object.fromEntries( Object.entries(state).filter( - ([key]) => !['client', 'metamaskInstalled', 'actions', 'address'].includes(key) - ) + ([key]) => !['client', 'metamaskInstalled', 'actions', 'address'].includes(key), + ), ), - } - ) + }, + ), ) export default useWalletStore diff --git a/types/generated/account-nft/AccountNft.client.ts b/types/generated/account-nft/AccountNft.client.ts index 82c371e9..3e4cd96c 100644 --- a/types/generated/account-nft/AccountNft.client.ts +++ b/types/generated/account-nft/AccountNft.client.ts @@ -5,29 +5,30 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { Coin, StdFee } from '@cosmjs/amino' +import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' + import { - InstantiateMsg, - ExecuteMsg, - Binary, - Expiration, - Timestamp, - Uint64, - QueryMsg, AllNftInfoResponseForEmpty, - OwnerOfResponse, Approval, - NftInfoResponseForEmpty, - Empty, - OperatorsResponse, - TokensResponse, ApprovalResponse, ApprovalsResponse, + Binary, ContractInfoResponse, + Empty, + ExecuteMsg, + Expiration, + InstantiateMsg, MinterResponse, + NftInfoResponseForEmpty, NumTokensResponse, + OperatorsResponse, + OwnerOfResponse, + QueryMsg, String, + Timestamp, + TokensResponse, + Uint64, } from './AccountNft.types' export interface AccountNftReadOnlyInterface { contractAddress: string diff --git a/types/generated/account-nft/AccountNft.react-query.ts b/types/generated/account-nft/AccountNft.react-query.ts index 67eba018..9c01f5ef 100644 --- a/types/generated/account-nft/AccountNft.react-query.ts +++ b/types/generated/account-nft/AccountNft.react-query.ts @@ -5,32 +5,33 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { Coin, StdFee } from '@cosmjs/amino' import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { StdFee, Coin } from '@cosmjs/amino' +import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' + +import { AccountNftClient, AccountNftQueryClient } from './AccountNft.client' import { - InstantiateMsg, - ExecuteMsg, - Binary, - Expiration, - Timestamp, - Uint64, - QueryMsg, AllNftInfoResponseForEmpty, - OwnerOfResponse, Approval, - NftInfoResponseForEmpty, - Empty, - OperatorsResponse, - TokensResponse, ApprovalResponse, ApprovalsResponse, + Binary, ContractInfoResponse, + Empty, + ExecuteMsg, + Expiration, + InstantiateMsg, MinterResponse, + NftInfoResponseForEmpty, NumTokensResponse, + OperatorsResponse, + OwnerOfResponse, + QueryMsg, String, + Timestamp, + TokensResponse, + Uint64, } from './AccountNft.types' -import { AccountNftQueryClient, AccountNftClient } from './AccountNft.client' export const accountNftQueryKeys = { contract: [ { diff --git a/types/generated/account-nft/bundle.ts b/types/generated/account-nft/bundle.ts index de99f813..61eeb569 100644 --- a/types/generated/account-nft/bundle.ts +++ b/types/generated/account-nft/bundle.ts @@ -5,9 +5,9 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _0 from './AccountNft.types' import * as _1 from './AccountNft.client' import * as _2 from './AccountNft.react-query' +import * as _0 from './AccountNft.types' export namespace contracts { export const AccountNft = { ..._0, ..._1, ..._2 } } diff --git a/types/generated/credit-manager/CreditManager.client.ts b/types/generated/credit-manager/CreditManager.client.ts index 9610248c..93763a88 100644 --- a/types/generated/credit-manager/CreditManager.client.ts +++ b/types/generated/credit-manager/CreditManager.client.ts @@ -5,42 +5,43 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { StdFee } from '@cosmjs/amino' +import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' + import { - Decimal, - OracleBaseForString, - RedBankBaseForString, - SwapperBaseForString, - InstantiateMsg, - VaultBaseForString, - ExecuteMsg, Action, - Uint128, - CallbackMsg, Addr, - Coin, - ConfigUpdates, - VaultBaseForAddr, - QueryMsg, ArrayOfCoinBalanceResponseItem, - CoinBalanceResponseItem, - ArrayOfSharesResponseItem, - SharesResponseItem, ArrayOfDebtShares, - DebtShares, - ArrayOfVaultWithBalance, - VaultWithBalance, - ArrayOfVaultPositionResponseItem, - VaultPositionResponseItem, - VaultPosition, - VaultPositionState, + ArrayOfSharesResponseItem, ArrayOfString, ArrayOfVaultBaseForString, + ArrayOfVaultPositionResponseItem, + ArrayOfVaultWithBalance, + CallbackMsg, + Coin, + CoinBalanceResponseItem, ConfigResponse, - HealthResponse, - Positions, + ConfigUpdates, DebtAmount, + DebtShares, + Decimal, + ExecuteMsg, + HealthResponse, + InstantiateMsg, + OracleBaseForString, + Positions, + QueryMsg, + RedBankBaseForString, + SharesResponseItem, + SwapperBaseForString, + Uint128, + VaultBaseForAddr, + VaultBaseForString, + VaultPosition, + VaultPositionResponseItem, + VaultPositionState, + VaultWithBalance, } from './CreditManager.types' export interface CreditManagerReadOnlyInterface { contractAddress: string diff --git a/types/generated/credit-manager/CreditManager.react-query.ts b/types/generated/credit-manager/CreditManager.react-query.ts index 9d2140d2..43374638 100644 --- a/types/generated/credit-manager/CreditManager.react-query.ts +++ b/types/generated/credit-manager/CreditManager.react-query.ts @@ -5,45 +5,46 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' -import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { StdFee } from '@cosmjs/amino' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' + +import { CreditManagerClient, CreditManagerQueryClient } from './CreditManager.client' import { - Decimal, - OracleBaseForString, - RedBankBaseForString, - SwapperBaseForString, - InstantiateMsg, - VaultBaseForString, - ExecuteMsg, Action, - Uint128, - CallbackMsg, Addr, - Coin, - ConfigUpdates, - VaultBaseForAddr, - QueryMsg, ArrayOfCoinBalanceResponseItem, - CoinBalanceResponseItem, - ArrayOfSharesResponseItem, - SharesResponseItem, ArrayOfDebtShares, - DebtShares, - ArrayOfVaultWithBalance, - VaultWithBalance, - ArrayOfVaultPositionResponseItem, - VaultPositionResponseItem, - VaultPosition, - VaultPositionState, + ArrayOfSharesResponseItem, ArrayOfString, ArrayOfVaultBaseForString, + ArrayOfVaultPositionResponseItem, + ArrayOfVaultWithBalance, + CallbackMsg, + Coin, + CoinBalanceResponseItem, ConfigResponse, - HealthResponse, - Positions, + ConfigUpdates, DebtAmount, + DebtShares, + Decimal, + ExecuteMsg, + HealthResponse, + InstantiateMsg, + OracleBaseForString, + Positions, + QueryMsg, + RedBankBaseForString, + SharesResponseItem, + SwapperBaseForString, + Uint128, + VaultBaseForAddr, + VaultBaseForString, + VaultPosition, + VaultPositionResponseItem, + VaultPositionState, + VaultWithBalance, } from './CreditManager.types' -import { CreditManagerQueryClient, CreditManagerClient } from './CreditManager.client' export const creditManagerQueryKeys = { contract: [ { diff --git a/types/generated/credit-manager/bundle.ts b/types/generated/credit-manager/bundle.ts index 5b6328c6..d1b8912c 100644 --- a/types/generated/credit-manager/bundle.ts +++ b/types/generated/credit-manager/bundle.ts @@ -5,9 +5,9 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _3 from './CreditManager.types' import * as _4 from './CreditManager.client' import * as _5 from './CreditManager.react-query' +import * as _3 from './CreditManager.types' export namespace contracts { export const CreditManager = { ..._3, ..._4, ..._5 } } diff --git a/types/generated/mars-oracle-adapter/MarsOracleAdapter.client.ts b/types/generated/mars-oracle-adapter/MarsOracleAdapter.client.ts index 40e562bf..3ec2fd9e 100644 --- a/types/generated/mars-oracle-adapter/MarsOracleAdapter.client.ts +++ b/types/generated/mars-oracle-adapter/MarsOracleAdapter.client.ts @@ -5,22 +5,23 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { Coin, StdFee } from '@cosmjs/amino' +import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' + import { - OracleBaseForString, Addr, - PricingMethod, - InstantiateMsg, - VaultPricingInfo, - ExecuteMsg, - ConfigUpdates, - QueryMsg, ArrayOfVaultPricingInfo, - OracleBaseForAddr, ConfigResponse, + ConfigUpdates, Decimal, + ExecuteMsg, + InstantiateMsg, + OracleBaseForAddr, + OracleBaseForString, PriceResponse, + PricingMethod, + QueryMsg, + VaultPricingInfo, } from './MarsOracleAdapter.types' export interface MarsOracleAdapterReadOnlyInterface { contractAddress: string diff --git a/types/generated/mars-oracle-adapter/MarsOracleAdapter.react-query.ts b/types/generated/mars-oracle-adapter/MarsOracleAdapter.react-query.ts index 8ecf8c9b..d3959660 100644 --- a/types/generated/mars-oracle-adapter/MarsOracleAdapter.react-query.ts +++ b/types/generated/mars-oracle-adapter/MarsOracleAdapter.react-query.ts @@ -5,25 +5,26 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { Coin, StdFee } from '@cosmjs/amino' import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { StdFee, Coin } from '@cosmjs/amino' +import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' + +import { MarsOracleAdapterClient, MarsOracleAdapterQueryClient } from './MarsOracleAdapter.client' import { - OracleBaseForString, Addr, - PricingMethod, - InstantiateMsg, - VaultPricingInfo, - ExecuteMsg, - ConfigUpdates, - QueryMsg, ArrayOfVaultPricingInfo, - OracleBaseForAddr, ConfigResponse, + ConfigUpdates, Decimal, + ExecuteMsg, + InstantiateMsg, + OracleBaseForAddr, + OracleBaseForString, PriceResponse, + PricingMethod, + QueryMsg, + VaultPricingInfo, } from './MarsOracleAdapter.types' -import { MarsOracleAdapterQueryClient, MarsOracleAdapterClient } from './MarsOracleAdapter.client' export const marsOracleAdapterQueryKeys = { contract: [ { diff --git a/types/generated/mars-oracle-adapter/bundle.ts b/types/generated/mars-oracle-adapter/bundle.ts index 02375a2b..7faed529 100644 --- a/types/generated/mars-oracle-adapter/bundle.ts +++ b/types/generated/mars-oracle-adapter/bundle.ts @@ -5,9 +5,9 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _6 from './MarsOracleAdapter.types' import * as _7 from './MarsOracleAdapter.client' import * as _8 from './MarsOracleAdapter.react-query' +import * as _6 from './MarsOracleAdapter.types' export namespace contracts { export const MarsOracleAdapter = { ..._6, ..._7, ..._8 } } diff --git a/types/generated/mock-oracle/MockOracle.client.ts b/types/generated/mock-oracle/MockOracle.client.ts index f22720f3..b88a6453 100644 --- a/types/generated/mock-oracle/MockOracle.client.ts +++ b/types/generated/mock-oracle/MockOracle.client.ts @@ -5,15 +5,16 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { Coin, StdFee } from '@cosmjs/amino' +import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' + import { - Decimal, - InstantiateMsg, CoinPrice, + Decimal, ExecuteMsg, - QueryMsg, + InstantiateMsg, PriceResponse, + QueryMsg, } from './MockOracle.types' export interface MockOracleReadOnlyInterface { contractAddress: string diff --git a/types/generated/mock-oracle/MockOracle.react-query.ts b/types/generated/mock-oracle/MockOracle.react-query.ts index aca388f4..6c9a7324 100644 --- a/types/generated/mock-oracle/MockOracle.react-query.ts +++ b/types/generated/mock-oracle/MockOracle.react-query.ts @@ -5,18 +5,19 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' +import { Coin, StdFee } from '@cosmjs/amino' import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' -import { StdFee, Coin } from '@cosmjs/amino' +import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' + +import { MockOracleClient, MockOracleQueryClient } from './MockOracle.client' import { - Decimal, - InstantiateMsg, CoinPrice, + Decimal, ExecuteMsg, - QueryMsg, + InstantiateMsg, PriceResponse, + QueryMsg, } from './MockOracle.types' -import { MockOracleQueryClient, MockOracleClient } from './MockOracle.client' export const mockOracleQueryKeys = { contract: [ { diff --git a/types/generated/mock-oracle/bundle.ts b/types/generated/mock-oracle/bundle.ts index 5a59629e..11e9ab83 100644 --- a/types/generated/mock-oracle/bundle.ts +++ b/types/generated/mock-oracle/bundle.ts @@ -5,9 +5,9 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _9 from './MockOracle.types' import * as _10 from './MockOracle.client' import * as _11 from './MockOracle.react-query' +import * as _9 from './MockOracle.types' export namespace contracts { export const MockOracle = { ..._9, ..._10, ..._11 } } diff --git a/types/generated/mock-red-bank/MockRedBank.client.ts b/types/generated/mock-red-bank/MockRedBank.client.ts index 2950d9db..af987b13 100644 --- a/types/generated/mock-red-bank/MockRedBank.client.ts +++ b/types/generated/mock-red-bank/MockRedBank.client.ts @@ -5,18 +5,19 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { StdFee } from '@cosmjs/amino' +import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' + import { - Decimal, - InstantiateMsg, - CoinMarketInfo, - ExecuteMsg, - Uint128, Coin, - QueryMsg, - Market, + CoinMarketInfo, + Decimal, + ExecuteMsg, + InstantiateMsg, InterestRateModel, + Market, + QueryMsg, + Uint128, UserAssetDebtResponse, } from './MockRedBank.types' export interface MockRedBankReadOnlyInterface { diff --git a/types/generated/mock-red-bank/MockRedBank.react-query.ts b/types/generated/mock-red-bank/MockRedBank.react-query.ts index e059eabb..1c9f3885 100644 --- a/types/generated/mock-red-bank/MockRedBank.react-query.ts +++ b/types/generated/mock-red-bank/MockRedBank.react-query.ts @@ -5,22 +5,23 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' -import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { StdFee } from '@cosmjs/amino' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' + +import { MockRedBankClient, MockRedBankQueryClient } from './MockRedBank.client' import { - Decimal, - InstantiateMsg, - CoinMarketInfo, - ExecuteMsg, - Uint128, Coin, - QueryMsg, - Market, + CoinMarketInfo, + Decimal, + ExecuteMsg, + InstantiateMsg, InterestRateModel, + Market, + QueryMsg, + Uint128, UserAssetDebtResponse, } from './MockRedBank.types' -import { MockRedBankQueryClient, MockRedBankClient } from './MockRedBank.client' export const mockRedBankQueryKeys = { contract: [ { diff --git a/types/generated/mock-red-bank/bundle.ts b/types/generated/mock-red-bank/bundle.ts index 7b5a5df8..9486e666 100644 --- a/types/generated/mock-red-bank/bundle.ts +++ b/types/generated/mock-red-bank/bundle.ts @@ -5,9 +5,9 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _12 from './MockRedBank.types' import * as _13 from './MockRedBank.client' import * as _14 from './MockRedBank.react-query' +import * as _12 from './MockRedBank.types' export namespace contracts { export const MockRedBank = { ..._12, ..._13, ..._14 } } diff --git a/types/generated/mock-vault/MockVault.client.ts b/types/generated/mock-vault/MockVault.client.ts index 3c40db79..b0719bbd 100644 --- a/types/generated/mock-vault/MockVault.client.ts +++ b/types/generated/mock-vault/MockVault.client.ts @@ -5,17 +5,18 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { StdFee } from '@cosmjs/amino' +import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' + import { - OracleBaseForString, - InstantiateMsg, + ArrayOfCoin, + Coin, ExecuteMsg, + InstantiateMsg, + OracleBaseForString, QueryMsg, Uint128, VaultInfo, - Coin, - ArrayOfCoin, } from './MockVault.types' export interface MockVaultReadOnlyInterface { contractAddress: string diff --git a/types/generated/mock-vault/MockVault.react-query.ts b/types/generated/mock-vault/MockVault.react-query.ts index c4ca251d..6e765ba4 100644 --- a/types/generated/mock-vault/MockVault.react-query.ts +++ b/types/generated/mock-vault/MockVault.react-query.ts @@ -5,20 +5,21 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' -import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { StdFee } from '@cosmjs/amino' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' + +import { MockVaultClient, MockVaultQueryClient } from './MockVault.client' import { - OracleBaseForString, - InstantiateMsg, + ArrayOfCoin, + Coin, ExecuteMsg, + InstantiateMsg, + OracleBaseForString, QueryMsg, Uint128, VaultInfo, - Coin, - ArrayOfCoin, } from './MockVault.types' -import { MockVaultQueryClient, MockVaultClient } from './MockVault.client' export const mockVaultQueryKeys = { contract: [ { diff --git a/types/generated/mock-vault/bundle.ts b/types/generated/mock-vault/bundle.ts index 82599902..d681312e 100644 --- a/types/generated/mock-vault/bundle.ts +++ b/types/generated/mock-vault/bundle.ts @@ -5,9 +5,9 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _15 from './MockVault.types' import * as _16 from './MockVault.client' import * as _17 from './MockVault.react-query' +import * as _15 from './MockVault.types' export namespace contracts { export const MockVault = { ..._15, ..._16, ..._17 } } diff --git a/types/generated/swapper-base/SwapperBase.client.ts b/types/generated/swapper-base/SwapperBase.client.ts index 02a924c0..580a3544 100644 --- a/types/generated/swapper-base/SwapperBase.client.ts +++ b/types/generated/swapper-base/SwapperBase.client.ts @@ -5,21 +5,22 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { StdFee } from '@cosmjs/amino' +import { CosmWasmClient, ExecuteResult, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' + import { - InstantiateMsg, - ExecuteMsg, - Uint128, - Decimal, Addr, - Empty, - Coin, - QueryMsg, - ConfigForString, - EstimateExactInSwapResponse, - RouteResponseForEmpty, ArrayOfRouteResponseForEmpty, + Coin, + ConfigForString, + Decimal, + Empty, + EstimateExactInSwapResponse, + ExecuteMsg, + InstantiateMsg, + QueryMsg, + RouteResponseForEmpty, + Uint128, } from './SwapperBase.types' export interface SwapperBaseReadOnlyInterface { contractAddress: string diff --git a/types/generated/swapper-base/SwapperBase.react-query.ts b/types/generated/swapper-base/SwapperBase.react-query.ts index a47fdc9e..7683bb62 100644 --- a/types/generated/swapper-base/SwapperBase.react-query.ts +++ b/types/generated/swapper-base/SwapperBase.react-query.ts @@ -5,24 +5,25 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from '@tanstack/react-query' -import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' import { StdFee } from '@cosmjs/amino' +import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' +import { useMutation, UseMutationOptions, useQuery, UseQueryOptions } from '@tanstack/react-query' + +import { SwapperBaseClient, SwapperBaseQueryClient } from './SwapperBase.client' import { - InstantiateMsg, - ExecuteMsg, - Uint128, - Decimal, Addr, - Empty, - Coin, - QueryMsg, - ConfigForString, - EstimateExactInSwapResponse, - RouteResponseForEmpty, ArrayOfRouteResponseForEmpty, + Coin, + ConfigForString, + Decimal, + Empty, + EstimateExactInSwapResponse, + ExecuteMsg, + InstantiateMsg, + QueryMsg, + RouteResponseForEmpty, + Uint128, } from './SwapperBase.types' -import { SwapperBaseQueryClient, SwapperBaseClient } from './SwapperBase.client' export const swapperBaseQueryKeys = { contract: [ { diff --git a/types/generated/swapper-base/bundle.ts b/types/generated/swapper-base/bundle.ts index efff3078..ae771c7f 100644 --- a/types/generated/swapper-base/bundle.ts +++ b/types/generated/swapper-base/bundle.ts @@ -5,9 +5,9 @@ * and run the @cosmwasm/ts-codegen generate command to regenerate this file. */ -import * as _18 from './SwapperBase.types' import * as _19 from './SwapperBase.client' import * as _20 from './SwapperBase.react-query' +import * as _18 from './SwapperBase.types' export namespace contracts { export const SwapperBase = { ..._18, ..._19, ..._20 } } diff --git a/utils/experimental-chains.ts b/utils/experimental-chains.ts index 730226bf..0fbc3705 100644 --- a/utils/experimental-chains.ts +++ b/utils/experimental-chains.ts @@ -1,8 +1,9 @@ import { Bech32Address } from '@keplr-wallet/cosmos' + import { ChainId, CosmosChainId, TestnetCosmosChainId } from 'types' export const getEndpointsFromChainId = ( - chainId: TestnetCosmosChainId | CosmosChainId | ChainId + chainId: TestnetCosmosChainId | CosmosChainId | ChainId, ): { rpc: string; rest: string } => { switch (chainId) { case CosmosChainId.Osmosis: diff --git a/utils/formatters.ts b/utils/formatters.ts index ba328841..141acbcb 100644 --- a/utils/formatters.ts +++ b/utils/formatters.ts @@ -5,7 +5,7 @@ export const formatWalletAddress = (address: string, substrLength = 6): string = return `${address.slice(0, substrLength)}...${address.slice( address.length - substrLength, - address.length + address.length, )}` } diff --git a/yarn.lock b/yarn.lock index 8adc6b1c..e523e844 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3452,7 +3452,7 @@ eslint-module-utils@^2.7.3: eslint-plugin-import@^2.26.0: version "2.26.0" - resolved "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz#f812dc47be4f2b72b478a021605a59fc6fe8b88b" integrity sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA== dependencies: array-includes "^3.1.4"
Asset Value SizeAPYAPY
{getTokenSymbol(coin.denom)} {formatCurrency(getTokenTotalUSDValue(coin.amount, coin.denom))} @@ -289,12 +290,12 @@ const WithdrawModal = ({ show, onClose }: any) => { maximumFractionDigits: getTokenDecimals(coin.denom), })} --
{getTokenSymbol(coin.denom)}
{getTokenSymbol(coin.denom)} -{formatCurrency(getTokenTotalUSDValue(coin.amount, coin.denom))} + -{(Number(marketsData?.[coin.denom].borrow_rate) * 100).toFixed(1)}%