Skip to content

Commit

Permalink
fix collateral
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbir committed May 17, 2024
1 parent 44149d9 commit 87f6d68
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/ssv/reads/getExcessTokensToWithdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getMinimumLiquidationCollateral } from './getMinimumLiquidationCollater
import process from 'process'
import { blocksPerDay } from '../../common/helpers/constants'
import { getCurrentClusterBalance } from './getCurrentClusterBalance'
import { getLiquidationThresholdPeriod } from './getLiquidationThresholdPeriod'

export async function getExcessTokensToWithdraw(clusterState: ClusterStateApi) {
logger.info('getExcessTokensToWithdraw started for ' + clusterState.clusterId)
Expand Down Expand Up @@ -40,9 +41,19 @@ export async function getExcessTokensToWithdraw(clusterState: ClusterStateApi) {
const neededBalancePerValidator =
totalFeePerBlock * blocksPerDay * allowedDaysToLiquidationForPrivate
const minimumLiquidationCollateral = await getMinimumLiquidationCollateral()

const liquidationThresholdPeriod = await getLiquidationThresholdPeriod()
const collateralForLiquidationThresholdPeriod = liquidationThresholdPeriod *
totalFeePerBlock *
BigInt(validatorCount)

const collateral = minimumLiquidationCollateral > collateralForLiquidationThresholdPeriod
? minimumLiquidationCollateral
: collateralForLiquidationThresholdPeriod

const targetBalance =
neededBalancePerValidator * BigInt(validatorCount) +
minimumLiquidationCollateral
collateral

const balance = await getCurrentClusterBalance(clusterState)

Expand Down

0 comments on commit 87f6d68

Please sign in to comment.