Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit 3f8924d

Browse files
committed
update sim apr
1 parent 231d55e commit 3f8924d

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

src/pages/farms.vue

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ import { FarmInfo, UPCOMING } from '@/utils/farms'
400400
import { deposit, depositV5, withdraw, withdrawV4, withdrawV5 } from '@/utils/stake'
401401
import { getUnixTs } from '@/utils'
402402
import { getBigNumber } from '@/utils/layouts'
403+
import { web3Config } from '@/utils/web3'
403404
404405
const CollapsePanel = Collapse.Panel
405406
@@ -496,6 +497,28 @@ export default Vue.extend({
496497
const endedFarmsPoolId: string[] = []
497498
const pools = (await this.$api.getPairs()).data
498499
500+
let itemSecondSlotSpread = 2
501+
502+
for (const rpcUrl of web3Config.rpcs) {
503+
try {
504+
const dataReq = await this.$axios.post(
505+
rpcUrl.url,
506+
{
507+
id: 'getRecentPerformanceSamples',
508+
jsonrpc: '2.0',
509+
method: 'getRecentPerformanceSamples',
510+
params: [100]
511+
},
512+
{ timeout: 60000 }
513+
)
514+
// @ts-ignore
515+
const data: any = dataReq.result
516+
const slotList: number[] = data.map((item: any) => item.numSlots)
517+
itemSecondSlotSpread = slotList.reduce((a, b) => a + b) / slotList.length / 60
518+
break
519+
} catch (e) {}
520+
}
521+
499522
for (const [poolId, farmInfo] of Object.entries(this.farm.infos)) {
500523
const isFusion = Boolean((farmInfo as any).fusion)
501524
// @ts-ignore
@@ -524,15 +547,15 @@ export default Vue.extend({
524547
525548
const rewardPerBlockAmountTotalValue =
526549
getBigNumber(rewardPerBlockAmount.toEther()) *
527-
2 *
550+
itemSecondSlotSpread *
528551
60 *
529552
60 *
530553
24 *
531554
365 *
532555
this.price.prices[reward.mintAddress as string]
533556
const rewardBPerBlockAmountTotalValue =
534557
getBigNumber(rewardBPerBlockAmount.toEther()) *
535-
2 *
558+
itemSecondSlotSpread *
536559
60 *
537560
60 *
538561
24 *
@@ -580,7 +603,7 @@ export default Vue.extend({
580603
581604
const rewardPerBlockAmountTotalValue =
582605
getBigNumber(rewardPerBlockAmount.toEther()) *
583-
2 *
606+
itemSecondSlotSpread *
584607
60 *
585608
60 *
586609
24 *

src/pages/staking.vue

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ import { FarmInfo } from '@/utils/farms'
152152
import { deposit, withdraw } from '@/utils/stake'
153153
import { getUnixTs } from '@/utils'
154154
import { getBigNumber } from '@/utils/layouts'
155+
import { web3Config } from '@/utils/web3'
155156
156157
const CollapsePanel = Collapse.Panel
157158
@@ -220,9 +221,31 @@ export default Vue.extend({
220221
methods: {
221222
TokenAmount,
222223
223-
updateFarms() {
224+
async updateFarms() {
224225
const farms: any = []
225226
227+
let itemSecondSlotSpread = 2
228+
229+
for (const rpcUrl of web3Config.rpcs) {
230+
try {
231+
const dataReq = await this.$axios.post(
232+
rpcUrl.url,
233+
{
234+
id: 'getRecentPerformanceSamples',
235+
jsonrpc: '2.0',
236+
method: 'getRecentPerformanceSamples',
237+
params: [100]
238+
},
239+
{ timeout: 60000 }
240+
)
241+
// @ts-ignore
242+
const data: any = dataReq.result
243+
const slotList: number[] = data.map((item: any) => item.numSlots)
244+
itemSecondSlotSpread = slotList.reduce((a, b) => a + b) / slotList.length / 60
245+
break
246+
} catch (e) {}
247+
}
248+
226249
for (const [poolId, farmInfo] of Object.entries(this.farm.infos)) {
227250
// @ts-ignore
228251
if (farmInfo.isStake) {
@@ -235,7 +258,7 @@ export default Vue.extend({
235258
const rewardPerBlockAmount = new TokenAmount(getBigNumber(rewardPerBlock), reward.decimals)
236259
const rewardPerBlockAmountTotalValue =
237260
getBigNumber(rewardPerBlockAmount.toEther()) *
238-
2 *
261+
itemSecondSlotSpread *
239262
60 *
240263
60 *
241264
24 *

0 commit comments

Comments
 (0)