Skip to content

Commit f5cefb7

Browse files
authored
Merge pull request #37 from mars-protocol/v1.6.0
2 parents 2ebc64a + 6b6d717 commit f5cefb7

Some content is hidden

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

48 files changed

+2674
-1460
lines changed

README.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,20 @@ Copy `.env.example` to `.env` and modify the values to suit your needs.
2828

2929
We allow the use of environment variables to be passed to the Docker container to specify custom endpoints for the app. The variables are:
3030

31-
| Variable | Description | Default |
32-
| --------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------ |
33-
| URL_OSMOSIS_GQL | The Osmosis Hive GraphQL endpoint to use | https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-hive-front/graphql |
34-
| URL_OSMOSIS_REST | The Osmosis node REST endpoint to use | https://lcd-osmosis.blockapsis.com |
35-
| URL_OSMOSIS_RPC | The Osmosis node RPC endpoint to use | https://rpc-osmosis.blockapsis.com |
36-
| URL_OSMOSIS_TEST_GQL | The Osmosis Testnet Hive GraphQL endpoint to use | https://testnet-osmosis-node.marsprotocol.io/XF32UOOU55CX/osmosis-hive-front/graphql |
37-
| URL_OSMOSIS_TEST_REST | The Osmosis Testnet node REST endpoint to use | https://lcd.osmotest5.osmosis.zone |
38-
| URL_OSMOSIS_TEST_RPC | The Osmosis Testnet node RPC endpoint to use | https://rpc.osmotest5.osmosis.zone |
39-
| URL_NEUTRON_TEST_GQL | The Neutron Testnet Hive GraphQL endpoint to use | https://testnet-neutron-gql.marsprotocol.io/graphql |
40-
| URL_NEUTRON_TEST_REST | The Neutron Testnet node REST endpoint to use | https://rest-palvus.pion-1.ntrn.tech |
41-
| URL_NEUTRON_TEST_RPC | The Neutron Testnet node RPC endpoint to use | https://rpc-palvus.pion-1.ntrn.tech |
31+
| Variable | Description | Default |
32+
| --------------------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------- |
33+
| URL_OSMOSIS_GQL | The Osmosis Hive GraphQL endpoint to use | https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-hive-front/graphql |
34+
| URL_OSMOSIS_REST | The Osmosis node REST endpoint to use | https://lcd-osmosis.blockapsis.com |
35+
| URL_OSMOSIS_RPC | The Osmosis node RPC endpoint to use | https://rpc-osmosis.blockapsis.com |
36+
| URL_OSMOSIS_TEST_GQL | The Osmosis Testnet Hive GraphQL endpoint to use | https://testnet-osmosis-node.marsprotocol.io/XF32UOOU55CX/osmosis-hive-front/graphql |
37+
| URL_OSMOSIS_TEST_REST | The Osmosis Testnet node REST endpoint to use | https://lcd.osmotest5.osmosis.zone |
38+
| URL_OSMOSIS_TEST_RPC | The Osmosis Testnet node RPC endpoint to use | https://rpc.osmotest5.osmosis.zone |
39+
| URL_NEUTRON_GQL | The Neutron Hive GraphQL endpoint to use | https://neutron.rpc.p2p.world/qgrnU6PsQZA8F9S5Fb8Fn3tV3kXmMBl2M9bcc9jWLjQy8p/hive/graphql |
40+
| URL_NEUTRON_REST | The Neutron node REST endpoint to use | https://rest-kralum.neutron-1.neutron.org |
41+
| URL_NEUTRON_RPC | The Neutron node RPC endpoint to use | https://rpc-kralum.neutron-1.neutron.org |
42+
| URL_NEUTRON_TEST_GQL | The Neutron Testnet Hive GraphQL endpoint to use | https://testnet-neutron-gql.marsprotocol.io/graphql |
43+
| URL_NEUTRON_TEST_REST | The Neutron Testnet node REST endpoint to use | https://rest-palvus.pion-1.ntrn.tech |
44+
| URL_NEUTRON_TEST_RPC | The Neutron Testnet node RPC endpoint to use | https://rpc-palvus.pion-1.ntrn.tech |
4245

4346
**Sample Docker run command**
4447

@@ -52,6 +55,9 @@ docker run -it -p 3000:3000 \
5255
-e URL_OSMOSIS_TEST_GQL=https://testnet-osmosis-node.marsprotocol.io/XF32UOOU55CX/osmosis-hive-front/graphql \
5356
-e URL_OSMOSIS_TEST_REST=https://lcd.osmotest5.osmosis.zone \
5457
-e URL_OSMOSIS_TEST_RPC=https://rpc.osmotest5.osmosis.zone \
58+
-e URL_NEUTRON_GQL=https://neutron.rpc.p2p.world/qgrnU6PsQZA8F9S5Fb8Fn3tV3kXmMBl2M9bcc9jWLjQy8p/hive/graphql \
59+
-e URL_NEUTRON_REST=https://rest-palvus.pion-1.ntrn.tech \
60+
-e URL_NEUTRON_RPC=https://rpc-palvus.pion-1.ntrn.tech \
5561
-e URL_NEUTRON_TEST_GQL=https://testnet-neutron-gql.marsprotocol.io/graphql \
5662
-e URL_NEUTRON_TEST_REST=https://rest-palvus.pion-1.ntrn.tech \
5763
-e URL_NEUTRON_TEST_RPC=https://rpc-palvus.pion-1.ntrn.tech marsprotocol/interface:latest

entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ echo "APP_NEXT_OSMOSIS_GQL=$URL_OSMOSIS_GQL" >> $envFilename
1010
echo "APP_NEXT_OSMOSIS_TEST_RPC=$URL_OSMOSIS_TEST_RPC" >> $envFilename
1111
echo "APP_NEXT_OSMOSIS_TEST_REST=$URL_OSMOSIS_TEST_REST" >> $envFilename
1212
echo "APP_NEXT_OSMOSIS_TEST_GQL=$URL_OSMOSIS_TEST_GQL" >> $envFilename
13+
echo "APP_NEXT_NEUTRON_RPC=$URL_NEUTRON_RPC" >> $envFilename
14+
echo "APP_NEXT_NEUTRON_REST=$URL_NEUTRON_REST" >> $envFilename
15+
echo "APP_NEXT_NEUTRON_GQL=$URL_NEUTRON_TEST_GQL" >> $envFilename
1316
echo "APP_NEXT_NEUTRON_TEST_RPC=$URL_NEUTRON_TEST_RPC" >> $envFilename
1417
echo "APP_NEXT_NEUTRON_TEST_REST=$URL_NEUTRON_TEST_REST" >> $envFilename
1518
echo "APP_NEXT_NEUTRON_TEST_GQL=$URL_NEUTRON_TEST_GQL" >> $envFilename

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mars",
33
"homepage": "./",
4-
"version": "1.5.3",
4+
"version": "1.6.0",
55
"license": "SEE LICENSE IN LICENSE FILE",
66
"private": false,
77
"scripts": {
@@ -18,14 +18,15 @@
1818
"test:coverage": "jest --coverage"
1919
},
2020
"dependencies": {
21-
"@cosmjs/cosmwasm-stargate": "^0.30.1",
21+
"@cosmjs/cosmwasm-stargate": "^0.31.0",
2222
"@cosmjs/launchpad": "^0.27.1",
23-
"@cosmjs/proto-signing": "^0.30.1",
24-
"@cosmjs/stargate": "^0.30.1",
25-
"@marsprotocol/wallet-connector": "^1.8.6",
23+
"@cosmjs/proto-signing": "^0.31.0",
24+
"@cosmjs/stargate": "^0.31.0",
25+
"@marsprotocol/wallet-connector": "^1.9.6",
2626
"@material-ui/core": "^4.12.4",
2727
"@material-ui/icons": "^4.11.3",
2828
"@ramonak/react-progress-bar": "^5.0.3",
29+
"@sentry/nextjs": "^7.36.0",
2930
"@tanstack/react-query": "^4.24.4",
3031
"@tanstack/react-table": "^8.7.9",
3132
"@testing-library/dom": "^8.20.0",

src/components/common/Containers/CommonContainer.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
WalletConnectionStatus,
88
} from '@marsprotocol/wallet-connector'
99
import { useQueryClient } from '@tanstack/react-query'
10-
import { MARS_SYMBOL } from 'constants/appConstants'
1110
import {
1211
useBlockHeight,
1312
useDepositAndDebt,
@@ -18,8 +17,8 @@ import {
1817
useUserDebt,
1918
useUserIcns,
2019
} from 'hooks/queries'
20+
import { useMarsPrice } from 'hooks/queries/useMarsPrice'
2121
import { usePythVaa } from 'hooks/queries/usePythVaa'
22-
import { useSpotPrice } from 'hooks/queries/useSpotPrice'
2322
import { useUserCollaterals } from 'hooks/queries/useUserCollaterals'
2423
import { ReactNode, useEffect, useState } from 'react'
2524
import useStore from 'store'
@@ -52,7 +51,6 @@ export const CommonContainer = ({ children }: CommonContainerProps) => {
5251
const networkConfig = useStore((s) => s.networkConfig)
5352
const marketDeposits = useStore((s) => s.marketDeposits)
5453
const marketInfo = useStore((s) => s.marketInfo)
55-
const marketIncentiveInfo = useStore((s) => s.marketIncentiveInfo)
5654
const migrationInProgress = useStore((s) => s.migrationInProgress)
5755
const redBankState = useStore((s) => s.redBankState)
5856
const rpc = useStore((s) => s.networkConfig.rpcUrl)
@@ -145,7 +143,6 @@ export const CommonContainer = ({ children }: CommonContainerProps) => {
145143
userBalancesState,
146144
exchangeRates,
147145
marketInfo,
148-
marketIncentiveInfo,
149146
userDebts,
150147
userDeposits,
151148
whitelistedAssets,
@@ -168,7 +165,7 @@ export const CommonContainer = ({ children }: CommonContainerProps) => {
168165
useUserDebt()
169166
useUserCollaterals()
170167
useMarsOracle()
171-
useSpotPrice(MARS_SYMBOL)
168+
useMarsPrice()
172169
useDepositAndDebt()
173170
useRedBank()
174171
usePythVaa()

src/components/common/CosmosWalletConnectProvider/CosmosWalletConnectProvider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ export const CosmosWalletConnectProvider = ({ children }: Props) => {
3030
rpc: networkConfig.rpcUrl,
3131
rest: networkConfig.restUrl,
3232
}}
33+
walletConnectProjectId='d93fdffb159bae5ec87d8fee4cdbb045'
3334
chainIds={supportedChains}
3435
closeIcon={<SVG.Close />}
3536
defaultChainId={currentNetwork}
3637
enabledWallets={[
3738
WalletID.Keplr,
3839
WalletID.Xdefi,
39-
WalletID.StationWallet,
40+
WalletID.Station,
4041
WalletID.Leap,
4142
WalletID.Cosmostation,
43+
WalletID.Vectis,
4244
WalletID.KeplrMobile,
4345
WalletID.CosmostationMobile,
4446
]}

src/components/common/Header/ChainSelect.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export const ChainSelect = () => {
6565
exchangeRates: [],
6666
assetPricesUSD: [],
6767
marketAssetLiquidity: [],
68-
marketIncentiveInfo: [],
6968
marketInfo: [],
7069
userIcns: undefined,
7170
redBankAssets: [],

src/components/common/Header/ConnectedButton.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { findByDenom } from 'functions'
55
import { useUserBalance } from 'hooks/queries'
66
import { formatValue, lookup } from 'libs/parse'
77
import { truncate } from 'libs/text'
8-
import { useCallback, useEffect, useState } from 'react'
8+
import { useCallback, useEffect, useMemo, useState } from 'react'
99
import { useTranslation } from 'react-i18next'
1010
import useClipboard from 'react-use-clipboard'
1111
import useStore from 'store'
@@ -61,6 +61,11 @@ export const ConnectedButton = () => {
6161
baseCurrency.decimals,
6262
)
6363

64+
const [connectedWalletAddress, connectedWalletIsLedger] = useMemo(() => {
65+
if (!connectedWallet?.account) return ['', false]
66+
return [connectedWallet.account.address, connectedWallet.account.isLedger]
67+
}, [connectedWallet])
68+
6469
useEffect(() => {
6570
if (!chainInfo) return
6671
setIsTestnet(
@@ -71,18 +76,18 @@ export const ConnectedButton = () => {
7176
}, [chainInfo])
7277

7378
useEffect(() => {
74-
if (userWalletAddress === connectedWallet?.account.address) return
79+
if (userWalletAddress === connectedWalletAddress) return
7580
useStore.setState({
76-
isLedger: !!connectedWallet?.account.isLedger,
77-
userWalletAddress: connectedWallet?.account.address,
81+
isLedger: connectedWalletIsLedger,
82+
userWalletAddress: connectedWalletAddress,
7883
marketAssetLiquidity: [],
7984
marketInfo: [],
8085
userIcns: undefined,
8186
redBankAssets: [],
8287
redBankState: State.INITIALISING,
8388
userBalancesState: State.INITIALISING,
8489
})
85-
}, [connectedWallet?.account.address, userWalletAddress])
90+
}, [connectedWalletAddress, connectedWalletIsLedger, userWalletAddress])
8691

8792
return (
8893
<div className={styles.wrapper}>

src/components/common/Header/IncentivesButton.tsx

Lines changed: 76 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ import {
1010
Tooltip,
1111
TxLink,
1212
} from 'components/common'
13-
import { MARS_DECIMALS, MARS_SYMBOL } from 'constants/appConstants'
13+
import { MARS_SYMBOL } from 'constants/appConstants'
14+
import { findByDenom } from 'functions'
1415
import { getClaimUserRewardsMsgOptions } from 'functions/messages'
1516
import { useEstimateFee } from 'hooks/queries'
16-
import { lookup, lookupDenomBySymbol, lookupSymbol } from 'libs/parse'
17+
import { lookup, lookupSymbol } from 'libs/parse'
1718
import { useCallback, useEffect, useMemo, useState } from 'react'
1819
import { useTranslation } from 'react-i18next'
1920
import useStore from 'store'
21+
import { State } from 'types/enums'
2022
import { QUERY_KEYS } from 'types/enums/queryKeys'
2123

2224
import styles from './IncentivesButton.module.scss'
@@ -32,9 +34,13 @@ export const IncentivesButton = () => {
3234
// STORE STATE
3335
// ---------------
3436
const client = useStore((s) => s.client)
37+
const whitelistedAssets = useStore((s) => s.whitelistedAssets)
3538
const otherAssets = useStore((s) => s.otherAssets)
3639
const userWalletAddress = useStore((s) => s.userWalletAddress)
40+
const networkConfig = useStore((s) => s.networkConfig)
3741
const unclaimedRewards = useStore((s) => s.userUnclaimedRewards)
42+
const convertToDisplayCurrency = useStore((s) => s.convertToDisplayCurrency)
43+
const marsPriceState = useStore((s) => s.marsPriceState)
3844
const incentivesContractAddress = useStore((s) => s.networkConfig.contracts.incentives)
3945
const chainInfo = useStore((s) => s.chainInfo)
4046
const executeMsg = useStore((s) => s.executeMsg)
@@ -49,12 +55,13 @@ export const IncentivesButton = () => {
4955
const [response, setResponse] = useState<TxBroadcastResult>()
5056
const [error, setError] = useState<string>()
5157
const [hasUnclaimedRewards, setHasUnclaimedRewards] = useState(false)
58+
const [unclaimedRewardsValue, setUnclaimedRewardsValue] = useState(0)
5259

5360
// ---------------
5461
// LOCAL VARIABLES
5562
// ---------------
56-
const marsDenom = lookupDenomBySymbol(MARS_SYMBOL, otherAssets)
5763
const explorerUrl = chainInfo && SimpleChainInfoList[chainInfo.chainId as ChainInfoID].explorer
64+
const assets = [...whitelistedAssets, ...otherAssets]
5865

5966
// ---------------
6067
// FUNCTIONS
@@ -66,8 +73,18 @@ export const IncentivesButton = () => {
6673
}, [])
6774

6875
useEffect(() => {
69-
setHasUnclaimedRewards(Number(unclaimedRewards) > 0)
70-
}, [unclaimedRewards])
76+
let rewardsValue = 0
77+
let rewardsAmount = 0
78+
79+
if (marsPriceState !== State.READY) return
80+
unclaimedRewards.forEach((reward) => {
81+
rewardsValue += convertToDisplayCurrency(reward)
82+
rewardsAmount += Number(reward.amount)
83+
})
84+
85+
setUnclaimedRewardsValue(rewardsValue)
86+
setHasUnclaimedRewards(rewardsAmount > 0)
87+
}, [unclaimedRewards, convertToDisplayCurrency, marsPriceState])
7188

7289
const txMsgOptions = useMemo(() => {
7390
if (!hasUnclaimedRewards) return
@@ -137,31 +154,39 @@ export const IncentivesButton = () => {
137154
}
138155

139156
const transactionHash = response?.hash || ''
140-
141157
if (!userWalletAddress) return null
142158

143159
return (
144160
<div className={styles.wrapper}>
145161
<button
146162
className={classNames(
147-
Number(unclaimedRewards) > 1000000
148-
? `${styles.button} ${styles.buttonHighlight}`
149-
: styles.button,
163+
unclaimedRewardsValue > 1 ? `${styles.button} ${styles.buttonHighlight}` : styles.button,
150164
)}
151165
onClick={() => {
152166
setShowDetails(!showDetails)
153167
}}
154168
>
155-
<SVG.Logo />
156-
<span>
169+
{networkConfig.hasMultiAssetIncentives ? (
157170
<AnimatedNumber
158-
amount={Number(unclaimedRewards) / 1e6}
171+
amount={unclaimedRewardsValue}
159172
minDecimals={2}
160173
maxDecimals={2}
161-
className={styles.marsAmount}
174+
prefix='$'
162175
/>
163-
{MARS_SYMBOL}
164-
</span>
176+
) : (
177+
<>
178+
<SVG.Logo />
179+
<span>
180+
<AnimatedNumber
181+
className={styles.marsAmount}
182+
amount={Number(unclaimedRewards[0]?.amount ?? 0) / 1e6}
183+
minDecimals={2}
184+
maxDecimals={2}
185+
/>
186+
</span>
187+
{MARS_SYMBOL}
188+
</>
189+
)}
165190
</button>
166191

167192
{showDetails && (
@@ -181,36 +206,48 @@ export const IncentivesButton = () => {
181206
<TxLink hash={transactionHash} link={`${explorerUrl}/txs/${transactionHash}`} />
182207
</div>
183208
) : (
184-
<div className={styles.container}>
185-
<div className={styles.position}>
186-
<div className={styles.label}>
187-
<p className={styles.token}>{lookupSymbol(marsDenom, otherAssets)}</p>
188-
<p className={styles.subhead}>{t('redbank.redBankRewards')}</p>
189-
</div>
190-
<div className={styles.value}>
191-
<AnimatedNumber
192-
className={styles.tokenAmount}
193-
amount={lookup(Number(unclaimedRewards) || 0, MARS_SYMBOL, MARS_DECIMALS)}
194-
maxDecimals={MARS_DECIMALS}
195-
minDecimals={2}
196-
/>
197-
<DisplayCurrency
198-
className={styles.tokenValue}
199-
coin={{
200-
amount: unclaimedRewards,
201-
denom: marsDenom,
202-
}}
203-
/>
204-
</div>
205-
</div>
206-
</div>
209+
<>
210+
{unclaimedRewards.map((rewards, index) => {
211+
const asset = findByDenom(assets, rewards.denom)
212+
if (!asset) return null
213+
return (
214+
<div className={styles.container} key={index}>
215+
<div className={styles.position}>
216+
<div className={styles.label}>
217+
<p className={styles.token}>{lookupSymbol(asset.denom, assets)}</p>
218+
<p className={styles.subhead}>{t('redbank.redBankRewards')}</p>
219+
</div>
220+
<div className={styles.value}>
221+
<AnimatedNumber
222+
className={styles.tokenAmount}
223+
amount={lookup(
224+
Number(rewards.amount) || 0,
225+
asset.symbol,
226+
asset.decimals,
227+
)}
228+
maxDecimals={asset.decimals}
229+
minDecimals={2}
230+
/>
231+
<DisplayCurrency
232+
className={styles.tokenValue}
233+
coin={{
234+
amount: rewards.amount,
235+
denom: asset.denom,
236+
}}
237+
/>
238+
</div>
239+
</div>
240+
</div>
241+
)
242+
})}
243+
</>
207244
)}
208245
<div className={styles.claimButton}>
209246
<Button
210247
disabled={disabled}
211248
showProgressIndicator={fetching}
212249
text={
213-
Number(unclaimedRewards) > 0 && !disabled
250+
hasUnclaimedRewards && !disabled
214251
? t('incentives.claimRewards')
215252
: t('incentives.nothingToClaim')
216253
}

0 commit comments

Comments
 (0)