Remove Pyth for testnet/devnet (#495)
* vaults: multiple bug fixes * fixed relative import
This commit is contained in:
parent
6c193c1a9b
commit
851aeac233
@ -1,33 +0,0 @@
|
|||||||
import { getVaultMetaData } from 'utils/vaults'
|
|
||||||
import * as constants from 'constants/env'
|
|
||||||
|
|
||||||
jest.mock('constants/env', () => ({
|
|
||||||
__esModule: true,
|
|
||||||
get IS_TESTNET() {
|
|
||||||
return true
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
|
||||||
describe('getVaultMetaData()', () => {
|
|
||||||
afterAll(() => {
|
|
||||||
jest.restoreAllMocks()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns the MAINNET vault of given address WHEN environment configured to mainnet', () => {
|
|
||||||
jest.spyOn(constants, 'IS_TESTNET', 'get').mockReturnValue(false)
|
|
||||||
|
|
||||||
const testAddress = 'osmo1g3kmqpp8608szfp0pdag3r6z85npph7wmccat8lgl3mp407kv73qlj7qwp'
|
|
||||||
const testVaultName = 'OSMO-ATOM'
|
|
||||||
|
|
||||||
expect(getVaultMetaData(testAddress)?.name).toBe(testVaultName)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns the TESTNET vault of given address WHEN environment configured to testnet', () => {
|
|
||||||
jest.spyOn(constants, 'IS_TESTNET', 'get').mockReturnValue(true)
|
|
||||||
|
|
||||||
const testAddress = 'osmo1m45ap4rq4m2mfjkcqu9ks9mxmyx2hvx0cdca9sjmrg46q7lghzqqhxxup5'
|
|
||||||
const testVaultName = 'OSMO-ATOM'
|
|
||||||
|
|
||||||
expect(getVaultMetaData(testAddress)?.name).toBe(testVaultName)
|
|
||||||
})
|
|
||||||
})
|
|
@ -1,9 +1,9 @@
|
|||||||
|
import getPrice from 'api/prices/getPrice'
|
||||||
import { ENV } from 'constants/env'
|
import { ENV } from 'constants/env'
|
||||||
|
import { BN_ONE } from 'constants/math'
|
||||||
|
import { BNCoin } from 'types/classes/BNCoin'
|
||||||
import { byDenom, byTokenDenom, partition } from 'utils/array'
|
import { byDenom, byTokenDenom, partition } from 'utils/array'
|
||||||
import { BN } from 'utils/helpers'
|
import { BN } from 'utils/helpers'
|
||||||
import getPrice from 'api/prices/getPrice'
|
|
||||||
import { BNCoin } from 'types/classes/BNCoin'
|
|
||||||
import { BN_ONE } from 'constants/math'
|
|
||||||
|
|
||||||
interface PoolToken {
|
interface PoolToken {
|
||||||
denom: string
|
denom: string
|
||||||
@ -33,9 +33,8 @@ export default async function getPoolPrice(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getAssetRate = async (asset: Asset) => {
|
const getAssetRate = async (asset: Asset) => {
|
||||||
const url = `${ENV.MAINNET_REST_API}osmosis/gamm/v1beta1/pools/${asset.poolId}`
|
const url = `${ENV.URL_REST}osmosis/gamm/v1beta1/pools/${asset.poolId}`
|
||||||
const response = await fetch(url).then((res) => res.json())
|
const response = await fetch(url).then((res) => res.json())
|
||||||
|
|
||||||
return calculateSpotPrice(response.pool.pool_assets, asset)
|
return calculateSpotPrice(response.pool.pool_assets, asset)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +43,9 @@ const calculateSpotPrice = (poolAssets: PoolAsset[], asset: Asset): [BigNumber,
|
|||||||
|
|
||||||
const numerator = BN(assetIn.token.amount).dividedBy(assetIn.weight)
|
const numerator = BN(assetIn.token.amount).dividedBy(assetIn.weight)
|
||||||
const denominator = BN(assetOut.token.amount).dividedBy(assetOut.weight)
|
const denominator = BN(assetOut.token.amount).dividedBy(assetOut.weight)
|
||||||
const spotPrice = BN_ONE.dividedBy(numerator.dividedBy(denominator))
|
|
||||||
|
const additionalDecimals = asset.decimals - 6
|
||||||
|
const spotPrice = BN_ONE.dividedBy(numerator.dividedBy(denominator)).shiftedBy(additionalDecimals)
|
||||||
|
|
||||||
return [spotPrice, assetOut]
|
return [spotPrice, assetOut]
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import getOraclePrices from 'api/prices/getOraclePrices'
|
import getOraclePrices from 'api/prices/getOraclePrices'
|
||||||
import getPoolPrice from 'api/prices/getPoolPrice'
|
import getPoolPrice from 'api/prices/getPoolPrice'
|
||||||
import fetchPythPrices from 'api/prices/getPythPrices'
|
import fetchPythPrices from 'api/prices/getPythPrices'
|
||||||
|
import { ENV } from 'constants/env'
|
||||||
import { BNCoin } from 'types/classes/BNCoin'
|
import { BNCoin } from 'types/classes/BNCoin'
|
||||||
|
import { NETWORK } from 'types/enums/network'
|
||||||
import { partition } from 'utils/array'
|
import { partition } from 'utils/array'
|
||||||
import { getAssetsMustHavePriceInfo } from 'utils/assets'
|
import { getAssetsMustHavePriceInfo } from 'utils/assets'
|
||||||
|
|
||||||
@ -19,6 +21,7 @@ export default async function getPrices(): Promise<BNCoin[]> {
|
|||||||
])
|
])
|
||||||
).flat()
|
).flat()
|
||||||
const poolPrices = await requestPoolPrices(assetsWithPoolIds, pythAndOraclePrices)
|
const poolPrices = await requestPoolPrices(assetsWithPoolIds, pythAndOraclePrices)
|
||||||
|
|
||||||
return [...pythAndOraclePrices, ...poolPrices, usdPrice]
|
return [...pythAndOraclePrices, ...poolPrices, usdPrice]
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.error(ex)
|
console.error(ex)
|
||||||
@ -27,8 +30,9 @@ export default async function getPrices(): Promise<BNCoin[]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function requestPythPrices(assets: Asset[]): Promise<BNCoin[]> {
|
async function requestPythPrices(assets: Asset[]): Promise<BNCoin[]> {
|
||||||
const priceFeedIds = assets.map((a) => a.pythPriceFeedId) as string[]
|
if (!assets.length) return []
|
||||||
|
|
||||||
|
const priceFeedIds = assets.map((a) => a.pythPriceFeedId) as string[]
|
||||||
return await fetchPythPrices(...priceFeedIds).then(mapResponseToBnCoin(assets))
|
return await fetchPythPrices(...priceFeedIds).then(mapResponseToBnCoin(assets))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,13 +48,16 @@ const mapResponseToBnCoin = (assets: Asset[]) => (prices: BigNumber[]) =>
|
|||||||
)
|
)
|
||||||
|
|
||||||
function separateAssetsByPriceSources(assets: Asset[]) {
|
function separateAssetsByPriceSources(assets: Asset[]) {
|
||||||
|
// Only fetch Pyth prices for mainnet
|
||||||
const [assetsWithPythPriceFeedId, assetsWithoutPythPriceFeedId] = partition(
|
const [assetsWithPythPriceFeedId, assetsWithoutPythPriceFeedId] = partition(
|
||||||
assets,
|
assets,
|
||||||
(asset) => !!asset.pythPriceFeedId,
|
(asset) => !!asset.pythPriceFeedId && ENV.NETWORK === NETWORK.MAINNET,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Don't get oracle price if it's not mainnet and there is a poolId
|
||||||
const [assetsWithOraclePrice, assetsWithoutOraclePrice] = partition(
|
const [assetsWithOraclePrice, assetsWithoutOraclePrice] = partition(
|
||||||
assetsWithoutPythPriceFeedId,
|
assetsWithoutPythPriceFeedId,
|
||||||
(asset) => asset.hasOraclePrice,
|
(asset) => (asset.hasOraclePrice && ENV.NETWORK === NETWORK.MAINNET) || !asset.poolId,
|
||||||
)
|
)
|
||||||
const assetsWithPoolId = assetsWithoutOraclePrice.filter((asset) => !!asset.poolId)
|
const assetsWithPoolId = assetsWithoutOraclePrice.filter((asset) => !!asset.poolId)
|
||||||
|
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
import { convertAprToApy } from 'utils/parsers'
|
|
||||||
import getAprs from 'api/vaults/getVaultAprs'
|
import getAprs from 'api/vaults/getVaultAprs'
|
||||||
import { getVaultConfigs } from 'api/vaults/getVaultConfigs'
|
import { getVaultConfigs } from 'api/vaults/getVaultConfigs'
|
||||||
import { getVaultUtilizations } from 'api/vaults/getVaultUtilizations'
|
import { getVaultUtilizations } from 'api/vaults/getVaultUtilizations'
|
||||||
import { ENV } from 'constants/env'
|
import { ENV } from 'constants/env'
|
||||||
import { TESTNET_VAULTS_META_DATA, VAULTS_META_DATA } from 'constants/vaults'
|
import { TESTNET_VAULTS_META_DATA, VAULTS_META_DATA } from 'constants/vaults'
|
||||||
|
import { NETWORK } from 'types/enums/network'
|
||||||
import { BN } from 'utils/helpers'
|
import { BN } from 'utils/helpers'
|
||||||
|
import { convertAprToApy } from 'utils/parsers'
|
||||||
|
|
||||||
export default async function getVaults(): Promise<Vault[]> {
|
export default async function getVaults(): Promise<Vault[]> {
|
||||||
const vaultConfigs = await getVaultConfigs()
|
const vaultConfigs = await getVaultConfigs()
|
||||||
const $vaultUtilizations = getVaultUtilizations(vaultConfigs)
|
const $vaultUtilizations = getVaultUtilizations(vaultConfigs)
|
||||||
const $aprs = getAprs()
|
const $aprs = getAprs()
|
||||||
const vaultMetaDatas = ENV.NETWORK === 'testnet' ? TESTNET_VAULTS_META_DATA : VAULTS_META_DATA
|
const vaultMetaDatas =
|
||||||
|
ENV.NETWORK === NETWORK.TESTNET ? TESTNET_VAULTS_META_DATA : VAULTS_META_DATA
|
||||||
|
|
||||||
const vaults: Vault[] = []
|
const vaults: Vault[] = []
|
||||||
await Promise.all([$vaultUtilizations, $aprs]).then(([vaultUtilizations, aprs]) => {
|
await Promise.all([$vaultUtilizations, $aprs]).then(([vaultUtilizations, aprs]) => {
|
||||||
|
@ -3,12 +3,13 @@ import { Suspense, useMemo } from 'react'
|
|||||||
import Card from 'components/Card'
|
import Card from 'components/Card'
|
||||||
import { VaultTable } from 'components/Earn/Farm/VaultTable'
|
import { VaultTable } from 'components/Earn/Farm/VaultTable'
|
||||||
import VaultUnlockBanner from 'components/Earn/Farm/VaultUnlockBanner'
|
import VaultUnlockBanner from 'components/Earn/Farm/VaultUnlockBanner'
|
||||||
import { IS_TESTNET } from 'constants/env'
|
import { ENV } from 'constants/env'
|
||||||
import { BN_ZERO } from 'constants/math'
|
import { BN_ZERO } from 'constants/math'
|
||||||
import { TESTNET_VAULTS_META_DATA, VAULTS_META_DATA } from 'constants/vaults'
|
import { TESTNET_VAULTS_META_DATA, VAULTS_META_DATA } from 'constants/vaults'
|
||||||
import useAccountId from 'hooks/useAccountId'
|
import useAccountId from 'hooks/useAccountId'
|
||||||
import useDepositedVaults from 'hooks/useDepositedVaults'
|
import useDepositedVaults from 'hooks/useDepositedVaults'
|
||||||
import useVaults from 'hooks/useVaults'
|
import useVaults from 'hooks/useVaults'
|
||||||
|
import { NETWORK } from 'types/enums/network'
|
||||||
import { VaultStatus } from 'types/enums/vault'
|
import { VaultStatus } from 'types/enums/vault'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -21,7 +22,8 @@ function Content(props: Props) {
|
|||||||
const { data: depositedVaults } = useDepositedVaults(accountId || '')
|
const { data: depositedVaults } = useDepositedVaults(accountId || '')
|
||||||
const isAvailable = props.type === 'available'
|
const isAvailable = props.type === 'available'
|
||||||
|
|
||||||
const vaultsMetaData = IS_TESTNET ? TESTNET_VAULTS_META_DATA : VAULTS_META_DATA
|
const vaultsMetaData =
|
||||||
|
ENV.NETWORK === NETWORK.TESTNET ? TESTNET_VAULTS_META_DATA : VAULTS_META_DATA
|
||||||
|
|
||||||
const { deposited, available } = useMemo(() => {
|
const { deposited, available } = useMemo(() => {
|
||||||
return vaultsMetaData.reduce(
|
return vaultsMetaData.reduce(
|
||||||
@ -70,7 +72,7 @@ function Content(props: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Fallback() {
|
function Fallback() {
|
||||||
const vaults = IS_TESTNET ? TESTNET_VAULTS_META_DATA : VAULTS_META_DATA
|
const vaults = ENV.NETWORK === NETWORK.TESTNET ? TESTNET_VAULTS_META_DATA : VAULTS_META_DATA
|
||||||
const mockVaults: Vault[] = vaults.map((vault) => ({
|
const mockVaults: Vault[] = vaults.map((vault) => ({
|
||||||
...vault,
|
...vault,
|
||||||
apy: null,
|
apy: null,
|
||||||
|
@ -10,11 +10,12 @@ import WalletFetchBalancesAndAccounts from 'components/Wallet/WalletFetchBalance
|
|||||||
import WalletSelect from 'components/Wallet/WalletSelect'
|
import WalletSelect from 'components/Wallet/WalletSelect'
|
||||||
import { BRIDGES } from 'constants/bridges'
|
import { BRIDGES } from 'constants/bridges'
|
||||||
import { CHAINS } from 'constants/chains'
|
import { CHAINS } from 'constants/chains'
|
||||||
import { ENV, IS_TESTNET } from 'constants/env'
|
import { ENV } from 'constants/env'
|
||||||
import useCurrentWallet from 'hooks/useCurrentWallet'
|
import useCurrentWallet from 'hooks/useCurrentWallet'
|
||||||
import useToggle from 'hooks/useToggle'
|
import useToggle from 'hooks/useToggle'
|
||||||
import useWalletBalances from 'hooks/useWalletBalances'
|
import useWalletBalances from 'hooks/useWalletBalances'
|
||||||
import useStore from 'store'
|
import useStore from 'store'
|
||||||
|
import { NETWORK } from 'types/enums/network'
|
||||||
import { byDenom } from 'utils/array'
|
import { byDenom } from 'utils/array'
|
||||||
import { getBaseAsset } from 'utils/assets'
|
import { getBaseAsset } from 'utils/assets'
|
||||||
import { defaultFee } from 'utils/constants'
|
import { defaultFee } from 'utils/constants'
|
||||||
@ -87,7 +88,7 @@ export default function WalletBridges() {
|
|||||||
<Bridge key={bridge.name} {...bridge} />
|
<Bridge key={bridge.name} {...bridge} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{ENV.NETWORK !== 'mainnet' && (
|
{ENV.NETWORK !== NETWORK.MAINNET && (
|
||||||
<div className='flex flex-wrap w-full gap-3'>
|
<div className='flex flex-wrap w-full gap-3'>
|
||||||
<Text size='lg' className='mt-4 text-white'>
|
<Text size='lg' className='mt-4 text-white'>
|
||||||
Need Testnet Funds?
|
Need Testnet Funds?
|
||||||
@ -96,7 +97,7 @@ export default function WalletBridges() {
|
|||||||
key='osmosis-faucet'
|
key='osmosis-faucet'
|
||||||
name='Osmosis Testnet Faucet'
|
name='Osmosis Testnet Faucet'
|
||||||
url={
|
url={
|
||||||
IS_TESTNET
|
ENV.NETWORK === NETWORK.TESTNET
|
||||||
? 'https://faucet.osmotest5.osmosis.zone/'
|
? 'https://faucet.osmotest5.osmosis.zone/'
|
||||||
: 'https://faucet.devnet.osmosis.zone/'
|
: 'https://faucet.devnet.osmosis.zone/'
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ import useCurrentWallet from 'hooks/useCurrentWallet'
|
|||||||
import useToggle from 'hooks/useToggle'
|
import useToggle from 'hooks/useToggle'
|
||||||
import useWalletBalances from 'hooks/useWalletBalances'
|
import useWalletBalances from 'hooks/useWalletBalances'
|
||||||
import useStore from 'store'
|
import useStore from 'store'
|
||||||
|
import { NETWORK } from 'types/enums/network'
|
||||||
import { ChainInfoID } from 'types/enums/wallet'
|
import { ChainInfoID } from 'types/enums/wallet'
|
||||||
import { getBaseAsset, getEnabledMarketAssets } from 'utils/assets'
|
import { getBaseAsset, getEnabledMarketAssets } from 'utils/assets'
|
||||||
import { truncate } from 'utils/formatters'
|
import { truncate } from 'utils/formatters'
|
||||||
@ -91,7 +92,7 @@ export default function WalletConnectedButton() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={'relative'}>
|
<div className={'relative'}>
|
||||||
{ENV.NETWORK !== 'mainnet' && (
|
{ENV.NETWORK !== NETWORK.MAINNET && (
|
||||||
<Text
|
<Text
|
||||||
className='absolute -right-2 -top-2.5 z-10 rounded-sm p-0.5 px-2 gradient-primary-to-secondary'
|
className='absolute -right-2 -top-2.5 z-10 rounded-sm p-0.5 px-2 gradient-primary-to-secondary'
|
||||||
size='3xs'
|
size='3xs'
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { IS_TESTNET } from 'constants/env'
|
import { ENV } from 'constants/env'
|
||||||
|
|
||||||
|
import { NETWORK } from 'types/enums/network'
|
||||||
|
|
||||||
export const MARS_MAINNET_DENOM =
|
export const MARS_MAINNET_DENOM =
|
||||||
'ibc/573FCD90FACEE750F55A8864EF7D38265F07E5A9273FA0E8DAFD39951332B580'
|
'ibc/573FCD90FACEE750F55A8864EF7D38265F07E5A9273FA0E8DAFD39951332B580'
|
||||||
@ -24,9 +26,10 @@ export const ASSETS: Asset[] = [
|
|||||||
symbol: 'ATOM',
|
symbol: 'ATOM',
|
||||||
name: 'Atom',
|
name: 'Atom',
|
||||||
id: 'ATOM',
|
id: 'ATOM',
|
||||||
denom: IS_TESTNET
|
denom:
|
||||||
? 'ibc/A8C2D23A1E6F95DA4E48BA349667E322BD7A6C996D8A4AAE8BA72E190F3D1477'
|
ENV.NETWORK === NETWORK.TESTNET
|
||||||
: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
|
? 'ibc/A8C2D23A1E6F95DA4E48BA349667E322BD7A6C996D8A4AAE8BA72E190F3D1477'
|
||||||
|
: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
|
||||||
mainnetDenom: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
|
mainnetDenom: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
|
||||||
color: '#6f7390',
|
color: '#6f7390',
|
||||||
logo: '/images/tokens/atom.svg',
|
logo: '/images/tokens/atom.svg',
|
||||||
@ -48,10 +51,10 @@ export const ASSETS: Asset[] = [
|
|||||||
color: '#e50571',
|
color: '#e50571',
|
||||||
logo: '/images/tokens/statom.svg',
|
logo: '/images/tokens/statom.svg',
|
||||||
decimals: 6,
|
decimals: 6,
|
||||||
hasOraclePrice: !IS_TESTNET,
|
hasOraclePrice: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isEnabled: !IS_TESTNET,
|
isEnabled: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isMarket: !IS_TESTNET,
|
isMarket: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isDisplayCurrency: !IS_TESTNET,
|
isDisplayCurrency: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isAutoLendEnabled: false,
|
isAutoLendEnabled: false,
|
||||||
poolId: 803,
|
poolId: 803,
|
||||||
},
|
},
|
||||||
@ -65,9 +68,9 @@ export const ASSETS: Asset[] = [
|
|||||||
logo: '/images/tokens/axlwbtc.svg',
|
logo: '/images/tokens/axlwbtc.svg',
|
||||||
decimals: 8,
|
decimals: 8,
|
||||||
hasOraclePrice: true,
|
hasOraclePrice: true,
|
||||||
isEnabled: !IS_TESTNET,
|
isEnabled: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isMarket: !IS_TESTNET,
|
isMarket: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isDisplayCurrency: !IS_TESTNET,
|
isDisplayCurrency: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isAutoLendEnabled: true,
|
isAutoLendEnabled: true,
|
||||||
pythPriceFeedId: 'e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
|
pythPriceFeedId: 'e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
|
||||||
poolId: 712,
|
poolId: 712,
|
||||||
@ -82,9 +85,9 @@ export const ASSETS: Asset[] = [
|
|||||||
logo: '/images/tokens/axlweth.svg',
|
logo: '/images/tokens/axlweth.svg',
|
||||||
decimals: 18,
|
decimals: 18,
|
||||||
hasOraclePrice: true,
|
hasOraclePrice: true,
|
||||||
isEnabled: !IS_TESTNET,
|
isEnabled: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isMarket: !IS_TESTNET,
|
isMarket: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isDisplayCurrency: !IS_TESTNET,
|
isDisplayCurrency: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isAutoLendEnabled: true,
|
isAutoLendEnabled: true,
|
||||||
pythPriceFeedId: 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
|
pythPriceFeedId: 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
|
||||||
poolId: 704,
|
poolId: 704,
|
||||||
@ -93,9 +96,10 @@ export const ASSETS: Asset[] = [
|
|||||||
symbol: 'MARS',
|
symbol: 'MARS',
|
||||||
name: 'Mars',
|
name: 'Mars',
|
||||||
id: 'MARS',
|
id: 'MARS',
|
||||||
denom: IS_TESTNET
|
denom:
|
||||||
? 'ibc/DB9D326CF53EA07610C394D714D78F8BB4DC7E312D4213193791A9046BF45E20'
|
ENV.NETWORK === NETWORK.TESTNET
|
||||||
: MARS_MAINNET_DENOM,
|
? 'ibc/DB9D326CF53EA07610C394D714D78F8BB4DC7E312D4213193791A9046BF45E20'
|
||||||
|
: MARS_MAINNET_DENOM,
|
||||||
mainnetDenom: MARS_MAINNET_DENOM,
|
mainnetDenom: MARS_MAINNET_DENOM,
|
||||||
color: '#a03b45',
|
color: '#a03b45',
|
||||||
logo: '/images/tokens/mars.svg',
|
logo: '/images/tokens/mars.svg',
|
||||||
@ -110,9 +114,10 @@ export const ASSETS: Asset[] = [
|
|||||||
symbol: 'USDC.axl',
|
symbol: 'USDC.axl',
|
||||||
name: 'Axelar USDC',
|
name: 'Axelar USDC',
|
||||||
id: 'axlUSDC',
|
id: 'axlUSDC',
|
||||||
denom: IS_TESTNET
|
denom:
|
||||||
? 'ibc/6F34E1BD664C36CE49ACC28E60D62559A5F96C4F9A6CCE4FC5A67B2852E24CFE'
|
ENV.NETWORK === NETWORK.TESTNET
|
||||||
: 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858',
|
? 'ibc/6F34E1BD664C36CE49ACC28E60D62559A5F96C4F9A6CCE4FC5A67B2852E24CFE'
|
||||||
|
: 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858',
|
||||||
mainnetDenom: 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858',
|
mainnetDenom: 'ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858',
|
||||||
color: '#478edc',
|
color: '#478edc',
|
||||||
logo: '/images/tokens/axlusdc.svg',
|
logo: '/images/tokens/axlusdc.svg',
|
||||||
@ -136,9 +141,9 @@ export const ASSETS: Asset[] = [
|
|||||||
logo: '/images/tokens/axl.svg',
|
logo: '/images/tokens/axl.svg',
|
||||||
decimals: 6,
|
decimals: 6,
|
||||||
hasOraclePrice: true,
|
hasOraclePrice: true,
|
||||||
isEnabled: !IS_TESTNET,
|
isEnabled: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isMarket: !IS_TESTNET,
|
isMarket: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isDisplayCurrency: !IS_TESTNET,
|
isDisplayCurrency: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
isAutoLendEnabled: false,
|
isAutoLendEnabled: false,
|
||||||
pythPriceFeedId: '60144b1d5c9e9851732ad1d9760e3485ef80be39b984f6bf60f82b28a2b7f126',
|
pythPriceFeedId: '60144b1d5c9e9851732ad1d9760e3485ef80be39b984f6bf60f82b28a2b7f126',
|
||||||
poolId: 812,
|
poolId: 812,
|
||||||
@ -162,9 +167,9 @@ export const ASSETS: Asset[] = [
|
|||||||
{
|
{
|
||||||
symbol: 'OSMO-ATOM',
|
symbol: 'OSMO-ATOM',
|
||||||
name: 'OSMO-ATOM LP',
|
name: 'OSMO-ATOM LP',
|
||||||
id: IS_TESTNET ? 'gamm/pool/12' : 'gamm/pool/1',
|
id: ENV.NETWORK === NETWORK.TESTNET ? 'gamm/pool/12' : 'gamm/pool/1',
|
||||||
denom: IS_TESTNET ? 'gamm/pool/12' : 'gamm/pool/1',
|
denom: ENV.NETWORK === NETWORK.TESTNET ? 'gamm/pool/12' : 'gamm/pool/1',
|
||||||
mainnetDenom: IS_TESTNET ? 'gamm/pool/12' : 'gamm/pool/1',
|
mainnetDenom: ENV.NETWORK === NETWORK.TESTNET ? 'gamm/pool/12' : 'gamm/pool/1',
|
||||||
color: '',
|
color: '',
|
||||||
logo: '',
|
logo: '',
|
||||||
decimals: 6,
|
decimals: 6,
|
||||||
@ -184,8 +189,8 @@ export const ASSETS: Asset[] = [
|
|||||||
decimals: 6,
|
decimals: 6,
|
||||||
isEnabled: false,
|
isEnabled: false,
|
||||||
isMarket: false,
|
isMarket: false,
|
||||||
hasOraclePrice: !IS_TESTNET,
|
hasOraclePrice: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
forceFetchPrice: !IS_TESTNET,
|
forceFetchPrice: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
symbol: 'OSMO-WETH.axl',
|
symbol: 'OSMO-WETH.axl',
|
||||||
@ -198,8 +203,8 @@ export const ASSETS: Asset[] = [
|
|||||||
decimals: 6,
|
decimals: 6,
|
||||||
isEnabled: false,
|
isEnabled: false,
|
||||||
isMarket: false,
|
isMarket: false,
|
||||||
hasOraclePrice: !IS_TESTNET,
|
hasOraclePrice: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
forceFetchPrice: !IS_TESTNET,
|
forceFetchPrice: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
symbol: 'OSMO-WBTC.axl',
|
symbol: 'OSMO-WBTC.axl',
|
||||||
@ -212,8 +217,8 @@ export const ASSETS: Asset[] = [
|
|||||||
decimals: 6,
|
decimals: 6,
|
||||||
isEnabled: false,
|
isEnabled: false,
|
||||||
isMarket: false,
|
isMarket: false,
|
||||||
hasOraclePrice: !IS_TESTNET,
|
hasOraclePrice: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
forceFetchPrice: !IS_TESTNET,
|
forceFetchPrice: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
symbol: 'stATOM-ATOM',
|
symbol: 'stATOM-ATOM',
|
||||||
@ -226,7 +231,7 @@ export const ASSETS: Asset[] = [
|
|||||||
decimals: 6,
|
decimals: 6,
|
||||||
isEnabled: false,
|
isEnabled: false,
|
||||||
isMarket: false,
|
isMarket: false,
|
||||||
hasOraclePrice: !IS_TESTNET,
|
hasOraclePrice: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
forceFetchPrice: !IS_TESTNET,
|
forceFetchPrice: ENV.NETWORK !== NETWORK.TESTNET,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -49,5 +49,3 @@ export const ENV: EnvironmentVariables = {
|
|||||||
export const VERCEL_BYPASS = process.env.NEXT_PUBLIC_BYPASS
|
export const VERCEL_BYPASS = process.env.NEXT_PUBLIC_BYPASS
|
||||||
? `?x-vercel-protection-bypass=${process.env.NEXT_PUBLIC_BYPASS}`
|
? `?x-vercel-protection-bypass=${process.env.NEXT_PUBLIC_BYPASS}`
|
||||||
: ''
|
: ''
|
||||||
|
|
||||||
export const IS_TESTNET = ENV.NETWORK === 'testnet'
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { IS_TESTNET } from 'constants/env'
|
import { ENV } from 'constants/env'
|
||||||
|
import { NETWORK } from 'types/enums/network'
|
||||||
|
|
||||||
export const EXPLORER_NAME = 'Mintscan'
|
export const EXPLORER_NAME = 'Mintscan'
|
||||||
export const EXPLORER_TX_URL = IS_TESTNET
|
export const EXPLORER_TX_URL =
|
||||||
? 'https://testnet.mintscan.io/osmosis-testnet/txs/'
|
ENV.NETWORK === NETWORK.TESTNET
|
||||||
: 'https://www.mintscan.io/osmosis/transactions/'
|
? 'https://testnet.mintscan.io/osmosis-testnet/txs/'
|
||||||
|
: 'https://www.mintscan.io/osmosis/transactions/'
|
||||||
|
@ -8,7 +8,6 @@ import usePrices from 'hooks/usePrices'
|
|||||||
import { BNCoin } from 'types/classes/BNCoin'
|
import { BNCoin } from 'types/classes/BNCoin'
|
||||||
import { Action } from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
import { Action } from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
||||||
import { getLendEnabledAssets } from 'utils/assets'
|
import { getLendEnabledAssets } from 'utils/assets'
|
||||||
import { getDenomsFromBNCoins } from 'utils/tokens'
|
|
||||||
import {
|
import {
|
||||||
getEnterVaultActions,
|
getEnterVaultActions,
|
||||||
getVaultDepositCoinsAndValue,
|
getVaultDepositCoinsAndValue,
|
||||||
@ -74,9 +73,7 @@ export default function useDepositVault(props: Props): {
|
|||||||
const lendActions: Action[] = useMemo(() => {
|
const lendActions: Action[] = useMemo(() => {
|
||||||
if (!isAutoLend) return []
|
if (!isAutoLend) return []
|
||||||
|
|
||||||
const denoms = Array.from(
|
const denoms = [props.vault.denoms.primary, props.vault.denoms.secondary]
|
||||||
new Set(getDenomsFromBNCoins([...props.reclaims, ...props.deposits, ...props.borrowings])),
|
|
||||||
)
|
|
||||||
const denomsForLend = getLendEnabledAssets()
|
const denomsForLend = getLendEnabledAssets()
|
||||||
.filter((asset) => denoms.includes(asset.denom))
|
.filter((asset) => denoms.includes(asset.denom))
|
||||||
.map((asset) => asset.denom)
|
.map((asset) => asset.denom)
|
||||||
|
5
src/types/enums/network.ts
Normal file
5
src/types/enums/network.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export enum NETWORK {
|
||||||
|
MAINNET = 'mainnet',
|
||||||
|
DEVNET = 'devnet',
|
||||||
|
TESTNET = 'testnet',
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
import { ASSETS } from 'constants/assets'
|
import { ASSETS } from 'constants/assets'
|
||||||
import { IS_TESTNET } from 'constants/env'
|
import { ENV } from 'constants/env'
|
||||||
import { BN_ZERO } from 'constants/math'
|
import { BN_ZERO } from 'constants/math'
|
||||||
import { TESTNET_VAULTS_META_DATA, VAULTS_META_DATA } from 'constants/vaults'
|
import { TESTNET_VAULTS_META_DATA, VAULTS_META_DATA } from 'constants/vaults'
|
||||||
import { BNCoin } from 'types/classes/BNCoin'
|
import { BNCoin } from 'types/classes/BNCoin'
|
||||||
|
import { NETWORK } from 'types/enums/network'
|
||||||
import { Action, Uint128 } from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
import { Action, Uint128 } from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
||||||
import { getAssetByDenom } from 'utils/assets'
|
import { getAssetByDenom } from 'utils/assets'
|
||||||
import { VAULT_DEPOSIT_BUFFER } from 'utils/constants'
|
import { VAULT_DEPOSIT_BUFFER } from 'utils/constants'
|
||||||
@ -11,11 +12,11 @@ import { getValueFromBNCoins, mergeBNCoinArrays } from 'utils/helpers'
|
|||||||
import { getTokenPrice } from 'utils/tokens'
|
import { getTokenPrice } from 'utils/tokens'
|
||||||
|
|
||||||
export function getVaultsMetaData() {
|
export function getVaultsMetaData() {
|
||||||
return IS_TESTNET ? TESTNET_VAULTS_META_DATA : VAULTS_META_DATA
|
return ENV.NETWORK === NETWORK.TESTNET ? TESTNET_VAULTS_META_DATA : VAULTS_META_DATA
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getVaultMetaData(address: string) {
|
export function getVaultMetaData(address: string) {
|
||||||
const vaults = IS_TESTNET ? TESTNET_VAULTS_META_DATA : VAULTS_META_DATA
|
const vaults = ENV.NETWORK === NETWORK.TESTNET ? TESTNET_VAULTS_META_DATA : VAULTS_META_DATA
|
||||||
return vaults.find((vault) => vault.address === address)
|
return vaults.find((vault) => vault.address === address)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user