From 6b6d717faccd2b134ad3eae0bd9a54b03a02c12a Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Wed, 2 Aug 2023 11:25:13 +0200 Subject: [PATCH] v1.6.0 --- README.md | 28 +- entrypoint.sh | 3 + package.json | 11 +- .../common/Containers/CommonContainer.tsx | 7 +- .../CosmosWalletConnectProvider.tsx | 4 +- src/components/common/Header/ChainSelect.tsx | 1 - .../common/Header/ConnectedButton.tsx | 15 +- .../common/Header/IncentivesButton.tsx | 115 +- src/components/common/Tooltip/Apr.tsx | 3 +- src/components/common/TxModal/Action.tsx | 9 +- .../redbank/AssetTable/ActionsRow.tsx | 21 +- .../DepositColumns/useDepositColumns.tsx | 47 +- .../redbank/RedbankAction/RedbankAction.tsx | 6 +- src/configs/neutron-1.ts | 101 + src/configs/osmo-test-5.ts | 68 +- src/configs/osmosis-1.ts | 41 +- src/configs/pion-1.ts | 31 +- src/constants/appConstants.ts | 1 + src/functions/getSwapUrl.ts | 37 +- src/functions/queries/getDepositDebtQuery.ts | 1 - src/functions/queries/getIncentiveQuery.ts | 9 +- src/functions/queries/getRedbankQuery.ts | 3 +- src/hooks/queries/index.ts | 2 +- src/hooks/queries/useDepositAndDebt.tsx | 2 + src/hooks/queries/useMarsOracle.tsx | 5 +- .../{useSpotPrice.tsx => useMarsPrice.tsx} | 53 +- src/hooks/queries/useRedBank.tsx | 10 +- src/hooks/queries/useUsdPrice.tsx | 20 +- src/images/astro.svg | 30 + src/libs/council.ts | 2 +- src/libs/math.ts | 6 - src/libs/networkConfig.ts | 12 + src/mocks/redBankData.ts | 72 +- src/pages/_app.tsx | 2 + src/pages/redbank/index.tsx | 7 +- src/store/interfaces/common.interface.ts | 2 +- src/store/interfaces/oracles.interface.ts | 1 + src/store/interfaces/redBank.interface.ts | 5 +- src/store/slices/common.ts | 4 +- src/store/slices/oracles.ts | 15 +- src/store/slices/redBank.ts | 93 +- src/styles/_assets.module.scss | 1 + src/styles/_master.scss | 1 + src/types/interfaces/asset.d.ts | 5 +- src/types/interfaces/hoverItem.d.ts | 2 +- src/types/interfaces/networkConfig.d.ts | 1 + src/types/interfaces/redbank.d.ts | 38 +- yarn.lock | 3121 +++++++++++------ 48 files changed, 2644 insertions(+), 1430 deletions(-) create mode 100644 src/configs/neutron-1.ts rename src/hooks/queries/{useSpotPrice.tsx => useMarsPrice.tsx} (63%) create mode 100644 src/images/astro.svg diff --git a/README.md b/README.md index e36bc8e..178078a 100644 --- a/README.md +++ b/README.md @@ -28,17 +28,20 @@ Copy `.env.example` to `.env` and modify the values to suit your needs. We allow the use of environment variables to be passed to the Docker container to specify custom endpoints for the app. The variables are: -| Variable | Description | Default | -| --------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------ | -| URL_OSMOSIS_GQL | The Osmosis Hive GraphQL endpoint to use | https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-hive-front/graphql | -| URL_OSMOSIS_REST | The Osmosis node REST endpoint to use | https://lcd-osmosis.blockapsis.com | -| URL_OSMOSIS_RPC | The Osmosis node RPC endpoint to use | https://rpc-osmosis.blockapsis.com | -| URL_OSMOSIS_TEST_GQL | The Osmosis Testnet Hive GraphQL endpoint to use | https://testnet-osmosis-node.marsprotocol.io/XF32UOOU55CX/osmosis-hive-front/graphql | -| URL_OSMOSIS_TEST_REST | The Osmosis Testnet node REST endpoint to use | https://lcd.osmotest5.osmosis.zone | -| URL_OSMOSIS_TEST_RPC | The Osmosis Testnet node RPC endpoint to use | https://rpc.osmotest5.osmosis.zone | -| URL_NEUTRON_TEST_GQL | The Neutron Testnet Hive GraphQL endpoint to use | https://testnet-neutron-gql.marsprotocol.io/graphql | -| URL_NEUTRON_TEST_REST | The Neutron Testnet node REST endpoint to use | https://rest-palvus.pion-1.ntrn.tech | -| URL_NEUTRON_TEST_RPC | The Neutron Testnet node RPC endpoint to use | https://rpc-palvus.pion-1.ntrn.tech | +| Variable | Description | Default | +| --------------------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------- | +| URL_OSMOSIS_GQL | The Osmosis Hive GraphQL endpoint to use | https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-hive-front/graphql | +| URL_OSMOSIS_REST | The Osmosis node REST endpoint to use | https://lcd-osmosis.blockapsis.com | +| URL_OSMOSIS_RPC | The Osmosis node RPC endpoint to use | https://rpc-osmosis.blockapsis.com | +| URL_OSMOSIS_TEST_GQL | The Osmosis Testnet Hive GraphQL endpoint to use | https://testnet-osmosis-node.marsprotocol.io/XF32UOOU55CX/osmosis-hive-front/graphql | +| URL_OSMOSIS_TEST_REST | The Osmosis Testnet node REST endpoint to use | https://lcd.osmotest5.osmosis.zone | +| URL_OSMOSIS_TEST_RPC | The Osmosis Testnet node RPC endpoint to use | https://rpc.osmotest5.osmosis.zone | +| URL_NEUTRON_GQL | The Neutron Hive GraphQL endpoint to use | https://neutron.rpc.p2p.world/qgrnU6PsQZA8F9S5Fb8Fn3tV3kXmMBl2M9bcc9jWLjQy8p/hive/graphql | +| URL_NEUTRON_REST | The Neutron node REST endpoint to use | https://rest-kralum.neutron-1.neutron.org | +| URL_NEUTRON_RPC | The Neutron node RPC endpoint to use | https://rpc-kralum.neutron-1.neutron.org | +| URL_NEUTRON_TEST_GQL | The Neutron Testnet Hive GraphQL endpoint to use | https://testnet-neutron-gql.marsprotocol.io/graphql | +| URL_NEUTRON_TEST_REST | The Neutron Testnet node REST endpoint to use | https://rest-palvus.pion-1.ntrn.tech | +| URL_NEUTRON_TEST_RPC | The Neutron Testnet node RPC endpoint to use | https://rpc-palvus.pion-1.ntrn.tech | **Sample Docker run command** @@ -52,6 +55,9 @@ docker run -it -p 3000:3000 \ -e URL_OSMOSIS_TEST_GQL=https://testnet-osmosis-node.marsprotocol.io/XF32UOOU55CX/osmosis-hive-front/graphql \ -e URL_OSMOSIS_TEST_REST=https://lcd.osmotest5.osmosis.zone \ -e URL_OSMOSIS_TEST_RPC=https://rpc.osmotest5.osmosis.zone \ + -e URL_NEUTRON_GQL=https://neutron.rpc.p2p.world/qgrnU6PsQZA8F9S5Fb8Fn3tV3kXmMBl2M9bcc9jWLjQy8p/hive/graphql \ + -e URL_NEUTRON_REST=https://rest-palvus.pion-1.ntrn.tech \ + -e URL_NEUTRON_RPC=https://rpc-palvus.pion-1.ntrn.tech \ -e URL_NEUTRON_TEST_GQL=https://testnet-neutron-gql.marsprotocol.io/graphql \ -e URL_NEUTRON_TEST_REST=https://rest-palvus.pion-1.ntrn.tech \ -e URL_NEUTRON_TEST_RPC=https://rpc-palvus.pion-1.ntrn.tech marsprotocol/interface:latest diff --git a/entrypoint.sh b/entrypoint.sh index 4bc030d..6f6a5a3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,6 +10,9 @@ echo "APP_NEXT_OSMOSIS_GQL=$URL_OSMOSIS_GQL" >> $envFilename echo "APP_NEXT_OSMOSIS_TEST_RPC=$URL_OSMOSIS_TEST_RPC" >> $envFilename echo "APP_NEXT_OSMOSIS_TEST_REST=$URL_OSMOSIS_TEST_REST" >> $envFilename echo "APP_NEXT_OSMOSIS_TEST_GQL=$URL_OSMOSIS_TEST_GQL" >> $envFilename +echo "APP_NEXT_NEUTRON_RPC=$URL_NEUTRON_RPC" >> $envFilename +echo "APP_NEXT_NEUTRON_REST=$URL_NEUTRON_REST" >> $envFilename +echo "APP_NEXT_NEUTRON_GQL=$URL_NEUTRON_TEST_GQL" >> $envFilename echo "APP_NEXT_NEUTRON_TEST_RPC=$URL_NEUTRON_TEST_RPC" >> $envFilename echo "APP_NEXT_NEUTRON_TEST_REST=$URL_NEUTRON_TEST_REST" >> $envFilename echo "APP_NEXT_NEUTRON_TEST_GQL=$URL_NEUTRON_TEST_GQL" >> $envFilename diff --git a/package.json b/package.json index 5dcb423..6d137fa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mars", "homepage": "./", - "version": "1.5.3", + "version": "1.6.0", "license": "SEE LICENSE IN LICENSE FILE", "private": false, "scripts": { @@ -18,14 +18,15 @@ "test:coverage": "jest --coverage" }, "dependencies": { - "@cosmjs/cosmwasm-stargate": "^0.30.1", + "@cosmjs/cosmwasm-stargate": "^0.31.0", "@cosmjs/launchpad": "^0.27.1", - "@cosmjs/proto-signing": "^0.30.1", - "@cosmjs/stargate": "^0.30.1", - "@marsprotocol/wallet-connector": "^1.8.6", + "@cosmjs/proto-signing": "^0.31.0", + "@cosmjs/stargate": "^0.31.0", + "@marsprotocol/wallet-connector": "^1.9.6", "@material-ui/core": "^4.12.4", "@material-ui/icons": "^4.11.3", "@ramonak/react-progress-bar": "^5.0.3", + "@sentry/nextjs": "^7.36.0", "@tanstack/react-query": "^4.24.4", "@tanstack/react-table": "^8.7.9", "@testing-library/dom": "^8.20.0", diff --git a/src/components/common/Containers/CommonContainer.tsx b/src/components/common/Containers/CommonContainer.tsx index bee6f14..1306e2b 100644 --- a/src/components/common/Containers/CommonContainer.tsx +++ b/src/components/common/Containers/CommonContainer.tsx @@ -7,7 +7,6 @@ import { WalletConnectionStatus, } from '@marsprotocol/wallet-connector' import { useQueryClient } from '@tanstack/react-query' -import { MARS_SYMBOL } from 'constants/appConstants' import { useBlockHeight, useDepositAndDebt, @@ -18,8 +17,8 @@ import { useUserDebt, useUserIcns, } from 'hooks/queries' +import { useMarsPrice } from 'hooks/queries/useMarsPrice' import { usePythVaa } from 'hooks/queries/usePythVaa' -import { useSpotPrice } from 'hooks/queries/useSpotPrice' import { useUserCollaterals } from 'hooks/queries/useUserCollaterals' import { ReactNode, useEffect, useState } from 'react' import useStore from 'store' @@ -52,7 +51,6 @@ export const CommonContainer = ({ children }: CommonContainerProps) => { const networkConfig = useStore((s) => s.networkConfig) const marketDeposits = useStore((s) => s.marketDeposits) const marketInfo = useStore((s) => s.marketInfo) - const marketIncentiveInfo = useStore((s) => s.marketIncentiveInfo) const migrationInProgress = useStore((s) => s.migrationInProgress) const redBankState = useStore((s) => s.redBankState) const rpc = useStore((s) => s.networkConfig.rpcUrl) @@ -145,7 +143,6 @@ export const CommonContainer = ({ children }: CommonContainerProps) => { userBalancesState, exchangeRates, marketInfo, - marketIncentiveInfo, userDebts, userDeposits, whitelistedAssets, @@ -168,7 +165,7 @@ export const CommonContainer = ({ children }: CommonContainerProps) => { useUserDebt() useUserCollaterals() useMarsOracle() - useSpotPrice(MARS_SYMBOL) + useMarsPrice() useDepositAndDebt() useRedBank() usePythVaa() diff --git a/src/components/common/CosmosWalletConnectProvider/CosmosWalletConnectProvider.tsx b/src/components/common/CosmosWalletConnectProvider/CosmosWalletConnectProvider.tsx index 20e8fe3..d5b5876 100644 --- a/src/components/common/CosmosWalletConnectProvider/CosmosWalletConnectProvider.tsx +++ b/src/components/common/CosmosWalletConnectProvider/CosmosWalletConnectProvider.tsx @@ -30,15 +30,17 @@ export const CosmosWalletConnectProvider = ({ children }: Props) => { rpc: networkConfig.rpcUrl, rest: networkConfig.restUrl, }} + walletConnectProjectId='d93fdffb159bae5ec87d8fee4cdbb045' chainIds={supportedChains} closeIcon={} defaultChainId={currentNetwork} enabledWallets={[ WalletID.Keplr, WalletID.Xdefi, - WalletID.StationWallet, + WalletID.Station, WalletID.Leap, WalletID.Cosmostation, + WalletID.Vectis, WalletID.KeplrMobile, WalletID.CosmostationMobile, ]} diff --git a/src/components/common/Header/ChainSelect.tsx b/src/components/common/Header/ChainSelect.tsx index 1c1188f..61a4e06 100644 --- a/src/components/common/Header/ChainSelect.tsx +++ b/src/components/common/Header/ChainSelect.tsx @@ -65,7 +65,6 @@ export const ChainSelect = () => { exchangeRates: [], assetPricesUSD: [], marketAssetLiquidity: [], - marketIncentiveInfo: [], marketInfo: [], userIcns: undefined, redBankAssets: [], diff --git a/src/components/common/Header/ConnectedButton.tsx b/src/components/common/Header/ConnectedButton.tsx index 79574d3..a63b71f 100644 --- a/src/components/common/Header/ConnectedButton.tsx +++ b/src/components/common/Header/ConnectedButton.tsx @@ -5,7 +5,7 @@ import { findByDenom } from 'functions' import { useUserBalance } from 'hooks/queries' import { formatValue, lookup } from 'libs/parse' import { truncate } from 'libs/text' -import { useCallback, useEffect, useState } from 'react' +import { useCallback, useEffect, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import useClipboard from 'react-use-clipboard' import useStore from 'store' @@ -61,6 +61,11 @@ export const ConnectedButton = () => { baseCurrency.decimals, ) + const [connectedWalletAddress, connectedWalletIsLedger] = useMemo(() => { + if (!connectedWallet?.account) return ['', false] + return [connectedWallet.account.address, connectedWallet.account.isLedger] + }, [connectedWallet]) + useEffect(() => { if (!chainInfo) return setIsTestnet( @@ -71,10 +76,10 @@ export const ConnectedButton = () => { }, [chainInfo]) useEffect(() => { - if (userWalletAddress === connectedWallet?.account.address) return + if (userWalletAddress === connectedWalletAddress) return useStore.setState({ - isLedger: !!connectedWallet?.account.isLedger, - userWalletAddress: connectedWallet?.account.address, + isLedger: connectedWalletIsLedger, + userWalletAddress: connectedWalletAddress, marketAssetLiquidity: [], marketInfo: [], userIcns: undefined, @@ -82,7 +87,7 @@ export const ConnectedButton = () => { redBankState: State.INITIALISING, userBalancesState: State.INITIALISING, }) - }, [connectedWallet?.account.address, userWalletAddress]) + }, [connectedWalletAddress, connectedWalletIsLedger, userWalletAddress]) return (
diff --git a/src/components/common/Header/IncentivesButton.tsx b/src/components/common/Header/IncentivesButton.tsx index 7da03cf..045ce4e 100644 --- a/src/components/common/Header/IncentivesButton.tsx +++ b/src/components/common/Header/IncentivesButton.tsx @@ -10,13 +10,15 @@ import { Tooltip, TxLink, } from 'components/common' -import { MARS_DECIMALS, MARS_SYMBOL } from 'constants/appConstants' +import { MARS_SYMBOL } from 'constants/appConstants' +import { findByDenom } from 'functions' import { getClaimUserRewardsMsgOptions } from 'functions/messages' import { useEstimateFee } from 'hooks/queries' -import { lookup, lookupDenomBySymbol, lookupSymbol } from 'libs/parse' +import { lookup, lookupSymbol } from 'libs/parse' import { useCallback, useEffect, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import useStore from 'store' +import { State } from 'types/enums' import { QUERY_KEYS } from 'types/enums/queryKeys' import styles from './IncentivesButton.module.scss' @@ -32,9 +34,13 @@ export const IncentivesButton = () => { // STORE STATE // --------------- const client = useStore((s) => s.client) + const whitelistedAssets = useStore((s) => s.whitelistedAssets) const otherAssets = useStore((s) => s.otherAssets) const userWalletAddress = useStore((s) => s.userWalletAddress) + const networkConfig = useStore((s) => s.networkConfig) const unclaimedRewards = useStore((s) => s.userUnclaimedRewards) + const convertToDisplayCurrency = useStore((s) => s.convertToDisplayCurrency) + const marsPriceState = useStore((s) => s.marsPriceState) const incentivesContractAddress = useStore((s) => s.networkConfig.contracts.incentives) const chainInfo = useStore((s) => s.chainInfo) const executeMsg = useStore((s) => s.executeMsg) @@ -49,12 +55,13 @@ export const IncentivesButton = () => { const [response, setResponse] = useState() const [error, setError] = useState() const [hasUnclaimedRewards, setHasUnclaimedRewards] = useState(false) + const [unclaimedRewardsValue, setUnclaimedRewardsValue] = useState(0) // --------------- // LOCAL VARIABLES // --------------- - const marsDenom = lookupDenomBySymbol(MARS_SYMBOL, otherAssets) const explorerUrl = chainInfo && SimpleChainInfoList[chainInfo.chainId as ChainInfoID].explorer + const assets = [...whitelistedAssets, ...otherAssets] // --------------- // FUNCTIONS @@ -66,8 +73,18 @@ export const IncentivesButton = () => { }, []) useEffect(() => { - setHasUnclaimedRewards(Number(unclaimedRewards) > 0) - }, [unclaimedRewards]) + let rewardsValue = 0 + let rewardsAmount = 0 + + if (marsPriceState !== State.READY) return + unclaimedRewards.forEach((reward) => { + rewardsValue += convertToDisplayCurrency(reward) + rewardsAmount += Number(reward.amount) + }) + + setUnclaimedRewardsValue(rewardsValue) + setHasUnclaimedRewards(rewardsAmount > 0) + }, [unclaimedRewards, convertToDisplayCurrency, marsPriceState]) const txMsgOptions = useMemo(() => { if (!hasUnclaimedRewards) return @@ -137,31 +154,39 @@ export const IncentivesButton = () => { } const transactionHash = response?.hash || '' - if (!userWalletAddress) return null return (
{showDetails && ( @@ -181,36 +206,48 @@ export const IncentivesButton = () => {
) : ( -
-
-
-

{lookupSymbol(marsDenom, otherAssets)}

-

{t('redbank.redBankRewards')}

-
-
- - -
-
-
+ <> + {unclaimedRewards.map((rewards, index) => { + const asset = findByDenom(assets, rewards.denom) + if (!asset) return null + return ( +
+
+
+

{lookupSymbol(asset.denom, assets)}

+

{t('redbank.redBankRewards')}

+
+
+ + +
+
+
+ ) + })} + )}