|
|
@@ -1,12 +1,12 @@
|
|
|
<script setup lang="ts">
|
|
|
import { computed, onMounted, ref, watch } from 'vue'
|
|
|
-import { onBeforeRouteLeave, useRoute, useRouter } from 'vue-router'
|
|
|
+import { useRoute, useRouter } from 'vue-router'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
import {
|
|
|
fetchMinOpenStakingConfig,
|
|
|
fetchStakingConfigList,
|
|
|
fetchStakingTeamOverview,
|
|
|
- fetchStakingSpotPrice,
|
|
|
+ IDO_SUBSCRIPTION_PRICE_USDT,
|
|
|
submitStakeByUsdt,
|
|
|
type StakingConfig,
|
|
|
} from '@/api/staking'
|
|
|
@@ -18,7 +18,6 @@ import {
|
|
|
releaseMonthsFromConfig,
|
|
|
} from '@/utils/stakingDisplay'
|
|
|
import { useToast } from '@/composables/useToast'
|
|
|
-import { useLiveCoinUsdtPrice } from '@/composables/useLiveCoinUsdtPrice'
|
|
|
import { AUTH_ENABLED } from '@/utils/featureFlags'
|
|
|
import TransferModal from '@/components/common/TransferModal.vue'
|
|
|
import idoHero from '@/assets/finance/ido-hero.png'
|
|
|
@@ -74,55 +73,16 @@ function fmtAmount(n: string | number, maxFrac = 8) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-const priceCoinUnit = computed(
|
|
|
- () => config.value?.coinUnit?.trim() || STAKING_COIN_UNIT,
|
|
|
-)
|
|
|
+/** IDO 固定认购价 0.6 USDT */
|
|
|
+const unitPriceUsdt = computed(() => IDO_SUBSCRIPTION_PRICE_USDT)
|
|
|
|
|
|
-/** iBit/USDT 实时价(现货 WS) */
|
|
|
-const { livePrice: ibitUsdtPrice, disconnect: disconnectLivePrice } =
|
|
|
- useLiveCoinUsdtPrice(priceCoinUnit)
|
|
|
-
|
|
|
-/** Redis 现货价(与提交闪兑同源,WS 未连上时回退) */
|
|
|
-const redisSpotPrice = ref(0)
|
|
|
-
|
|
|
-onBeforeRouteLeave(() => {
|
|
|
- disconnectLivePrice()
|
|
|
-})
|
|
|
-
|
|
|
-/** 优先 WS,否则用 Redis HTTP 价 */
|
|
|
-const unitPriceUsdt = computed(() => {
|
|
|
- if (ibitUsdtPrice.value > 0) {
|
|
|
- return ibitUsdtPrice.value
|
|
|
- }
|
|
|
- return redisSpotPrice.value
|
|
|
-})
|
|
|
-
|
|
|
-async function refreshRedisSpotPrice() {
|
|
|
- const unit = priceCoinUnit.value
|
|
|
- if (!unit || unit.toUpperCase() === 'USDT') {
|
|
|
- redisSpotPrice.value = 1
|
|
|
- return
|
|
|
- }
|
|
|
- try {
|
|
|
- const res = await fetchStakingSpotPrice(unit)
|
|
|
- const p = Number(res?.price)
|
|
|
- redisSpotPrice.value = Number.isFinite(p) && p > 0 ? p : 0
|
|
|
- } catch {
|
|
|
- redisSpotPrice.value = 0
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-/** USDT → iBit 实时折算(左侧展示) */
|
|
|
+/** USDT → iBit 折算(固定价) */
|
|
|
const subscribeIbit = computed(() => {
|
|
|
const usdt = Number(subscribeUsdt.value)
|
|
|
if (!Number.isFinite(usdt) || usdt <= 0) {
|
|
|
return '0'
|
|
|
}
|
|
|
- const price = ibitUsdtPrice.value
|
|
|
- if (!price || price <= 0) {
|
|
|
- return '0'
|
|
|
- }
|
|
|
- const ibit = usdt / price
|
|
|
+ const ibit = usdt / IDO_SUBSCRIPTION_PRICE_USDT
|
|
|
return ibit.toLocaleString('en-US', {
|
|
|
minimumFractionDigits: 0,
|
|
|
maximumFractionDigits: 8,
|
|
|
@@ -223,7 +183,7 @@ async function load(opts?: { silent?: boolean }) {
|
|
|
error.value = t('finance.configNotFound')
|
|
|
return
|
|
|
}
|
|
|
- await Promise.all([refreshAvailableUsdt(), refreshOverviewStats(), refreshRedisSpotPrice()])
|
|
|
+ await Promise.all([refreshAvailableUsdt(), refreshOverviewStats()])
|
|
|
} catch (e) {
|
|
|
error.value = e instanceof Error ? e.message : t('common.loadFailed')
|
|
|
config.value = null
|
|
|
@@ -246,10 +206,6 @@ async function onSubmit() {
|
|
|
toast.error(t('finance.amountRequired'))
|
|
|
return
|
|
|
}
|
|
|
- if (!unitPriceUsdt.value || unitPriceUsdt.value <= 0) {
|
|
|
- toast.error(t('finance.priceUnavailable'))
|
|
|
- return
|
|
|
- }
|
|
|
|
|
|
const ibit = subscribeIbitNum.value
|
|
|
if (!ibit || ibit <= 0) {
|
|
|
@@ -287,10 +243,6 @@ async function onSubmit() {
|
|
|
onMounted(() => load())
|
|
|
|
|
|
watch(() => route.params.configId, () => load())
|
|
|
-
|
|
|
-watch(priceCoinUnit, () => {
|
|
|
- void refreshRedisSpotPrice()
|
|
|
-})
|
|
|
</script>
|
|
|
|
|
|
<template>
|