Skip to content

Commit c3f83ef

Browse files
authored
Merge pull request #964 from mars-protocol/develop
v2.4.0
2 parents 6bfa4d5 + 2800a79 commit c3f83ef

File tree

223 files changed

+2823
-4845
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+2823
-4845
lines changed

.env.example

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ NEXT_PUBLIC_WALLET_CONNECT_ID=0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x
55
### Optional Environment Variables
66
NEXT_PUBLIC_OSMOSIS_RPC=https://rpc-osmosis.blockapsis.com
77
NEXT_PUBLIC_OSMOSIS_REST=https://lcd-osmosis.blockapsis.com
8-
NEXT_PUBLIC_OSMOSIS_TEST_RPC=https://rpc.devnet.osmosis.zone
9-
NEXT_PUBLIC_OSMOSIS_TEST_REST=https://lcd.devnet.osmosis.zone
108
NEXT_PUBLIC_NEUTRON_TEST_RPC=https://rpc-palvus.pion-1.ntrn.tech
119
NEXT_PUBLIC_NEUTRON_TEST_REST=https://rest-palvus.pion-1.ntrn.tech
1210

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

eslint.config.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const ts = require('@typescript-eslint/eslint-plugin')
2+
const tsParser = require('@typescript-eslint/parser')
3+
const functional = require('eslint-plugin-functional')
4+
const imprt = require('eslint-plugin-import')
5+
6+
module.exports = [
7+
{
8+
files: ['src/**/*.ts', 'src/**/*.tsx'],
9+
ignores: [
10+
'src/utils/charting_library/*',
11+
'src/utils/datafeeds/*',
12+
'src/utils/health_computer/*',
13+
'src/types/generated/**/*',
14+
],
15+
languageOptions: {
16+
parser: tsParser,
17+
parserOptions: {
18+
ecmaFeatures: { modules: true },
19+
ecmaVersion: 'latest',
20+
project: './tsconfig.json',
21+
},
22+
},
23+
plugins: {
24+
functional,
25+
import: imprt,
26+
'@typescript-eslint': ts,
27+
ts,
28+
},
29+
rules: {
30+
'@typescript-eslint/no-empty-interface': 'off',
31+
'@typescript-eslint/no-unused-vars': 'off',
32+
'@typescript-eslint/no-explicit-any': 'off',
33+
'require-jsdoc': 'off',
34+
'linebreak-style': ['warn', 'unix'],
35+
'sort-imports': [
36+
'warn',
37+
{
38+
ignoreCase: true,
39+
ignoreDeclarationSort: true,
40+
},
41+
],
42+
},
43+
},
44+
]

package.json

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mars-v2-frontend",
3-
"version": "2.3.5",
3+
"version": "2.4.0",
44
"homepage": "./",
55
"private": false,
66
"license": "SEE LICENSE IN LICENSE FILE",
@@ -21,10 +21,10 @@
2121
},
2222
"dependencies": {
2323
"@cosmjs/cosmwasm-stargate": "^0.32.3",
24-
"@delphi-labs/shuttle-react": "^3.22.0",
25-
"@keplr-wallet/cosmos": "^0.12.88",
24+
"@delphi-labs/shuttle-react": "^3.24.0",
25+
"@keplr-wallet/cosmos": "^0.12.101",
2626
"@tailwindcss/container-queries": "^0.1.1",
27-
"@tanstack/react-table": "^8.16.0",
27+
"@tanstack/react-table": "^8.17.3",
2828
"@tippyjs/react": "^4.2.6",
2929
"bignumber.js": "^9.1.2",
3030
"classnames": "^2.5.1",
@@ -35,17 +35,17 @@
3535
"mobx": "^6.12.3",
3636
"moment": "^2.30.1",
3737
"next": "^14.2.3",
38-
"react": "^18.3.1",
38+
"react": "18.3.1",
3939
"react-device-detect": "^2.2.3",
40-
"react-dom": "^18.2.0",
40+
"react-dom": "^18.3.1",
4141
"react-draggable": "^4.4.6",
42-
"react-helmet-async": "^2.0.4",
43-
"react-qr-code": "^2.0.12",
42+
"react-helmet-async": "^2.0.5",
43+
"react-qr-code": "^2.0.14",
4444
"react-router-dom": "^6.23.1",
4545
"react-spring": "^9.7.3",
4646
"react-toastify": "^10.0.5",
4747
"react-use-clipboard": "^1.0.9",
48-
"recharts": "^2.12.6",
48+
"recharts": "^2.12.7",
4949
"swr": "^2.2.5",
5050
"tailwind-scrollbar-hide": "^1.1.7",
5151
"zustand": "^4.5.2"
@@ -55,24 +55,29 @@
5555
"@types/debounce-promise": "^3.1.9",
5656
"@types/lodash.debounce": "^4.0.9",
5757
"@types/lodash.throttle": "^4.1.9",
58-
"@types/node": "^20.12.11",
59-
"@types/react": "18.3.1",
58+
"@types/node": "^20.14.2",
59+
"@types/react": "18.3.3",
6060
"@types/react-dom": "18.3.0",
6161
"@types/react-helmet": "^6.1.11",
62+
"@typescript-eslint/eslint-plugin": "^7.12.0",
63+
"@typescript-eslint/parser": "^7.12.0",
64+
"eslint-plugin-functional": "^6.5.1",
65+
"eslint-plugin-import": "^2.29.1",
6266
"autoprefixer": "^10.4.19",
6367
"dotenv": "^16.4.5",
64-
"dotenv-cli": "^7.4.1",
65-
"eslint": "^8.57.0",
66-
"eslint-config-next": "^14.2.3",
67-
"eslint-plugin-import": "^2.29.1",
68+
"dotenv-cli": "^7.4.2",
69+
"eslint": "^9.4.0",
6870
"husky": "^9.0.11",
6971
"identity-obj-proxy": "^3.0.0",
70-
"lint-staged": "^15.2.2",
71-
"prettier": "^3.2.5",
72-
"prettier-plugin-tailwindcss": "^0.5.14",
72+
"lint-staged": "^15.2.5",
73+
"prettier": "^3.3.1",
74+
"prettier-plugin-tailwindcss": "^0.6.2",
7375
"shelljs": "^0.8.5",
74-
"tailwindcss": "^3.4.3",
75-
"typescript": "5.3.3"
76+
"tailwindcss": "^3.4.4",
77+
"typescript": "5.4.5"
78+
},
79+
"resolutions": {
80+
"@cosmjs/encoding": "0.32.3"
7681
},
7782
"engines": {
7883
"npm": "please-use-yarn",

src/api/accounts/getAccount.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { cacheFn, positionsCache } from 'api/cache'
22
import { getCreditManagerQueryClient } from 'api/cosmwasm-client'
3-
import getPrices from 'api/prices/getPrices'
43
import getDepositedVaults from 'api/vaults/getDepositedVaults'
54
import { BNCoin } from 'types/classes/BNCoin'
65
import { Positions } from 'types/generated/mars-credit-manager/MarsCreditManager.types'
76
import { resolvePerpsPositions, resolvePerpsVaultPositions } from 'utils/resolvers'
87

98
export default async function getAccount(
109
chainConfig: ChainConfig,
10+
assets: Asset[],
1111
accountId?: string,
1212
): Promise<Account> {
1313
if (!accountId) return new Promise((_, reject) => reject('No account ID found'))
@@ -20,11 +20,9 @@ export default async function getAccount(
2020
`${chainConfig.id}/account/${accountId}`,
2121
)
2222

23-
const prices = await getPrices(chainConfig)
24-
2523
const accountKind = await creditManagerQueryClient.accountKind({ accountId: accountId })
2624

27-
const depositedVaults = await getDepositedVaults(accountId, chainConfig, accountPosition)
25+
const depositedVaults = await getDepositedVaults(accountId, chainConfig, assets, accountPosition)
2826

2927
if (accountPosition) {
3028
return {
@@ -34,7 +32,7 @@ export default async function getAccount(
3432
deposits: accountPosition.deposits.map((deposit) => new BNCoin(deposit)),
3533
vaults: depositedVaults,
3634
perpsVault: resolvePerpsVaultPositions(accountPosition.perp_vault),
37-
perps: resolvePerpsPositions(accountPosition.perps, prices),
35+
perps: resolvePerpsPositions(accountPosition.perps, assets),
3836
kind: accountKind,
3937
}
4038
}

src/api/assets/getAstroportAssets.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { convertAstroportAssetsResponse } from 'utils/assets'
2+
3+
export default async function getAssets(chainConfig: ChainConfig) {
4+
const uri = new URL(chainConfig.endpoints.dexAssets)
5+
try {
6+
const assets = await fetch(uri.toString()).then(async (res) => {
7+
const data = (await res.json()) as AstroportAsset[]
8+
return convertAstroportAssetsResponse(data)
9+
})
10+
return assets
11+
} catch (e) {
12+
console.error(e)
13+
}
14+
return []
15+
}

src/api/cache.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ import {
1717

1818
interface Cache<T> extends Map<string, { data: T | null; timestamp: number }> {}
1919

20-
let totalRequests: number = 0
21-
let cachedRequests: number = 0
20+
let totalRequests = 0
21+
let cachedRequests = 0
2222

2323
export async function cacheFn<T>(
2424
fn: () => Promise<T>,
2525
cache: Cache<T>,
2626
key: string,
27-
staleAfter: number = 5,
27+
staleAfter = 5,
2828
) {
2929
const cachedData = cache.get(key)?.data
3030
const isStale = (cache.get(key)?.timestamp || 0) + 1000 * staleAfter < new Date().getTime()

src/api/hls/getHLSStakingAccounts.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import getHLSStakingAssets from 'api/hls/getHLSStakingAssets'
2-
import getPrices from 'api/prices/getPrices'
32
import getAccounts from 'api/wallets/getAccounts'
43
import { calculateAccountLeverage, getAccountPositionValues, isAccountEmpty } from 'utils/accounts'
54

65
export default async function getHLSStakingAccounts(
76
chainConfig: ChainConfig,
7+
assets: Asset[],
88
address?: string,
99
): Promise<HLSAccountWithStrategy[]> {
10-
const accounts = await getAccounts('high_levered_strategy', chainConfig, address)
10+
const accounts = await getAccounts('high_levered_strategy', chainConfig, assets, address)
1111
const activeAccounts = accounts.filter((account) => !isAccountEmpty(account))
12-
const hlsStrategies = await getHLSStakingAssets(chainConfig)
13-
const prices = await getPrices(chainConfig)
12+
const hlsStrategies = await getHLSStakingAssets(chainConfig, assets)
1413
const hlsAccountsWithStrategy: HLSAccountWithStrategy[] = []
1514

1615
activeAccounts.forEach((account) => {
@@ -22,11 +21,7 @@ export default async function getHLSStakingAccounts(
2221

2322
if (!strategy) return
2423

25-
const [deposits, lends, debts, vaults] = getAccountPositionValues(
26-
account,
27-
prices,
28-
chainConfig.assets,
29-
)
24+
const [deposits, _, debts, __] = getAccountPositionValues(account, assets)
3025

3126
hlsAccountsWithStrategy.push({
3227
...account,
@@ -36,7 +31,7 @@ export default async function getHLSStakingAccounts(
3631
debt: debts,
3732
total: deposits,
3833
},
39-
leverage: calculateAccountLeverage(account, prices, chainConfig.assets).toNumber(),
34+
leverage: calculateAccountLeverage(account, assets).toNumber(),
4035
})
4136
})
4237

src/api/hls/getHLSStakingAssets.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import { byDenom } from 'utils/array'
55
import { BN } from 'utils/helpers'
66
import { resolveHLSStrategies } from 'utils/resolvers'
77

8-
export default async function getHLSStakingAssets(chainConfig: ChainConfig) {
9-
const stakingAssetDenoms = chainConfig.assets
10-
.filter((asset) => asset.isStaking)
11-
.map((asset) => asset.denom)
8+
export default async function getHLSStakingAssets(chainConfig: ChainConfig, assets: Asset[]) {
9+
const stakingAssetDenoms = assets.filter((asset) => asset.isStaking).map((asset) => asset.denom)
1210
const assetParams = await getAssetParams(chainConfig)
1311
const HLSAssets = assetParams
1412
.filter((asset) => asset.credit_manager.hls)
@@ -37,7 +35,7 @@ export default async function getHLSStakingAssets(chainConfig: ChainConfig) {
3735

3836
return Promise.all(depositCaps$).then((depositCaps) => {
3937
return depositCaps.map((depositCap, index) => {
40-
const borrowSymbol = chainConfig.assets.find(byDenom(strategies[index].denoms.borrow))?.symbol
38+
const borrowSymbol = assets.find(byDenom(strategies[index].denoms.borrow))?.symbol
4139
return {
4240
...strategies[index],
4341
depositCap: {

src/api/prices/getMarsPrice.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/api/prices/getPoolPrice.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)