From ae8c07d6ce5ee6b5a21825232ac965d70cddd14c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 10:50:05 +0200 Subject: [PATCH 1/8] Build(deps-dev): bump @types/react from 18.2.23 to 18.2.27 (#530) Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.2.23 to 18.2.27. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react) --- updated-dependencies: - dependency-name: "@types/react" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 136eb07a..21a7df24 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@types/lodash.debounce": "^4.0.7", "@types/lodash.throttle": "^4.1.7", "@types/node": "^20.7.0", - "@types/react": "18.2.23", + "@types/react": "18.2.27", "@types/react-dom": "18.2.11", "@types/react-helmet": "^6.1.7", "autoprefixer": "^10.4.16", diff --git a/yarn.lock b/yarn.lock index 053a79e5..38d0666b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3591,10 +3591,10 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@18.2.23": - version "18.2.23" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.23.tgz#60ad6cf4895e93bed858db0e03bcc4ff97d0410e" - integrity sha512-qHLW6n1q2+7KyBEYnrZpcsAmU/iiCh9WGCKgXvMxx89+TYdJWRjZohVIo9XTcoLhfX3+/hP0Pbulu3bCZQ9PSA== +"@types/react@*", "@types/react@18.2.27": + version "18.2.27" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.27.tgz#746e52b06f3ccd5d7a724fd53769b70792601440" + integrity sha512-Wfv7B7FZiR2r3MIqbAlXoY1+tXm4bOqfz4oRr+nyXdBqapDBZ0l/IGcSlAfvxIHEEJjkPU0MYAc/BlFPOcrgLw== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" From 7fac73b4ddd9b4244ea8c7c9806382d31138d5a2 Mon Sep 17 00:00:00 2001 From: Bob van der Helm <34470358+bobthebuidlr@users.noreply.github.com> Date: Wed, 11 Oct 2023 11:07:56 +0200 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=90=9BstAtom=20chart=20data=20(#533)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TradeChart/OsmosisTheGraphDataFeed.ts | 72 ++++++++++++------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts b/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts index c255f3b0..5a59976a 100644 --- a/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts +++ b/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts @@ -34,7 +34,7 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi { baseDenom: string = 'uosmo' batchSize = 1000 enabledMarketAssetDenoms: string[] = [] - pairs: string[] = [] + pairs: { baseAsset: string; quoteAsset: string }[] = [] pairsWithData: string[] = [] intervals: { [key: string]: string } = { '15': '15m', @@ -55,19 +55,6 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi { this.supportedPools = enabledMarketAssets .map((asset) => asset.poolId?.toString()) .filter((poolId) => typeof poolId === 'string') as string[] - this.getAllPairs() - } - - getAllPairs() { - const assets = getEnabledMarketAssets() - const pairs: Set = new Set() - assets.forEach((asset1) => { - assets.forEach((asset2) => { - if (asset1.symbol === asset2.symbol) return - pairs.add(`${asset1.denom}${PAIR_SEPARATOR}${asset2.denom}`) - }) - }) - this.pairs = Array.from(pairs) } getDescription(pairName: string) { @@ -102,6 +89,7 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi { }) .then((res) => res.json()) .then((json) => { + this.pairs = json.data.pairs this.pairsWithData = json.data.pairs.map( (pair: { baseAsset: string; quoteAsset: string }) => { return `${pair.baseAsset}${PAIR_SEPARATOR}${pair.quoteAsset}` @@ -150,14 +138,35 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi { let pair1 = symbolInfo.full_name let pair2: string = '' + let pair3: string = '' if (!this.pairsWithData.includes(pair1)) { - if (this.debug) console.log('Pair does not have data, need to combine with 2nd pair') + if (this.debug) console.log('Pair does not have data, need to combine with other pairs') const [buyAssetDenom, sellAssetDenom] = pair1.split(PAIR_SEPARATOR) - pair1 = `${buyAssetDenom}${PAIR_SEPARATOR}${this.baseDenom}` - pair2 = `${this.baseDenom}${PAIR_SEPARATOR}${sellAssetDenom}` + const pair1Pools = this.pairs.filter((pair) => pair.baseAsset === buyAssetDenom) + const pair2Pools = this.pairs.filter((pair) => pair.quoteAsset === sellAssetDenom) + + const matchedPools = pair1Pools.filter((pool) => { + const asset = pool.quoteAsset + return !!pair2Pools.find((pool) => pool.baseAsset === asset) + }) + + if (matchedPools.length) { + pair1 = `${buyAssetDenom}${PAIR_SEPARATOR}${matchedPools[0].quoteAsset}` + pair2 = `${matchedPools[0].quoteAsset}${PAIR_SEPARATOR}${sellAssetDenom}` + } else { + const middlePair = this.pairs.filter( + (pair) => + pair1Pools.map((pairs) => pairs.quoteAsset).includes(pair.baseAsset) && + pair2Pools.map((pairs) => pairs.baseAsset).includes(pair.quoteAsset), + ) + + pair1 = `${buyAssetDenom}${PAIR_SEPARATOR}${middlePair[0].baseAsset}` + pair2 = `${middlePair[0].baseAsset}${PAIR_SEPARATOR}${middlePair[0].quoteAsset}` + pair3 = `${middlePair[0].quoteAsset}${PAIR_SEPARATOR}${sellAssetDenom}` + } } const pair1Bars = this.queryBarData( @@ -176,13 +185,28 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi { ) } - await Promise.all([pair1Bars, pair2Bars]).then(([pair1Bars, pair2Bars]) => { - let bars = pair1Bars - if (pair2Bars) { - bars = this.combineBars(pair1Bars, pair2Bars) - } - onResult(bars) - }) + let pair3Bars: Promise | null = null + + if (pair3) { + pair3Bars = this.queryBarData( + pair3.split(PAIR_SEPARATOR)[0], + pair3.split(PAIR_SEPARATOR)[1], + interval, + ) + } + + await Promise.all([pair1Bars, pair2Bars, pair3Bars]).then( + ([pair1Bars, pair2Bars, pair3Bars]) => { + let bars = pair1Bars + if (pair2Bars) { + bars = this.combineBars(pair1Bars, pair2Bars) + } + if (pair3Bars) { + bars = this.combineBars(bars, pair3Bars) + } + onResult(bars) + }, + ) } async queryBarData(quote: string, base: string, interval: string): Promise { From b175ee3e0e673973112fd0d3420716a420c33e81 Mon Sep 17 00:00:00 2001 From: Bob van der Helm <34470358+bobthebuidlr@users.noreply.github.com> Date: Wed, 11 Oct 2023 12:45:59 +0200 Subject: [PATCH 3/8] =?UTF-8?q?=E2=9C=A8=20add=204h=20and=201D=20intervals?= =?UTF-8?q?=20(#534)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TradeChart/OsmosisTheGraphDataFeed.ts | 56 ++++++++++++++++--- src/components/Trade/TradeChart/constants.ts | 5 +- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts b/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts index 5a59976a..0fe4ac96 100644 --- a/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts +++ b/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts @@ -40,10 +40,19 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi { '15': '15m', '30': '30m', '60': '1h', + '240': '4h', + '1D': '1d', + } + minutesPerInterval: { [key: string]: number } = { + '15': 15, + '30': 30, + '60': 60, + '240': 60 * 4, + '1D': 60 * 24, } supportedPools: string[] = [] - supportedResolutions = ['15', '30', '60'] as ResolutionString[] + supportedResolutions = ['15', '30', '60', '4h', 'D'] as ResolutionString[] constructor(debug = false, baseDecimals: number, baseDenom: string) { if (debug) console.log('Start TheGraph charting library datafeed') @@ -113,19 +122,22 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi { }) } - async resolveSymbol(pairName: string, onResolve: ResolveCallback, onError: ErrorCallback) { - setTimeout(() => - onResolve({ + resolveSymbol(pairName: string, onResolve: ResolveCallback, onError: ErrorCallback) { + pairName = this.getPairName(pairName) + setTimeout(() => { + const info: LibrarySymbolInfo = { ...defaultSymbolInfo, name: this.getDescription(pairName), - full_name: pairName, + full_name: this.getDescription(pairName), description: this.getDescription(pairName), ticker: this.getDescription(pairName), exchange: this.exchangeName, listed_exchange: this.exchangeName, supported_resolutions: this.supportedResolutions, - }), - ) + base_name: [this.getDescription(pairName)], + } as LibrarySymbolInfo + onResolve(info) + }) } async getBars( @@ -136,7 +148,7 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi { ): Promise { const interval = this.intervals[resolution] - let pair1 = symbolInfo.full_name + let pair1 = this.getPairName(symbolInfo.full_name) let pair2: string = '' let pair3: string = '' @@ -198,13 +210,29 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi { await Promise.all([pair1Bars, pair2Bars, pair3Bars]).then( ([pair1Bars, pair2Bars, pair3Bars]) => { let bars = pair1Bars + + if (!bars.length) { + onResult([], { noData: true }) + return + } + if (pair2Bars) { bars = this.combineBars(pair1Bars, pair2Bars) } if (pair3Bars) { bars = this.combineBars(bars, pair3Bars) } - onResult(bars) + + const filler = Array.from({ length: this.batchSize - bars.length }).map((_, index) => ({ + time: (bars[0]?.time || new Date().getTime()) - index * this.minutesPerInterval[resolution], + close: 0, + open: 0, + high: 0, + low: 0, + volume: 0, + })) + + onResult([...filler, ...bars]) }, ) } @@ -282,6 +310,16 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi { return bars } + getPairName(name: string) { + if (name.includes(PAIR_SEPARATOR)) return name + + const [symbol1, symbol2] = name.split('/') + + const asset1 = ASSETS.find((asset) => asset.symbol === symbol1) + const asset2 = ASSETS.find((asset) => asset.symbol === symbol2) + return `${asset1?.denom}${PAIR_SEPARATOR}${asset2?.denom}` + } + searchSymbols(): void { // Don't allow to search for symbols } diff --git a/src/components/Trade/TradeChart/constants.ts b/src/components/Trade/TradeChart/constants.ts index 279ed7f9..79632248 100644 --- a/src/components/Trade/TradeChart/constants.ts +++ b/src/components/Trade/TradeChart/constants.ts @@ -1,5 +1,6 @@ import { ChartingLibraryFeatureset, + LibrarySymbolInfo, ResolutionString, SeriesFormat, Timezone, @@ -26,7 +27,7 @@ export const overrides = { 'linetooltrendline.linewidth': 2, } -export const defaultSymbolInfo = { +export const defaultSymbolInfo: Partial = { listed_exchange: 'Osmosis', type: 'AMM', session: '24x7', @@ -35,7 +36,7 @@ export const defaultSymbolInfo = { timezone: 'Etc/UTC' as Timezone, has_intraday: true, has_daily: true, - has_weekly_and_monthly: true, + has_weekly_and_monthly: false, format: 'price' as SeriesFormat, supported_resolutions: ['15'] as ResolutionString[], } From db1048bf4c5713480e055ca2895415fb8209f02b Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Wed, 11 Oct 2023 12:56:13 +0200 Subject: [PATCH 4/8] various fixes (#535) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: fixed autoConnect * tidy: Credit Account * fix: fallback timer * fix: clearTimer * fix: fixed v1 links * fix: changed the farm columns * fix: updated doc urls according to Dino (#531) * fix: updated doc urls according to Dino * fix: updated the v1 url * Build(deps-dev): bump @types/react from 18.2.23 to 18.2.27 (#530) Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.2.23 to 18.2.27. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react) --- updated-dependencies: - dependency-name: "@types/react" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * šŸ›stAtom chart data (#533) * env: update * env: tidy * fix: fixed v1 links * fix: no need for camelcase in keywords --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bob van der Helm <34470358+bobthebuidlr@users.noreply.github.com> --- package.json | 18 +- .../Account/AccountDetails/index.tsx | 2 +- src/components/Earn/Farm/VaultTable.tsx | 8 - .../Earn/Lend/LendingActionButtons.tsx | 2 +- src/components/MobileNotSupported.tsx | 3 +- .../Modals/Account/AccountDeleteModal.tsx | 4 +- .../FundWithdraw/WithdrawFromAccount.tsx | 2 +- src/components/Modals/Settings/index.tsx | 4 +- src/components/Portfolio/Account/Summary.tsx | 6 +- src/components/Portfolio/Card/Skeleton.tsx | 2 +- src/components/Portfolio/Overview/index.tsx | 2 +- src/components/TokenInput/index.tsx | 2 +- .../TradeModule/AssetSelector/AssetList.tsx | 2 +- src/components/Wallet/WalletConnecting.tsx | 44 ++- src/components/Wallet/WalletSelect.tsx | 2 +- src/components/Wallet/index.tsx | 14 +- src/constants/chains.ts | 4 +- yarn.lock | 277 ++++++++++-------- 18 files changed, 226 insertions(+), 172 deletions(-) diff --git a/package.json b/package.json index 21a7df24..37d6a079 100644 --- a/package.json +++ b/package.json @@ -17,11 +17,11 @@ "dependencies": { "@cosmjs/cosmwasm-stargate": "^0.31.1", "@delphi-labs/shuttle-react": "^3.9.0", - "@keplr-wallet/cosmos": "^0.12.28", + "@keplr-wallet/cosmos": "^0.12.32", "@sentry/nextjs": "^7.73.0", "@splinetool/react-spline": "^2.2.6", - "@splinetool/runtime": "^0.9.473", - "@tanstack/react-table": "^8.10.3", + "@splinetool/runtime": "^0.9.477", + "@tanstack/react-table": "^8.10.6", "@tippyjs/react": "^4.2.6", "bignumber.js": "^9.1.2", "classnames": "^2.3.2", @@ -29,7 +29,7 @@ "lodash.debounce": "^4.0.8", "lodash.throttle": "^4.1.1", "moment": "^2.29.4", - "next": "13.5.3", + "next": "^13.5.4", "react": "^18.2.0", "react-device-detect": "^2.2.3", "react-dom": "^18.2.0", @@ -43,7 +43,7 @@ "recharts": "^2.8.0", "swr": "^2.2.4", "tailwind-scrollbar-hide": "^1.1.7", - "zustand": "^4.4.1" + "zustand": "^4.4.3" }, "devDependencies": { "@svgr/webpack": "^8.1.0", @@ -53,15 +53,15 @@ "@types/lodash.debounce": "^4.0.7", "@types/lodash.throttle": "^4.1.7", "@types/node": "^20.7.0", - "@types/react": "18.2.27", - "@types/react-dom": "18.2.11", + "@types/react": "18.2.28", + "@types/react-dom": "18.2.13", "@types/react-helmet": "^6.1.7", "autoprefixer": "^10.4.16", "babel-jest": "^29.7.0", "dotenv": "^16.3.1", "dotenv-cli": "^7.3.0", - "eslint": "8.51.0", - "eslint-config-next": "^13.5.3", + "eslint": "^8.51.0", + "eslint-config-next": "^13.5.4", "eslint-plugin-import": "^2.28.1", "identity-obj-proxy": "^3.0.0", "jest": "^29.7.0", diff --git a/src/components/Account/AccountDetails/index.tsx b/src/components/Account/AccountDetails/index.tsx index eae039b9..ee24f77a 100644 --- a/src/components/Account/AccountDetails/index.tsx +++ b/src/components/Account/AccountDetails/index.tsx @@ -87,7 +87,7 @@ function AccountDetails(props: Props) { const apr = useMemo( () => calculateAccountApr(updatedAccount ?? account, borrowAssetsData, lendingAssetsData, prices), - [account, borrowAssetsData, lendingAssetsData, prices], + [account, borrowAssetsData, lendingAssetsData, prices, updatedAccount], ) function AccountDetailsHeader() { diff --git a/src/components/Earn/Farm/VaultTable.tsx b/src/components/Earn/Farm/VaultTable.tsx index e4abca05..59957bb1 100644 --- a/src/components/Earn/Farm/VaultTable.tsx +++ b/src/components/Earn/Farm/VaultTable.tsx @@ -188,14 +188,6 @@ export const VaultTable = (props: Props) => { return {formatPercent(row.original.ltv.max)} }, }, - { - accessorKey: 'ltv.liq', - header: 'Liq. LTV', - cell: ({ row }) => { - if (props.isLoading) return - return {formatPercent(row.original.ltv.liq)} - }, - }, { accessorKey: 'details', enableSorting: false, diff --git a/src/components/Earn/Lend/LendingActionButtons.tsx b/src/components/Earn/Lend/LendingActionButtons.tsx index 56988b0e..36761f36 100644 --- a/src/components/Earn/Lend/LendingActionButtons.tsx +++ b/src/components/Earn/Lend/LendingActionButtons.tsx @@ -75,7 +75,7 @@ export default function LendingActionButtons(props: Props) { {`You donā€™t have any ${asset.symbol}. Please first deposit ${asset.symbol} into your credit account before lending.`} + {`You donā€™t have any ${asset.symbol}. Please first deposit ${asset.symbol} into your Credit Account before lending.`} } > {children} diff --git a/src/components/MobileNotSupported.tsx b/src/components/MobileNotSupported.tsx index 5e544cd7..4f242aed 100644 --- a/src/components/MobileNotSupported.tsx +++ b/src/components/MobileNotSupported.tsx @@ -2,6 +2,7 @@ import Spline from '@splinetool/react-spline' import Button from 'components/Button' import Text from 'components/Text' +import { DocURL } from 'types/enums/docURL' export default function MobileNotSupported() { return ( @@ -23,7 +24,7 @@ export default function MobileNotSupported() { text='Visit Mars v1' color='tertiary' size='lg' - onClick={() => window.open('https://app.marsprotocol.io', '_self')} + onClick={() => window.open(DocURL.V1_URL, '_self')} /> diff --git a/src/components/Modals/Account/AccountDeleteModal.tsx b/src/components/Modals/Account/AccountDeleteModal.tsx index 080aa7a9..a436963d 100644 --- a/src/components/Modals/Account/AccountDeleteModal.tsx +++ b/src/components/Modals/Account/AccountDeleteModal.tsx @@ -85,7 +85,7 @@ function AccountDeleteModal(props: Props) { return ( - The following assets within your credit account will be sent to your wallet. + The following assets within your Credit Account will be sent to your wallet.
{depositsAndLends.map((position, index) => { diff --git a/src/components/Modals/FundWithdraw/WithdrawFromAccount.tsx b/src/components/Modals/FundWithdraw/WithdrawFromAccount.tsx index 979e9cbe..0d319aba 100644 --- a/src/components/Modals/FundWithdraw/WithdrawFromAccount.tsx +++ b/src/components/Modals/FundWithdraw/WithdrawFromAccount.tsx @@ -118,7 +118,7 @@ export default function WithdrawFromAccount(props: Props) {
Withdraw with borrowing - Borrow assets from your credit account to withdraw to your wallet + Borrow assets from your Credit Account to withdraw to your wallet
diff --git a/src/components/Modals/Settings/index.tsx b/src/components/Modals/Settings/index.tsx index 0907e825..7b984164 100644 --- a/src/components/Modals/Settings/index.tsx +++ b/src/components/Modals/Settings/index.tsx @@ -231,8 +231,8 @@ export default function SettingsModal() { onChange={handleLendAssets} name='lendAssets' value={lendAssets} - label='Lend assets in credit accounts' - description='By turning this on you will automatically lend out all the assets you deposit into your credit accounts to earn yield.' + label='Lend assets in Credit Accounts' + description='By turning this on you will automatically lend out all the assets you deposit into your Credit Accounts to earn yield.' withStatus /> + return } export default function Summary(props: Props) { return ( - }> + }> ) diff --git a/src/components/Portfolio/Card/Skeleton.tsx b/src/components/Portfolio/Card/Skeleton.tsx index 07b2eab2..b5816805 100644 --- a/src/components/Portfolio/Card/Skeleton.tsx +++ b/src/components/Portfolio/Card/Skeleton.tsx @@ -17,7 +17,7 @@ export default function Skeleton(props: Props) { return (
- Credit account {props.accountId} + Credit Account {props.accountId} {props.isCurrent && '(current)'} diff --git a/src/components/Portfolio/Overview/index.tsx b/src/components/Portfolio/Overview/index.tsx index ec870b08..eb347411 100644 --- a/src/components/Portfolio/Overview/index.tsx +++ b/src/components/Portfolio/Overview/index.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames' -import React, { useCallback } from 'react' +import { useCallback } from 'react' import { useParams } from 'react-router-dom' import AccountCreateFirst from 'components/Account/AccountCreateFirst' diff --git a/src/components/TokenInput/index.tsx b/src/components/TokenInput/index.tsx index 4194b8b5..9846d865 100644 --- a/src/components/TokenInput/index.tsx +++ b/src/components/TokenInput/index.tsx @@ -90,7 +90,7 @@ export default function TokenInput(props: Props) { {props.warning && (
diff --git a/src/components/Trade/TradeModule/AssetSelector/AssetList.tsx b/src/components/Trade/TradeModule/AssetSelector/AssetList.tsx index c89f544a..36d0661c 100644 --- a/src/components/Trade/TradeModule/AssetSelector/AssetList.tsx +++ b/src/components/Trade/TradeModule/AssetSelector/AssetList.tsx @@ -1,11 +1,11 @@ import classNames from 'classnames' +import { useMemo } from 'react' import { ChevronDown } from 'components/Icons' import Text from 'components/Text' import AssetItem from 'components/Trade/TradeModule/AssetSelector/AssetItem' import useCurrentAccount from 'hooks/useCurrentAccount' import useMarketAssets from 'hooks/useMarketAssets' -import { useMemo } from 'react' import { getMergedBalancesForAsset } from 'utils/accounts' import { byDenom } from 'utils/array' import { getEnabledMarketAssets } from 'utils/assets' diff --git a/src/components/Wallet/WalletConnecting.tsx b/src/components/Wallet/WalletConnecting.tsx index e37a163f..5cb7ef99 100644 --- a/src/components/Wallet/WalletConnecting.tsx +++ b/src/components/Wallet/WalletConnecting.tsx @@ -1,6 +1,10 @@ import { CosmWasmClient } from '@cosmjs/cosmwasm-stargate' -import { useShuttle } from '@delphi-labs/shuttle-react' -import { useCallback, useEffect, useMemo } from 'react' +import { + useShuttle, + WalletExtensionProvider, + WalletMobileProvider, +} from '@delphi-labs/shuttle-react' +import { useCallback, useEffect, useMemo, useRef } from 'react' import { CircularProgress } from 'components/CircularProgress' import FullOverlayContent from 'components/FullOverlayContent' @@ -38,15 +42,21 @@ export default function WalletConnecting(props: Props) { ) const [isConnecting, setIsConnecting] = useToggle() const providerId = props.providerId ?? recentWallet?.providerId + const refTimer = useRef(null) const isAutoConnect = props.autoConnect const client = useStore((s) => s.client) const address = useStore((s) => s.address) + const clearTimer = useCallback(() => { + if (refTimer.current !== null) window.clearTimeout(refTimer.current) + }, [refTimer]) + const handleConnect = useCallback( (extensionProviderId: string) => { async function handleConnectAsync() { if (client || isConnecting) return setIsConnecting(true) + clearTimer() try { const response = await connect({ extensionProviderId, chainId: currentChainId }) const cosmClient = await CosmWasmClient.connect(response.network.rpc) @@ -70,7 +80,6 @@ export default function WalletConnecting(props: Props) { }) } catch (error) { setIsConnecting(false) - if (isAutoConnect) return if (error instanceof Error) { useStore.setState({ client: undefined, @@ -92,7 +101,15 @@ export default function WalletConnecting(props: Props) { } if (!isConnecting) handleConnectAsync() }, - [broadcast, connect, client, isAutoConnect, isConnecting, setIsConnecting, sign, simulate], + [broadcast, connect, client, isConnecting, setIsConnecting, sign, simulate, clearTimer], + ) + + const startTimer = useCallback( + (provider?: WalletMobileProvider | WalletExtensionProvider) => { + if (refTimer.current !== null || !window) return + refTimer.current = window.setTimeout(() => handleConnect(provider?.id ?? ''), 5000) + }, + [refTimer, handleConnect], ) useEffect(() => { @@ -102,10 +119,25 @@ export default function WalletConnecting(props: Props) { !provider.initialized || isConnecting || (recentWallet && recentWallet.account.address === address) - ) + ) { + if (isAutoConnect) startTimer(provider) return + } + handleConnect(provider.id) - }, [handleConnect, isConnecting, providerId, providers, recentWallet, address]) + + return () => clearTimer() + }, [ + handleConnect, + isConnecting, + providerId, + providers, + recentWallet, + address, + isAutoConnect, + startTimer, + clearTimer, + ]) return (
diff --git a/src/components/Wallet/index.tsx b/src/components/Wallet/index.tsx index d27a1506..76b8c79d 100644 --- a/src/components/Wallet/index.tsx +++ b/src/components/Wallet/index.tsx @@ -1,3 +1,4 @@ +import { useShuttle } from '@delphi-labs/shuttle-react' import { useEffect } from 'react' import WalletConnectButton from 'components/Wallet/WalletConnectButton' @@ -7,6 +8,7 @@ import useCurrentWallet from 'hooks/useCurrentWallet' import useStore from 'store' export default function Wallet() { + const { disconnectWallet } = useShuttle() const currentWallet = useCurrentWallet() const address = useStore((s) => s.address) const focusComponent = useStore((s) => s.focusComponent) @@ -19,9 +21,19 @@ export default function Wallet() { client: undefined, focusComponent: { component: , + onClose: () => { + disconnectWallet(currentWallet) + useStore.setState({ + client: undefined, + address: undefined, + accounts: null, + balances: [], + focusComponent: null, + }) + }, }, }) - }, [currentWallet, address, focusComponent]) + }, [currentWallet, address, focusComponent, disconnectWallet]) return address ? : } diff --git a/src/constants/chains.ts b/src/constants/chains.ts index cca4efd0..fa84e8c4 100644 --- a/src/constants/chains.ts +++ b/src/constants/chains.ts @@ -4,8 +4,8 @@ import { ChainInfoID } from 'types/enums/wallet' export const CHAINS: ChainInfos = { [ChainInfoID.Osmosis1]: { - rpc: 'https://rpc-osmosis.blockapsis.com', - rest: 'https://lcd-osmosis.blockapsis.com', + rpc: 'https://rpc.osmosis.zone', + rest: 'https://lcd.osmosis.zone', explorer: 'https://www.mintscan.io/osmosis', explorerName: 'Mintscan', chainId: ChainInfoID.Osmosis1, diff --git a/yarn.lock b/yarn.lock index 38d0666b..1944f383 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2470,38 +2470,38 @@ "@jridgewell/resolve-uri" "3.1.0" "@jridgewell/sourcemap-codec" "1.4.14" -"@keplr-wallet/common@0.12.28": - version "0.12.28" - resolved "https://registry.yarnpkg.com/@keplr-wallet/common/-/common-0.12.28.tgz#1d5d985070aced31a34a6426c9ac4b775081acca" - integrity sha512-ESQorPZw8PRiUXhsrxED+E1FEWkAdc6Kwi3Az7ce204gMBQDI2j0XJtTd4uCUp+C24Em9fk0samdHzdoB4caIg== +"@keplr-wallet/common@0.12.32": + version "0.12.32" + resolved "https://registry.yarnpkg.com/@keplr-wallet/common/-/common-0.12.32.tgz#3dab2ddf58943fb457e9ded76262ea4c5c262201" + integrity sha512-GWMsuk4Sam/QXwNHbJ8sOTB1piRHMZMkMaZEdIVbWUDFn0Dun6gRD4hrDSAUohgPCcJ5Vk350eCf6P2q1KhWbQ== dependencies: - "@keplr-wallet/crypto" "0.12.28" - "@keplr-wallet/types" "0.12.28" + "@keplr-wallet/crypto" "0.12.32" + "@keplr-wallet/types" "0.12.32" buffer "^6.0.3" delay "^4.4.0" mobx "^6.1.7" -"@keplr-wallet/cosmos@^0.12.28": - version "0.12.28" - resolved "https://registry.yarnpkg.com/@keplr-wallet/cosmos/-/cosmos-0.12.28.tgz#d56e73468256e7276a66bb41f145449dbf11efa1" - integrity sha512-IuqmSBgKgIeWBA0XGQKKs28IXFeFMCrfadCbtiZccNc7qnNr5Y/Cyyk01BPC8Dd1ZyEyAByoICgrxvtGN0GGvA== +"@keplr-wallet/cosmos@^0.12.32": + version "0.12.32" + resolved "https://registry.yarnpkg.com/@keplr-wallet/cosmos/-/cosmos-0.12.32.tgz#2a3f5765ede059d87dbda7b20de69c9bb0312a13" + integrity sha512-gB90blTgvMhRi7yGk0onGd1Q+g3KmyQYakARjieT7zG3nhNe2eB+xMcGlPlmzCsbEb/7Olkx55s9DfnbMHJMDA== dependencies: "@ethersproject/address" "^5.6.0" - "@keplr-wallet/common" "0.12.28" - "@keplr-wallet/crypto" "0.12.28" - "@keplr-wallet/proto-types" "0.12.28" - "@keplr-wallet/simple-fetch" "0.12.28" - "@keplr-wallet/types" "0.12.28" - "@keplr-wallet/unit" "0.12.28" + "@keplr-wallet/common" "0.12.32" + "@keplr-wallet/crypto" "0.12.32" + "@keplr-wallet/proto-types" "0.12.32" + "@keplr-wallet/simple-fetch" "0.12.32" + "@keplr-wallet/types" "0.12.32" + "@keplr-wallet/unit" "0.12.32" bech32 "^1.1.4" buffer "^6.0.3" long "^4.0.0" protobufjs "^6.11.2" -"@keplr-wallet/crypto@0.12.28": - version "0.12.28" - resolved "https://registry.yarnpkg.com/@keplr-wallet/crypto/-/crypto-0.12.28.tgz#28410ba1f707fa5a1506f111f6fd8baf071c394d" - integrity sha512-le1je+78/4213qshSMgQTYqhCCvzsL9+YfhjXg1kd/ali69MLWK8L8Z09ducHPS6C+LqQXXTNJQpbH2uiFSd5w== +"@keplr-wallet/crypto@0.12.32": + version "0.12.32" + resolved "https://registry.yarnpkg.com/@keplr-wallet/crypto/-/crypto-0.12.32.tgz#a8c12ae48372ac73c84dd4fcba91b5e0e651342c" + integrity sha512-BpsznV8qiStvoq/KAQEC/NDAVP6qL/gblNB7aF0m9DaFYHC42tj4CPK65DejCeMOZB217ACRXHKZRhrwg913gQ== dependencies: "@ethersproject/keccak256" "^5.5.0" bip32 "^2.0.6" @@ -2512,32 +2512,32 @@ elliptic "^6.5.3" sha.js "^2.4.11" -"@keplr-wallet/proto-types@0.12.28": - version "0.12.28" - resolved "https://registry.yarnpkg.com/@keplr-wallet/proto-types/-/proto-types-0.12.28.tgz#2fb2c37749ce7db974f01d07387e966c9b99027d" - integrity sha512-ukti/eCTltPUP64jxtk5TjtwJogyfKPqlBIT3KGUCGzBLIPeYMsffL5w5aoHsMjINzOITjYqzXyEF8LTIK/fmw== +"@keplr-wallet/proto-types@0.12.32": + version "0.12.32" + resolved "https://registry.yarnpkg.com/@keplr-wallet/proto-types/-/proto-types-0.12.32.tgz#313517d0dd7b3561d52c75315a95d1e6db438a0c" + integrity sha512-wlB6L2/+rn+yr4I6ow91HtUGPn6gh1uosvhcwI/66vB9g+OtCRg0dFz+ZkL5/ZPpzWLFSDfPt50aAxXW3oN3Pg== dependencies: long "^4.0.0" protobufjs "^6.11.2" -"@keplr-wallet/simple-fetch@0.12.28": - version "0.12.28" - resolved "https://registry.yarnpkg.com/@keplr-wallet/simple-fetch/-/simple-fetch-0.12.28.tgz#44225df5b329c823076280df1ec9930a21b1373e" - integrity sha512-T2CiKS2B5n0ZA7CWw0CA6qIAH0XYI1siE50MP+i+V0ZniCGBeL+BMcDw64vFJUcEH+1L5X4sDAzV37fQxGwllA== +"@keplr-wallet/simple-fetch@0.12.32": + version "0.12.32" + resolved "https://registry.yarnpkg.com/@keplr-wallet/simple-fetch/-/simple-fetch-0.12.32.tgz#641418bb38875642b11cc45033f57a3e937b3414" + integrity sha512-bSCb4oho4VKrCkQOHBrkrMji/jvU+CQ7Lugw4bAzyn5EvPPR7Yx1GZ295r/KQwphUdOHhzfTovE8GeyTIvKI0Q== -"@keplr-wallet/types@0.12.28": - version "0.12.28" - resolved "https://registry.yarnpkg.com/@keplr-wallet/types/-/types-0.12.28.tgz#eac3c2c9d4560856c5c403a87e67925992a04fbf" - integrity sha512-EcM9d46hYDm3AO4lf4GUbTSLRySONtTmhKb7p88q56OQOgJN3MMjRacEo2p9jX9gpPe7gRIjMUalhAfUiFpZoQ== +"@keplr-wallet/types@0.12.32": + version "0.12.32" + resolved "https://registry.yarnpkg.com/@keplr-wallet/types/-/types-0.12.32.tgz#6141500f7387cde0512d4f87cab3686ee9f67db3" + integrity sha512-uxTz2Tidmob12dy0Hp+posGkm9WFW5sFSpVenIX6geRIfJwgpApDWZ1oD4NtRPy8s5aa51DirJceSuIYz+fx1g== dependencies: long "^4.0.0" -"@keplr-wallet/unit@0.12.28": - version "0.12.28" - resolved "https://registry.yarnpkg.com/@keplr-wallet/unit/-/unit-0.12.28.tgz#907c7fa0b49a729cda207fca14fc0a38871cc6c4" - integrity sha512-kpXigHDBJGOmhtPkv9hqsQid9zkFo7OQPeKgO2n8GUlOINIXW6kWG5LXYTi/Yg9Uiw1CQF69gFMuZCJ8IzVHlA== +"@keplr-wallet/unit@0.12.32": + version "0.12.32" + resolved "https://registry.yarnpkg.com/@keplr-wallet/unit/-/unit-0.12.32.tgz#b5d16599f0fb944ba82558a546f7ce706877b0b3" + integrity sha512-ipaUV0RtUjn3W9ULIhndXwq0tz7mWwGSg1iTZgNbBSBT/5Q14ZjS+U6wvZY5oFg1pmHyQSXzEhlRQFtfzA35Gg== dependencies: - "@keplr-wallet/types" "0.12.28" + "@keplr-wallet/types" "0.12.32" big-integer "^1.6.48" utility-types "^3.10.0" @@ -2564,62 +2564,62 @@ tweetnacl "^1.0.3" tweetnacl-util "^0.15.1" -"@next/env@13.5.3": - version "13.5.3" - resolved "https://registry.yarnpkg.com/@next/env/-/env-13.5.3.tgz#402da9a0af87f93d853519f0c2a602b1ab637c2c" - integrity sha512-X4te86vsbjsB7iO4usY9jLPtZ827Mbx+WcwNBGUOIuswuTAKQtzsuoxc/6KLxCMvogKG795MhrR1LDhYgDvasg== +"@next/env@13.5.4": + version "13.5.4" + resolved "https://registry.yarnpkg.com/@next/env/-/env-13.5.4.tgz#777c3af16de2cf2f611b6c8126910062d13d222c" + integrity sha512-LGegJkMvRNw90WWphGJ3RMHMVplYcOfRWf2Be3td3sUa+1AaxmsYyANsA+znrGCBjXJNi4XAQlSoEfUxs/4kIQ== -"@next/eslint-plugin-next@13.5.3": - version "13.5.3" - resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-13.5.3.tgz#585fca48fb5f969825ad57f05c0a627fd4662dda" - integrity sha512-lbZOoEjzSuTtpk9UgV9rOmxYw+PsSfNR+00mZcInqooiDMZ1u+RqT1YQYLsEZPW1kumZoQe5+exkCBtZ2xn0uw== +"@next/eslint-plugin-next@13.5.4": + version "13.5.4" + resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-13.5.4.tgz#ec70af509f07dc4e545df25834ac94d2c341c36a" + integrity sha512-vI94U+D7RNgX6XypSyjeFrOzxGlZyxOplU0dVE5norIfZGn/LDjJYPHdvdsR5vN1eRtl6PDAsOHmycFEOljK5A== dependencies: glob "7.1.7" -"@next/swc-darwin-arm64@13.5.3": - version "13.5.3" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.5.3.tgz#f72eac8c7b71d33e0768bd3c8baf68b00fea0160" - integrity sha512-6hiYNJxJmyYvvKGrVThzo4nTcqvqUTA/JvKim7Auaj33NexDqSNwN5YrrQu+QhZJCIpv2tULSHt+lf+rUflLSw== +"@next/swc-darwin-arm64@13.5.4": + version "13.5.4" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.5.4.tgz#241957774fef3f876dc714cfc0ca6f00f561737e" + integrity sha512-Df8SHuXgF1p+aonBMcDPEsaahNo2TCwuie7VXED4FVyECvdXfRT9unapm54NssV9tF3OQFKBFOdlje4T43VO0w== -"@next/swc-darwin-x64@13.5.3": - version "13.5.3" - resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.5.3.tgz#96eda3a1247a713579eb241d76d3f503291c8938" - integrity sha512-UpBKxu2ob9scbpJyEq/xPgpdrgBgN3aLYlxyGqlYX5/KnwpJpFuIHU2lx8upQQ7L+MEmz+fA1XSgesoK92ppwQ== +"@next/swc-darwin-x64@13.5.4": + version "13.5.4" + resolved "https://registry.yarnpkg.com/@next/swc-darwin-x64/-/swc-darwin-x64-13.5.4.tgz#fa11bb97bf06cd45cbd554354b46bf93e22c025b" + integrity sha512-siPuUwO45PnNRMeZnSa8n/Lye5ZX93IJom9wQRB5DEOdFrw0JjOMu1GINB8jAEdwa7Vdyn1oJ2xGNaQpdQQ9Pw== -"@next/swc-linux-arm64-gnu@13.5.3": - version "13.5.3" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.5.3.tgz#132e155a029310fffcdfd3e3c4255f7ce9fd2714" - integrity sha512-5AzM7Yx1Ky+oLY6pHs7tjONTF22JirDPd5Jw/3/NazJ73uGB05NqhGhB4SbeCchg7SlVYVBeRMrMSZwJwq/xoA== +"@next/swc-linux-arm64-gnu@13.5.4": + version "13.5.4" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-13.5.4.tgz#dd3a482cd6871ed23b049066a0f3c4c2f955dc88" + integrity sha512-l/k/fvRP/zmB2jkFMfefmFkyZbDkYW0mRM/LB+tH5u9pB98WsHXC0WvDHlGCYp3CH/jlkJPL7gN8nkTQVrQ/2w== -"@next/swc-linux-arm64-musl@13.5.3": - version "13.5.3" - resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.5.3.tgz#981d7d8fdcf040bd0c89588ef4139c28805f5cf1" - integrity sha512-A/C1shbyUhj7wRtokmn73eBksjTM7fFQoY2v/0rTM5wehpkjQRLOXI8WJsag2uLhnZ4ii5OzR1rFPwoD9cvOgA== +"@next/swc-linux-arm64-musl@13.5.4": + version "13.5.4" + resolved "https://registry.yarnpkg.com/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-13.5.4.tgz#ed6d7abaf5712cff2752ce5300d6bacc6aff1b18" + integrity sha512-YYGb7SlLkI+XqfQa8VPErljb7k9nUnhhRrVaOdfJNCaQnHBcvbT7cx/UjDQLdleJcfyg1Hkn5YSSIeVfjgmkTg== -"@next/swc-linux-x64-gnu@13.5.3": - version "13.5.3" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.5.3.tgz#b8263663acda7b84bc2c4ffa39ca4b0172a78060" - integrity sha512-FubPuw/Boz8tKkk+5eOuDHOpk36F80rbgxlx4+xty/U71e3wZZxVYHfZXmf0IRToBn1Crb8WvLM9OYj/Ur815g== +"@next/swc-linux-x64-gnu@13.5.4": + version "13.5.4" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-13.5.4.tgz#977a040388e8a685a3a85e0dbdff90a4ee2a7189" + integrity sha512-uE61vyUSClnCH18YHjA8tE1prr/PBFlBFhxBZis4XBRJoR+txAky5d7gGNUIbQ8sZZ7LVkSVgm/5Fc7mwXmRAg== -"@next/swc-linux-x64-musl@13.5.3": - version "13.5.3" - resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.5.3.tgz#cd0bed8ee92032c25090bed9d95602ac698d925f" - integrity sha512-DPw8nFuM1uEpbX47tM3wiXIR0Qa+atSzs9Q3peY1urkhofx44o7E1svnq+a5Q0r8lAcssLrwiM+OyJJgV/oj7g== +"@next/swc-linux-x64-musl@13.5.4": + version "13.5.4" + resolved "https://registry.yarnpkg.com/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.5.4.tgz#3e29a0ad8efc016196c3a120da04397eea328b2a" + integrity sha512-qVEKFYML/GvJSy9CfYqAdUexA6M5AklYcQCW+8JECmkQHGoPxCf04iMh7CPR7wkHyWWK+XLt4Ja7hhsPJtSnhg== -"@next/swc-win32-arm64-msvc@13.5.3": - version "13.5.3" - resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.5.3.tgz#7f556674ca97e6936220d10c58252cc36522d80a" - integrity sha512-zBPSP8cHL51Gub/YV8UUePW7AVGukp2D8JU93IHbVDu2qmhFAn9LWXiOOLKplZQKxnIPUkJTQAJDCWBWU4UWUA== +"@next/swc-win32-arm64-msvc@13.5.4": + version "13.5.4" + resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.5.4.tgz#18a236c3fe5a48d24b56d939e6a05488bb682b7e" + integrity sha512-mDSQfqxAlfpeZOLPxLymZkX0hYF3juN57W6vFHTvwKlnHfmh12Pt7hPIRLYIShk8uYRsKPtMTth/EzpwRI+u8w== -"@next/swc-win32-ia32-msvc@13.5.3": - version "13.5.3" - resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.5.3.tgz#4912721fb8695f11daec4cde42e73dc57bcc479f" - integrity sha512-ONcL/lYyGUj4W37D4I2I450SZtSenmFAvapkJQNIJhrPMhzDU/AdfLkW98NvH1D2+7FXwe7yclf3+B7v28uzBQ== +"@next/swc-win32-ia32-msvc@13.5.4": + version "13.5.4" + resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.5.4.tgz#255132243ab6fb20d3c7c92a585e2c4fa50368fe" + integrity sha512-aoqAT2XIekIWoriwzOmGFAvTtVY5O7JjV21giozBTP5c6uZhpvTWRbmHXbmsjZqY4HnEZQRXWkSAppsIBweKqw== -"@next/swc-win32-x64-msvc@13.5.3": - version "13.5.3" - resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.3.tgz#97340a709febb60ff73003566b99d127d4e5b881" - integrity sha512-2Vz2tYWaLqJvLcWbbTlJ5k9AN6JD7a5CN2pAeIzpbecK8ZF/yobA39cXtv6e+Z8c5UJuVOmaTldEAIxvsIux/Q== +"@next/swc-win32-x64-msvc@13.5.4": + version "13.5.4" + resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.5.4.tgz#cc542907b55247c5634d9a8298e1c143a1847e25" + integrity sha512-cyRvlAxwlddlqeB9xtPSfNSCRy8BOa4wtMo0IuI9P7Y0XT2qpDrpFKRyZ7kUngZis59mPVla5k8X1oOJ8RxDYg== "@noble/curves@1.1.0", "@noble/curves@~1.1.0": version "1.1.0" @@ -3026,10 +3026,10 @@ lodash.debounce "^4.0.8" react-merge-refs "^2.0.1" -"@splinetool/runtime@^0.9.473": - version "0.9.473" - resolved "https://registry.yarnpkg.com/@splinetool/runtime/-/runtime-0.9.473.tgz#923f76f5c7490b42ad1e605784b8ead69dd3bd39" - integrity sha512-6XXp+rI6YHijQyh+gNQPx3HivBO/1Q63AAzaHJr6AteguJsEieIJZI/7bzAoa/NwtPXXnm/+M5brtJ9NtPPlyg== +"@splinetool/runtime@^0.9.477": + version "0.9.477" + resolved "https://registry.yarnpkg.com/@splinetool/runtime/-/runtime-0.9.477.tgz#62ce32197cb4671bc522638addf94baf539eddec" + integrity sha512-zb2+zh1uPH4h3EbVYJmoiC9iuD1FmQJGCzifPQICpQ9VSKVk/4wDLgaoCTXqME/kbx5XERkGh+kmOAGTBkOsxQ== dependencies: on-change "^4.0.0" semver-compare "^1.0.0" @@ -3281,17 +3281,17 @@ dependencies: tslib "^2.4.0" -"@tanstack/react-table@^8.10.3": - version "8.10.3" - resolved "https://registry.yarnpkg.com/@tanstack/react-table/-/react-table-8.10.3.tgz#d109be13ffca4085336e92b4a856bddc1ddfebd8" - integrity sha512-Qya1cJ+91arAlW7IRDWksRDnYw28O446jJ/ljkRSc663EaftJoBCAU10M+VV1K6MpCBLrXq1BD5IQc1zj/ZEjA== +"@tanstack/react-table@^8.10.6": + version "8.10.6" + resolved "https://registry.yarnpkg.com/@tanstack/react-table/-/react-table-8.10.6.tgz#a8c03cc06ac890bce4404739b9356059c4259dd4" + integrity sha512-D0VEfkIYnIKdy6SHiBNEaMc4SxO+MV7ojaPhRu8jP933/gbMi367+Wul2LxkdovJ5cq6awm0L1+jgxdS/unzIg== dependencies: - "@tanstack/table-core" "8.10.3" + "@tanstack/table-core" "8.10.6" -"@tanstack/table-core@8.10.3": - version "8.10.3" - resolved "https://registry.yarnpkg.com/@tanstack/table-core/-/table-core-8.10.3.tgz#7f7a0753645e05bb15c97512785abbae7b626ee3" - integrity sha512-hJ55YfJlWbfzRROfcyA/kC1aZr/shsLA8XNAwN8jXylhYWGLnPmiJJISrUfj4dMMWRiFi0xBlnlC7MLH+zSrcw== +"@tanstack/table-core@8.10.6": + version "8.10.6" + resolved "https://registry.yarnpkg.com/@tanstack/table-core/-/table-core-8.10.6.tgz#c79d145dfc3dc9947a2b1cdac82cd4ec4cef822a" + integrity sha512-9t8brthhAmCBIjzk7fCDa/kPKoLQTtA31l9Ir76jYxciTlHU61r/6gYm69XF9cbg9n88gVL5y7rNpeJ2dc1AFA== "@terra-money/terra.proto@^3.0.5": version "3.0.5" @@ -3577,7 +3577,14 @@ resolved "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz" integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w== -"@types/react-dom@18.2.11", "@types/react-dom@^18.0.0": +"@types/react-dom@18.2.13": + version "18.2.13" + resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.13.tgz#89cd7f9ec8b28c8b6f0392b9591671fb4a9e96b7" + integrity sha512-eJIUv7rPP+EC45uNYp/ThhSpE16k22VJUknt5OLoH9tbXoi8bMhwLf5xRuWMywamNbWzhrSmU7IBJfPup1+3fw== + dependencies: + "@types/react" "*" + +"@types/react-dom@^18.0.0": version "18.2.11" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.11.tgz#4332c315544698a0875dfdb6e320dda59e1b3d58" integrity sha512-zq6Dy0EiCuF9pWFW6I6k6W2LdpUixLE4P6XjXU1QHLfak3GPACQfLwEuHzY5pOYa4hzj1d0GxX/P141aFjZsyg== @@ -3591,7 +3598,7 @@ dependencies: "@types/react" "*" -"@types/react@*", "@types/react@18.2.27": +"@types/react@*": version "18.2.27" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.27.tgz#746e52b06f3ccd5d7a724fd53769b70792601440" integrity sha512-Wfv7B7FZiR2r3MIqbAlXoY1+tXm4bOqfz4oRr+nyXdBqapDBZ0l/IGcSlAfvxIHEEJjkPU0MYAc/BlFPOcrgLw== @@ -3600,6 +3607,15 @@ "@types/scheduler" "*" csstype "^3.0.2" +"@types/react@18.2.28": + version "18.2.28" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.28.tgz#86877465c0fcf751659a36c769ecedfcfacee332" + integrity sha512-ad4aa/RaaJS3hyGz0BGegdnSRXQBkd1CCYDCdNjBPg90UUpLgo+WlJqb9fMYUxtehmzF3PJaTWqRZjko6BRzBg== + dependencies: + "@types/prop-types" "*" + "@types/scheduler" "*" + csstype "^3.0.2" + "@types/scheduler@*": version "0.16.2" resolved "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz" @@ -5554,12 +5570,12 @@ escodegen@^2.0.0: optionalDependencies: source-map "~0.6.1" -eslint-config-next@^13.5.3: - version "13.5.3" - resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-13.5.3.tgz#f1ff64e4a5b55ce52ef0ab0ea85de04fd581b956" - integrity sha512-VN2qbCpq2DMWgs7SVF8KTmc8bVaWz3s4nmcFqRLs7PNBt5AXejOhJuZ4zg2sCEHOvz5RvqdwLeI++NSCV6qHVg== +eslint-config-next@^13.5.4: + version "13.5.4" + resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-13.5.4.tgz#e50bb157d8346b63426f4b36bf53c2e46ccbc938" + integrity sha512-FzQGIj4UEszRX7fcRSJK6L1LrDiVZvDFW320VVntVKh3BSU8Fb9kpaoxQx0cdFgf3MQXdeSbrCXJ/5Z/NndDkQ== dependencies: - "@next/eslint-plugin-next" "13.5.3" + "@next/eslint-plugin-next" "13.5.4" "@rushstack/eslint-patch" "^1.3.3" "@typescript-eslint/parser" "^5.4.2 || ^6.0.0" eslint-import-resolver-node "^0.3.6" @@ -5683,7 +5699,7 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4 resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== -eslint@8.51.0: +eslint@^8.51.0: version "8.51.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.51.0.tgz#4a82dae60d209ac89a5cff1604fea978ba4950f3" integrity sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA== @@ -7748,7 +7764,7 @@ nan@^2.13.2, nan@^2.14.0: resolved "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz" integrity sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ== -nanoid@^3.3.4, nanoid@^3.3.6: +nanoid@^3.3.6: version "3.3.6" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c" integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA== @@ -7758,29 +7774,28 @@ natural-compare@^1.4.0: resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== -next@13.5.3: - version "13.5.3" - resolved "https://registry.yarnpkg.com/next/-/next-13.5.3.tgz#631efcbcc9d756c610855d9b94f3d8c4e73ee131" - integrity sha512-4Nt4HRLYDW/yRpJ/QR2t1v63UOMS55A38dnWv3UDOWGezuY0ZyFO1ABNbD7mulVzs9qVhgy2+ppjdsANpKP1mg== +next@^13.5.4: + version "13.5.4" + resolved "https://registry.yarnpkg.com/next/-/next-13.5.4.tgz#7e6a93c9c2b9a2c78bf6906a6c5cc73ae02d5b4d" + integrity sha512-+93un5S779gho8y9ASQhb/bTkQF17FNQOtXLKAj3lsNgltEcF0C5PMLLncDmH+8X1EnJH1kbqAERa29nRXqhjA== dependencies: - "@next/env" "13.5.3" + "@next/env" "13.5.4" "@swc/helpers" "0.5.2" busboy "1.6.0" caniuse-lite "^1.0.30001406" - postcss "8.4.14" + postcss "8.4.31" styled-jsx "5.1.1" watchpack "2.4.0" - zod "3.21.4" optionalDependencies: - "@next/swc-darwin-arm64" "13.5.3" - "@next/swc-darwin-x64" "13.5.3" - "@next/swc-linux-arm64-gnu" "13.5.3" - "@next/swc-linux-arm64-musl" "13.5.3" - "@next/swc-linux-x64-gnu" "13.5.3" - "@next/swc-linux-x64-musl" "13.5.3" - "@next/swc-win32-arm64-msvc" "13.5.3" - "@next/swc-win32-ia32-msvc" "13.5.3" - "@next/swc-win32-x64-msvc" "13.5.3" + "@next/swc-darwin-arm64" "13.5.4" + "@next/swc-darwin-x64" "13.5.4" + "@next/swc-linux-arm64-gnu" "13.5.4" + "@next/swc-linux-arm64-musl" "13.5.4" + "@next/swc-linux-x64-gnu" "13.5.4" + "@next/swc-linux-x64-musl" "13.5.4" + "@next/swc-win32-arm64-msvc" "13.5.4" + "@next/swc-win32-ia32-msvc" "13.5.4" + "@next/swc-win32-x64-msvc" "13.5.4" no-case@^3.0.4: version "3.0.4" @@ -8211,12 +8226,12 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.2.0: resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== -postcss@8.4.14: - version "8.4.14" - resolved "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz" - integrity sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig== +postcss@8.4.31: + version "8.4.31" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.31.tgz#92b451050a9f914da6755af352bdc0192508656d" + integrity sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ== dependencies: - nanoid "^3.3.4" + nanoid "^3.3.6" picocolors "^1.0.0" source-map-js "^1.0.2" @@ -10142,14 +10157,16 @@ zen-observable@0.8.15: resolved "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz" integrity sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ== -zod@3.21.4: - version "3.21.4" - resolved "https://registry.yarnpkg.com/zod/-/zod-3.21.4.tgz#10882231d992519f0a10b5dd58a38c9dabbb64db" - integrity sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw== - -zustand@^4.3.8, zustand@^4.4.1: +zustand@^4.3.8: version "4.4.1" resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.4.1.tgz#0cd3a3e4756f21811bd956418fdc686877e8b3b0" integrity sha512-QCPfstAS4EBiTQzlaGP1gmorkh/UL1Leaj2tdj+zZCZ/9bm0WS7sI2wnfD5lpOszFqWJ1DcPnGoY8RDL61uokw== dependencies: use-sync-external-store "1.2.0" + +zustand@^4.4.4: + version "4.4.3" + resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.4.3.tgz#1d54cf7fa4507ad8bf58e2f13e08ddc8a6730128" + integrity sha512-oRy+X3ZazZvLfmv6viIaQmtLOMeij1noakIsK/Y47PWYhT8glfXzQ4j0YcP5i0P0qI1A4rIB//SGROGyZhx91A== + dependencies: + use-sync-external-store "1.2.0" From 3fce7f58511027f908f80bdc12f64d1653472a7a Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Wed, 11 Oct 2023 16:08:31 +0200 Subject: [PATCH 5/8] Fix utilization rate (#537) --- .env.example | 33 ++----------------- .../MarketAssetTable/MarketDetails.tsx | 2 +- yarn.lock | 2 +- 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/.env.example b/.env.example index 6bdf5290..03d1da3d 100644 --- a/.env.example +++ b/.env.example @@ -19,34 +19,10 @@ NEXT_PUBLIC_PYTH_ENDPOINT=https://xc-mainnet.pyth.network/api NEXT_PUBLIC_MAINNET_REST=https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-lcd-front/ NEXT_PUBLIC_CANDLES_ENDPOINT=https://api.thegraph.com/subgraphs/name/donovansolms/osmosis-tv-candles-test NEXT_PUBLIC_WALLET_CONNECT_ID=d93fdffb159bae5ec87d8fee4cdbb045 -CHARTING_LIBRARY_REPOSITORY=github.com/tradingview/charting_library -CHARTING_LIBRARY_ACCESS_TOKEN=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 -CHARTING_LIBRARY_USERNAME=mars-git-demo -# TESTNET # -# NEXT_PUBLIC_NETWORK=testnet -# NEXT_PUBLIC_CHAIN_ID=osmo-test-5 -# NEXT_PUBLIC_RPC=https://testnet-osmosis-node.marsprotocol.io/XF32UOOU55CX/osmosis-rpc-front/ -# NEXT_PUBLIC_GQL=https://testnet-osmosis-node.marsprotocol.io/XF32UOOU55CX/osmosis-hive-front/graphql -# NEXT_PUBLIC_REST=https://testnet-osmosis-node.marsprotocol.io/XF32UOOU55CX/osmosis-lcd-front/ -# NEXT_PUBLIC_SWAP=https://testnet.osmosis.zone -# NEXT_PUBLIC_VAULT_APR=https://testnet-api.marsprotocol.io/v1/vaults/osmosis -# NEXT_PUBLIC_ACCOUNT_NFT=osmo1hdk6nps2l2tdfgly0tegcgwl239l45etuae7nsc6s93u0yrqk4rqv489kl -# NEXT_PUBLIC_ORACLE=osmo1dxu93scjdnx42txdp9d4hm3snffvnzmkp4jpc9sml8xlu3ncgamsl2lx58 -# NEXT_PUBLIC_RED_BANK=osmo1hs4sm0fah9rk4mz8e56v4n76g0q9fffdkkjm3f8tjagkdx78pqcq75pk0a -# NEXT_PUBLIC_CREDIT_MANAGER=osmo1zwugj8tz9nq63m3lxcfpunp0xr5lnlxdr0yyn4gpftx3ham09m4skn73ew -# NEXT_PUBLIC_INCENTIVES=osmo1nu0k6g294jela67vyth6nwr3l42gutq2m07pg9927f7v7tuv0d4sre9fr7 -# NEXT_PUBLIC_ZAPPER=osmo1jwtmujld4ew2vt67qnmpdxr3fmmle2yg823de5ygvf47uvhpu76qlhf82q -# NEXT_PUBLIC_SWAPPER=osmo1ee9cq8dcknmw43znznx6vuupx5ku0tt505agccgaz5gn48mhe45s3kwwfm -# NEXT_PUBLIC_PARAMS=osmo1h334tvddn82m4apm08rm9k6kt32ws7vy0c4n30ngrvu6h6yxh8eq9l9jfh -# NEXT_PUBLIC_API=http://localhost:3000/api -# NEXT_PUBLIC_CANDLES_ENDPOINT="https://api.thegraph.com/subgraphs/name/{NAME}/{GRAPH_NAME}" -# CHARTING_LIBRARY_USERNAME="username_with_access_to_charting_library" -# CHARTING_LIBRARY_ACCESS_TOKEN="access_token_with_access_to_charting_library" -# CHARTING_LIBRARY_REPOSITORY="github.com/username/charting_library/" -# NEXT_PUBLIC_PYTH_ENDPOINT=https://xc-mainnet.pyth.network/api -# NEXT_PUBLIC_MAINNET_REST=https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-lcd-front/ -# NEXT_PUBLIC_WALLET_CONNECT_ID=d93fdffb159bae5ec87d8fee4cdbb045 +CHARTING_LIBRARY_REPOSITORY=github.com/tradingview/charting_library +CHARTING_LIBRARY_ACCESS_TOKEN=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 +CHARTING_LIBRARY_USERNAME=mars-git-demo # MAINNET # # NEXT_PUBLIC_NETWORK=mainnet @@ -64,9 +40,6 @@ CHARTING_LIBRARY_USERNAME=mars-git-demo # NEXT_PUBLIC_ZAPPER=osmo17qwvc70pzc9mudr8t02t3pl74hhqsgwnskl734p4hug3s8mkerdqzduf7c # NEXT_PUBLIC_SWAPPER=osmo1wee0z8c7tcawyl647eapqs4a88q8jpa7ddy6nn2nrs7t47p2zhxswetwla # NEXT_PUBLIC_API=http://localhost:3000/api -# CHARTING_LIBRARY_USERNAME="username_with_access_to_charting_library" -# CHARTING_LIBRARY_ACCESS_TOKEN="access_token_with_access_to_charting_library" -# CHARTING_LIBRARY_REPOSITORY="username/charting_library" # NEXT_PUBLIC_PYTH_ENDPOINT=https://xc-mainnet.pyth.network/api # NEXT_PUBLIC_MAINNET_REST=https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-lcd-front/ # NEXT_PUBLIC_WALLET_CONNECT_ID=d93fdffb159bae5ec87d8fee4cdbb045 diff --git a/src/components/MarketAssetTable/MarketDetails.tsx b/src/components/MarketAssetTable/MarketDetails.tsx index 5773f06f..80340eb2 100644 --- a/src/components/MarketAssetTable/MarketDetails.tsx +++ b/src/components/MarketAssetTable/MarketDetails.tsx @@ -68,7 +68,7 @@ export default function MarketDetails({ data, type }: Props) { title: 'Oracle Price', }, { - amount: totalBorrowed.dividedBy(depositCap).multipliedBy(100).toNumber(), + amount: totalBorrowed.dividedBy(marketDepositAmount).multipliedBy(100).toNumber(), options: { minDecimals: 2, maxDecimals: 2, suffix: '%' }, title: 'Utilization Rate', }, diff --git a/yarn.lock b/yarn.lock index 1944f383..4741001f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10164,7 +10164,7 @@ zustand@^4.3.8: dependencies: use-sync-external-store "1.2.0" -zustand@^4.4.4: +zustand@^4.4.3: version "4.4.3" resolved "https://registry.yarnpkg.com/zustand/-/zustand-4.4.3.tgz#1d54cf7fa4507ad8bf58e2f13e08ddc8a6730128" integrity sha512-oRy+X3ZazZvLfmv6viIaQmtLOMeij1noakIsK/Y47PWYhT8glfXzQ4j0YcP5i0P0qI1A4rIB//SGROGyZhx91A== From 4915729ed5591e6336b9e3027480085338a0d17c Mon Sep 17 00:00:00 2001 From: Bob van der Helm <34470358+bobthebuidlr@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:40:40 +0200 Subject: [PATCH 6/8] =?UTF-8?q?=E2=9C=A8=20routing=20and=20pages=20for=20H?= =?UTF-8?q?LS=20(#538)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Earn/Tab.tsx | 33 ++++++++----------- src/components/Header/DesktopHeader.tsx | 2 ++ .../Navigation/DesktopNavigation.tsx | 3 +- src/components/Routes.tsx | 6 ++++ src/constants/pages.ts | 9 +++++ src/pages/FarmPage.tsx | 3 +- src/pages/HLSFarmPage.tsx | 12 +++++++ src/pages/HLSStakingPage.tsx | 12 +++++++ src/pages/LendPage.tsx | 5 +-- src/types/interfaces/components/Tab.d.ts | 4 +++ src/types/interfaces/route.d.ts | 10 +++++- src/utils/constants.ts | 2 ++ 12 files changed, 77 insertions(+), 24 deletions(-) create mode 100644 src/constants/pages.ts create mode 100644 src/pages/HLSFarmPage.tsx create mode 100644 src/pages/HLSStakingPage.tsx create mode 100644 src/types/interfaces/components/Tab.d.ts diff --git a/src/components/Earn/Tab.tsx b/src/components/Earn/Tab.tsx index bc4b7f16..1495c47c 100644 --- a/src/components/Earn/Tab.tsx +++ b/src/components/Earn/Tab.tsx @@ -8,7 +8,8 @@ const underlineClasses = 'relative before:absolute before:h-[2px] before:-bottom-1 before:left-0 before:right-0 before:gradient-active-tab' interface Props { - isFarm?: boolean + tabs: Tab[] + activeTabIdx: number } export default function Tab(props: Props) { @@ -17,24 +18,18 @@ export default function Tab(props: Props) { return (
- - Lend - - - Farm - + {props.tabs.map((tab, index) => ( + + {tab.name} + + ))}
) } diff --git a/src/components/Header/DesktopHeader.tsx b/src/components/Header/DesktopHeader.tsx index 8e1ff645..8965a7a1 100644 --- a/src/components/Header/DesktopHeader.tsx +++ b/src/components/Header/DesktopHeader.tsx @@ -9,12 +9,14 @@ import Settings from 'components/Settings' import Wallet from 'components/Wallet' import useAccountId from 'hooks/useAccountId' import useStore from 'store' +import { ENABLE_HLS } from 'utils/constants' export const menuTree: { pages: Page[]; label: string }[] = [ { pages: ['trade'], label: 'Trade' }, { pages: ['lend', 'farm'], label: 'Earn' }, { pages: ['borrow'], label: 'Borrow' }, { pages: ['portfolio'], label: 'Portfolio' }, + ...(ENABLE_HLS ? [{ pages: ['hls-farm', 'hls-staking'] as Page[], label: 'High Leverage' }] : []), ] export default function DesktopHeader() { diff --git a/src/components/Navigation/DesktopNavigation.tsx b/src/components/Navigation/DesktopNavigation.tsx index 596164f9..5621315d 100644 --- a/src/components/Navigation/DesktopNavigation.tsx +++ b/src/components/Navigation/DesktopNavigation.tsx @@ -15,7 +15,8 @@ export default function DesktopNavigation() { const focusComponent = useStore((s) => s.focusComponent) function getIsActive(pages: string[]) { - return pages.some((page) => location.pathname.includes(page)) + const segments = location.pathname.split('/') + return pages.some((page) => segments.includes(page)) } return ( diff --git a/src/components/Routes.tsx b/src/components/Routes.tsx index e4e0b096..df26dd94 100644 --- a/src/components/Routes.tsx +++ b/src/components/Routes.tsx @@ -3,6 +3,8 @@ import { Navigate, Outlet, Route, Routes as RoutesWrapper } from 'react-router-d import Layout from 'pages/_layout' import BorrowPage from 'pages/BorrowPage' import FarmPage from 'pages/FarmPage' +import HLSFarmPage from 'pages/HLSFarmPage' +import HLSStakingPage from 'pages/HLSStakingPage' import LendPage from 'pages/LendPage' import MobilePage from 'pages/MobilePage' import PortfolioAccountPage from 'pages/PortfolioAccountPage' @@ -25,6 +27,8 @@ export default function Routes() { } /> } /> } /> + } /> + } /> } /> } /> @@ -35,6 +39,8 @@ export default function Routes() { } /> + } /> + } /> } /> } /> diff --git a/src/constants/pages.ts b/src/constants/pages.ts new file mode 100644 index 00000000..a649f1fa --- /dev/null +++ b/src/constants/pages.ts @@ -0,0 +1,9 @@ +export const EARN_TABS: Tab[] = [ + { page: 'lend', name: 'Lend' }, + { page: 'farm', name: 'Farm' }, +] + +export const HLS_TABS: Tab[] = [ + { page: 'hls-farm', name: 'Farm' }, + { page: 'hls-staking', name: 'Staking' }, +] diff --git a/src/pages/FarmPage.tsx b/src/pages/FarmPage.tsx index fb248757..0eeccf7d 100644 --- a/src/pages/FarmPage.tsx +++ b/src/pages/FarmPage.tsx @@ -2,12 +2,13 @@ import FarmIntro from 'components/Earn/Farm/FarmIntro' import { AvailableVaults, DepositedVaults } from 'components/Earn/Farm/Vaults' import Tab from 'components/Earn/Tab' import MigrationBanner from 'components/MigrationBanner' +import { EARN_TABS } from 'constants/pages' export default function FarmPage() { return (
- + diff --git a/src/pages/HLSFarmPage.tsx b/src/pages/HLSFarmPage.tsx new file mode 100644 index 00000000..d386ee30 --- /dev/null +++ b/src/pages/HLSFarmPage.tsx @@ -0,0 +1,12 @@ +import Tab from 'components/Earn/Tab' +import MigrationBanner from 'components/MigrationBanner' +import { HLS_TABS } from 'constants/pages' + +export default function HLSFarmPage() { + return ( +
+ + +
+ ) +} diff --git a/src/pages/HLSStakingPage.tsx b/src/pages/HLSStakingPage.tsx new file mode 100644 index 00000000..1fc8e2d2 --- /dev/null +++ b/src/pages/HLSStakingPage.tsx @@ -0,0 +1,12 @@ +import Tab from 'components/Earn/Tab' +import MigrationBanner from 'components/MigrationBanner' +import { HLS_TABS } from 'constants/pages' + +export default function HLSStakingPage() { + return ( +
+ + +
+ ) +} diff --git a/src/pages/LendPage.tsx b/src/pages/LendPage.tsx index c27b76e3..0cce99ee 100644 --- a/src/pages/LendPage.tsx +++ b/src/pages/LendPage.tsx @@ -1,7 +1,8 @@ -import LendIntro from 'components/Earn/Lend/LendIntro' import LendingMarketsTable from 'components/Earn/Lend/LendingMarketsTable' +import LendIntro from 'components/Earn/Lend/LendIntro' import Tab from 'components/Earn/Tab' import MigrationBanner from 'components/MigrationBanner' +import { EARN_TABS } from 'constants/pages' import useLendingMarketAssetsTableData from 'hooks/useLendingMarketAssetsTableData' export default function LendPage() { @@ -9,7 +10,7 @@ export default function LendPage() { return (
- + diff --git a/src/types/interfaces/components/Tab.d.ts b/src/types/interfaces/components/Tab.d.ts new file mode 100644 index 00000000..aff1c9c5 --- /dev/null +++ b/src/types/interfaces/components/Tab.d.ts @@ -0,0 +1,4 @@ +interface Tab { + page: Page + name: string +} diff --git a/src/types/interfaces/route.d.ts b/src/types/interfaces/route.d.ts index 48101e31..dcd3b9e7 100644 --- a/src/types/interfaces/route.d.ts +++ b/src/types/interfaces/route.d.ts @@ -1 +1,9 @@ -type Page = 'trade' | 'borrow' | 'farm' | 'lend' | 'portfolio' | 'portfolio/{accountId}' +type Page = + | 'trade' + | 'borrow' + | 'farm' + | 'lend' + | 'portfolio' + | 'portfolio/{accountId}' + | 'hls-farm' + | 'hls-staking' diff --git a/src/utils/constants.ts b/src/utils/constants.ts index f4e8a264..55a7b2b4 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -22,3 +22,5 @@ export const DEFAULT_PORTFOLIO_STATS = [ { title: null, sub: 'APR' }, { title: null, sub: 'Account Leverage' }, ] + +export const ENABLE_HLS = false From ea614997a7b5a13fb58e8b65f722534c69d57aab Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Fri, 13 Oct 2023 13:49:38 +0200 Subject: [PATCH 7/8] Share accounts (#539) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: do not redirect to wallet on portfolio page * fix: use connected wallet for AccountMenu * fix: fixed ghost AccountDetails * feat: created ShareBar and share functionality * fix: donā€™t show shareBar if no address is present * fix: stupid 'next/navigation' * tidy: format * fix: fixed tests * āœØ routing and pages for HLS (#538) * šŸ› use useAccountIds * fix: fixed the tests * fix: accountIds is now a suspense --------- Co-authored-by: Bob van der Helm <34470358+bobthebuidlr@users.noreply.github.com> --- .../Account/AccountDetails.test.tsx | 21 +++++-- src/api/wallets/getAccountIds.ts | 2 +- .../Account/AccountDetails/index.tsx | 10 +++- src/components/Account/AccountList/index.tsx | 6 +- src/components/Account/AccountMenuContent.tsx | 9 +-- src/components/Button/ActionButton.tsx | 2 +- src/components/Icons/Chain.svg | 6 ++ src/components/Icons/Twitter.svg | 7 +++ src/components/Icons/index.ts | 2 + .../Navigation/DesktopNavigation.tsx | 5 +- src/components/Portfolio/Card/index.tsx | 7 ++- src/components/Portfolio/Overview/index.tsx | 4 +- src/components/Portfolio/PortfolioIntro.tsx | 11 ++-- src/components/ShareBar.tsx | 55 +++++++++++++++++++ .../TradeChart/OsmosisTheGraphDataFeed.ts | 3 +- .../Wallet/WalletFetchBalancesAndAccounts.tsx | 17 ++++-- src/hooks/useAccountIds.tsx | 4 +- src/pages/PortfolioAccountPage.tsx | 2 + src/pages/PortfolioPage.tsx | 2 + src/types/enums/docURL.ts | 1 + 20 files changed, 140 insertions(+), 36 deletions(-) create mode 100644 src/components/Icons/Chain.svg create mode 100644 src/components/Icons/Twitter.svg create mode 100644 src/components/ShareBar.tsx diff --git a/__tests__/components/Account/AccountDetails.test.tsx b/__tests__/components/Account/AccountDetails.test.tsx index 90b1de80..99b2f944 100644 --- a/__tests__/components/Account/AccountDetails.test.tsx +++ b/__tests__/components/Account/AccountDetails.test.tsx @@ -14,15 +14,28 @@ jest.mock('hooks/useHealthComputer', () => jest.mock('components/Account/AccountBalancesTable', () => jest.fn(() => null)) const mockedUseCurrentAccount = useCurrentAccount as jest.Mock -const mockedAccount = { id: '1', deposits: [], lends: [], debts: [], vaults: [] } +const mockedAccounts = [ + { id: '1', deposits: [], lends: [], debts: [], vaults: [] }, + { id: '2', deposits: [], lends: [], debts: [], vaults: [] }, +] jest.mock('hooks/useAccountId', () => jest.fn(() => '1')) -jest.mock('hooks/useAccounts', () => jest.fn(() => [mockedAccount])) +jest.mock('hooks/useAccounts', () => + jest.fn(() => ({ + data: mockedAccounts, + })), +) +jest.mock('hooks/useAccountIds', () => + jest.fn(() => ({ + data: ['1', '2'], + })), +) +jest.mock('hooks/useCurrentAccount', () => jest.fn(() => mockedAccounts[0])) describe('', () => { beforeAll(() => { useStore.setState({ address: 'walletAddress', - accounts: [mockedAccount], + accounts: mockedAccounts, }) }) @@ -31,7 +44,7 @@ describe('', () => { }) it('renders account details WHEN account is selected', () => { - mockedUseCurrentAccount.mockReturnValue(mockedAccount) + mockedUseCurrentAccount.mockReturnValue(mockedAccounts) render() const container = screen.queryByTestId('account-details') diff --git a/src/api/wallets/getAccountIds.ts b/src/api/wallets/getAccountIds.ts index 55cfbe99..de876130 100644 --- a/src/api/wallets/getAccountIds.ts +++ b/src/api/wallets/getAccountIds.ts @@ -5,8 +5,8 @@ export default async function getAccountIds( address?: string, previousResults?: string[], ): Promise { + if (!address) return [] try { - if (!address) return [] const accountNftQueryClient = await getAccountNftQueryClient() const lastItem = previousResults && previousResults.at(-1) diff --git a/src/components/Account/AccountDetails/index.tsx b/src/components/Account/AccountDetails/index.tsx index ee24f77a..9d6ffe57 100644 --- a/src/components/Account/AccountDetails/index.tsx +++ b/src/components/Account/AccountDetails/index.tsx @@ -17,6 +17,7 @@ import { DEFAULT_SETTINGS } from 'constants/defaultSettings' import { REDUCE_MOTION_KEY } from 'constants/localStore' import { ORACLE_DENOM } from 'constants/oracle' import useAccountId from 'hooks/useAccountId' +import useAccountIds from 'hooks/useAccountIds' import useAccounts from 'hooks/useAccounts' import useBorrowMarketAssetsTableData from 'hooks/useBorrowMarketAssetsTableData' import useCurrentAccount from 'hooks/useCurrentAccount' @@ -34,12 +35,15 @@ import { export default function AccountDetailsController() { const address = useStore((s) => s.address) - const { isLoading } = useAccounts(address) + const { data: accounts, isLoading } = useAccounts(address) + const { data: accountIds } = useAccountIds(address, false) const accountId = useAccountId() const account = useCurrentAccount() - const focusComponent = useStore((s) => s.focusComponent) - if (!address || focusComponent) return null + const focusComponent = useStore((s) => s.focusComponent) + const isOwnAccount = accountId && accountIds?.includes(accountId) + + if (!address || focusComponent || !isOwnAccount) return null if ((isLoading && accountId && !focusComponent) || !account) return diff --git a/src/components/Account/AccountList/index.tsx b/src/components/Account/AccountList/index.tsx index 29f96b49..c600ddd2 100644 --- a/src/components/Account/AccountList/index.tsx +++ b/src/components/Account/AccountList/index.tsx @@ -1,6 +1,6 @@ import classNames from 'classnames' import { useEffect } from 'react' -import { useLocation, useNavigate, useParams } from 'react-router-dom' +import { useLocation, useNavigate } from 'react-router-dom' import AccountStats from 'components/Account/AccountList/AccountStats' import Card from 'components/Card' @@ -26,7 +26,7 @@ export default function AccountList(props: Props) { const navigate = useNavigate() const { pathname } = useLocation() const currentAccountId = useAccountId() - const { address } = useParams() + const address = useStore((s) => s.address) const { data: accountIds } = useAccountIds(address) useEffect(() => { @@ -37,7 +37,7 @@ export default function AccountList(props: Props) { } }, [currentAccountId]) - if (!accountIds?.length) return null + if (!accountIds || !accountIds.length) return null return (
diff --git a/src/components/Account/AccountMenuContent.tsx b/src/components/Account/AccountMenuContent.tsx index 324101c1..e1a939c9 100644 --- a/src/components/Account/AccountMenuContent.tsx +++ b/src/components/Account/AccountMenuContent.tsx @@ -1,6 +1,6 @@ import classNames from 'classnames' import { useCallback } from 'react' -import { useLocation, useNavigate, useParams } from 'react-router-dom' +import { useLocation, useNavigate } from 'react-router-dom' import AccountCreateFirst from 'components/Account/AccountCreateFirst' import AccountFund from 'components/Account/AccountFund/AccountFundFullPage' @@ -30,7 +30,7 @@ const ACCOUNT_MENU_BUTTON_ID = 'account-menu-button' export default function AccountMenuContent() { const navigate = useNavigate() const { pathname } = useLocation() - const { address } = useParams() + const address = useStore((s) => s.address) const { data: accountIds } = useAccountIds(address) const accountId = useAccountId() @@ -42,8 +42,9 @@ export default function AccountMenuContent() { const [lendAssets] = useLocalStorage(LEND_ASSETS_KEY, DEFAULT_SETTINGS.lendAssets) const { enableAutoLendAccountId } = useAutoLend() - const hasCreditAccounts = !!accountIds.length - const isAccountSelected = isNumber(accountId) + const hasCreditAccounts = !!accountIds?.length + const isAccountSelected = + hasCreditAccounts && accountId && isNumber(accountId) && accountIds.includes(accountId) const checkHasFunds = useCallback(() => { return ( diff --git a/src/components/Button/ActionButton.tsx b/src/components/Button/ActionButton.tsx index d1ce6e2a..4b240d7b 100644 --- a/src/components/Button/ActionButton.tsx +++ b/src/components/Button/ActionButton.tsx @@ -23,7 +23,7 @@ export default function ActionButton(props: ButtonProps) { if (!address) return - if (accountIds.length === 0) { + if (accountIds && accountIds.length === 0) { return (
diff --git a/src/components/Portfolio/PortfolioIntro.tsx b/src/components/Portfolio/PortfolioIntro.tsx index 7ccac9d1..e359527a 100644 --- a/src/components/Portfolio/PortfolioIntro.tsx +++ b/src/components/Portfolio/PortfolioIntro.tsx @@ -4,17 +4,18 @@ import Intro from 'components/Intro' import useStore from 'store' export default function PortfolioIntro() { - const { address } = useParams() - const walletAddress = useStore((s) => s.address) + const { address: urlAddress } = useParams() + const address = useStore((s) => s.address) + const isCurrentWalllet = !urlAddress || urlAddress === address return ( This is the Portfolio of the address{' '} - {address}. You can see all Credit Accounts of this - address, but you can't interact with them. + {urlAddress}. You can see all Credit Accounts of + this address, but you can't interact with them. ) : ( <> diff --git a/src/components/ShareBar.tsx b/src/components/ShareBar.tsx new file mode 100644 index 00000000..9cea8d2e --- /dev/null +++ b/src/components/ShareBar.tsx @@ -0,0 +1,55 @@ +import classNames from 'classnames' +import { useLocation, useParams } from 'react-router-dom' +import useClipboard from 'react-use-clipboard' + +import Button from 'components/Button' +import { Chain, Check, Twitter } from 'components/Icons' +import Text from 'components/Text' +import { Tooltip } from 'components/Tooltip' +import ConditionalWrapper from 'hocs/ConditionalWrapper' +import { DocURL } from 'types/enums/docURL' + +interface Props { + text: string +} + +export default function ShareBar(props: Props) { + const { address } = useParams() + const { pathname } = useLocation() + const currentUrl = `https://${location.host}${pathname}` + const [isCopied, setCopied] = useClipboard(currentUrl, { + successDuration: 1000 * 5, + }) + + if (!window || !address) return null + return ( +
+ ( + Link copied!}> + {children} + + )} + > +
+ ) +} diff --git a/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts b/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts index 0fe4ac96..384c9d13 100644 --- a/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts +++ b/src/components/Trade/TradeChart/OsmosisTheGraphDataFeed.ts @@ -224,7 +224,8 @@ export class OsmosisTheGraphDataFeed implements IDatafeedChartApi { } const filler = Array.from({ length: this.batchSize - bars.length }).map((_, index) => ({ - time: (bars[0]?.time || new Date().getTime()) - index * this.minutesPerInterval[resolution], + time: + (bars[0]?.time || new Date().getTime()) - index * this.minutesPerInterval[resolution], close: 0, open: 0, high: 0, diff --git a/src/components/Wallet/WalletFetchBalancesAndAccounts.tsx b/src/components/Wallet/WalletFetchBalancesAndAccounts.tsx index 034e5323..b1155418 100644 --- a/src/components/Wallet/WalletFetchBalancesAndAccounts.tsx +++ b/src/components/Wallet/WalletFetchBalancesAndAccounts.tsx @@ -1,5 +1,5 @@ import { Suspense, useEffect, useMemo } from 'react' -import { useLocation, useNavigate } from 'react-router-dom' +import { useLocation, useNavigate, useParams } from 'react-router-dom' import AccountCreateFirst from 'components/Account/AccountCreateFirst' import { CircularProgress } from 'components/CircularProgress' @@ -27,6 +27,7 @@ function FetchLoading() { function Content() { const address = useStore((s) => s.address) + const { address: urlAddress } = useParams() const navigate = useNavigate() const { pathname } = useLocation() const { data: accountIds, isLoading: isLoadingAccounts } = useAccountIds(address || '') @@ -39,18 +40,26 @@ function Content() { ) useEffect(() => { + const page = getPage(pathname) + if (page === 'portfolio' && urlAddress && urlAddress !== address) { + navigate(getRoute(page, urlAddress as string)) + useStore.setState({ balances: walletBalances, focusComponent: null }) + return + } + if ( + accountIds && accountIds.length !== 0 && BN(baseBalance).isGreaterThanOrEqualTo(defaultFee.amount[0].amount) ) { - navigate(getRoute(getPage(pathname), address, accountIds[0])) + navigate(getRoute(page, address, accountIds[0])) useStore.setState({ balances: walletBalances, focusComponent: null }) } - }, [accountIds, baseBalance, navigate, pathname, address, walletBalances]) + }, [accountIds, baseBalance, navigate, pathname, address, walletBalances, urlAddress]) if (isLoadingAccounts || isLoadingBalances) return if (BN(baseBalance).isLessThan(defaultFee.amount[0].amount)) return - if (accountIds.length === 0) return + if (accountIds && accountIds.length === 0) return return null } diff --git a/src/hooks/useAccountIds.tsx b/src/hooks/useAccountIds.tsx index fffe385c..da633e92 100644 --- a/src/hooks/useAccountIds.tsx +++ b/src/hooks/useAccountIds.tsx @@ -2,9 +2,9 @@ import useSWR from 'swr' import getAccountIds from 'api/wallets/getAccountIds' -export default function useAccountIds(address?: string) { +export default function useAccountIds(address?: string, suspense = true) { return useSWR(`wallets/${address}/account-ids`, () => getAccountIds(address), { - suspense: true, + suspense: suspense, fallback: [] as string[], revalidateOnFocus: false, }) diff --git a/src/pages/PortfolioAccountPage.tsx b/src/pages/PortfolioAccountPage.tsx index fa63750a..84a9b835 100644 --- a/src/pages/PortfolioAccountPage.tsx +++ b/src/pages/PortfolioAccountPage.tsx @@ -4,6 +4,7 @@ import MigrationBanner from 'components/MigrationBanner' import Balances from 'components/Portfolio/Account/Balances' import BreadCrumbs from 'components/Portfolio/Account/BreadCrumbs' import Summary from 'components/Portfolio/Account/Summary' +import ShareBar from 'components/ShareBar' import useAccountId from 'hooks/useAccountId' import { getRoute } from 'utils/route' @@ -23,6 +24,7 @@ export default function PortfolioAccountPage() { +
) } diff --git a/src/pages/PortfolioPage.tsx b/src/pages/PortfolioPage.tsx index 9c676797..e39a71db 100644 --- a/src/pages/PortfolioPage.tsx +++ b/src/pages/PortfolioPage.tsx @@ -2,6 +2,7 @@ import MigrationBanner from 'components/MigrationBanner' import AccountOverview from 'components/Portfolio/Overview' import PortfolioSummary from 'components/Portfolio/Overview/Summary' import PortfolioIntro from 'components/Portfolio/PortfolioIntro' +import ShareBar from 'components/ShareBar' export default function PortfolioPage() { return ( @@ -10,6 +11,7 @@ export default function PortfolioPage() { +
) } diff --git a/src/types/enums/docURL.ts b/src/types/enums/docURL.ts index 7babde0c..185393b1 100644 --- a/src/types/enums/docURL.ts +++ b/src/types/enums/docURL.ts @@ -10,4 +10,5 @@ export enum DocURL { TRADING_INTRO_URL = 'https://docs.marsprotocol.io/docs/learn/tutorials/trading/trading-intro', V1_URL = 'https://v1.marsprotocol.io', WALLET_INTRO_URL = 'https://docs.marsprotocol.io/docs/learn/tutorials/basics/connecting-your-wallet', + X_SHARE_URL = 'https://x.com/intent/tweet', } From 199e24a006ab4b01026bc331bb2e08d3f9067dc2 Mon Sep 17 00:00:00 2001 From: Linkie Link Date: Sat, 14 Oct 2023 16:54:41 +0200 Subject: [PATCH 8/8] Set new caching rules (#542) --- next.config.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index f293ba9f..3915291a 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - productionBrowserSourceMaps: true, reactStrictMode: true, images: { domains: [ @@ -26,6 +25,31 @@ const nextConfig = { }, ] }, + async headers() { + return [ + { + source: '/(.*)?', + headers: [ + { + key: 'Referrer-Policy', + value: 'origin-when-cross-origin', + }, + { + key: 'Pragma', + value: 'no-cache', + }, + { + key: 'Expires', + value: new Date().toString(), + }, + { + key: 'X-Content-Type-Options', + value: 'nosniff', + }, + ], + }, + ] + }, async rewrites() { return [ {