Skip to content

Commit

Permalink
chore: pool commission fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbulat committed Dec 7, 2024
1 parent eedef20 commit e16cf75
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/app/src/hooks/usePoolCommission/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const usePoolCommission = () => {

const getCurrentCommission = (id: number): number =>
Math.min(
Number(getBondedPool(id)?.commission?.current?.[0]?.slice(0, -1) || 0),
Number(getBondedPool(id)?.commission?.current?.[0] || 0),
globalMaxCommission
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { rmCommas } from '@w3ux/utils'
import { useActivePool } from 'contexts/Pools/ActivePool'
import { useBondedPools } from 'contexts/Pools/BondedPools'
import { createContext, useContext, useEffect, useState } from 'react'
Expand Down Expand Up @@ -29,25 +28,23 @@ export const PoolCommissionProvider = ({
const bondedPool = getBondedPool(poolId)

// Get initial commission value from the bonded pool commission config.
const initialCommission = Number(
(bondedPool?.commission?.current?.[0] || '0%').slice(0, -1)
)
const initialCommission = Number(bondedPool?.commission?.current?.[0] || '0')

// Get initial payee value from the bonded pool commission config.
const initialPayee = bondedPool?.commission?.current?.[1] || null

// Get initial maximum commission value from the bonded pool commission config.
const initialMaxCommission = Number(
(bondedPool?.commission?.max || '100').toString().slice(0, -1)
(bondedPool?.commission?.max || '100').toString()
)

// Get initial change rate value from the bonded pool commission config.
const initialChangeRate = ((): ChangeRateInput => {
const raw = bondedPool?.commission?.changeRate
return raw
? {
maxIncrease: Number(raw.maxIncrease.slice(0, -1)),
minDelay: Number(rmCommas(raw.minDelay)),
maxIncrease: Number(raw.maxIncrease),
minDelay: Number(raw.minDelay),
}
: {
maxIncrease: 100,
Expand Down

0 comments on commit e16cf75

Please sign in to comment.