Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

fix(raft): fix for position presenter #2732

Merged
merged 1 commit into from
Jun 10, 2023

Conversation

tonzgao
Copy link
Contributor

@tonzgao tonzgao commented Jun 9, 2023

Description

see #2728

solution for https://discord.com/channels/647279669388771329/964569348243075082/1116498228406394941. just not imported. still not testable. if this doesnt work I have an alternate approach, which is to override getBalances in the raft.position.contract-position-fetcher as follows


  // Hack: should be position presenter
  async getBalances(_address: string) {
    const rawBalances = await super.getBalances(_address);
    const balances = rawBalances.map(balance => {
      const collateral = balance.tokens[0];
      const collateralUSD = collateral?.balanceUSD ?? 0;
      const debt = -(balance.tokens[1]?.balanceUSD ?? 0);
      const cRatio = Math.abs(debt) > 0 ? Math.abs(collateralUSD / debt) : 0;
      const liquidationPrice = (Number(balance.dataProps.minCRatio) * debt) / collateral.balance
      balance.displayProps['statsItems'] = [
        { label: 'C-Ratio', value: buildPercentageDisplayItem(cRatio) },
        { label: 'Liquidation Price', value: buildDollarDisplayItem(liquidationPrice) },
      ]
      return balance
    })
    return balances;
  }

Checklist

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants