Skip to content

Commit

Permalink
fix: leverage unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek committed Apr 23, 2024
1 parent 87e80fd commit 9a902ce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/src/api/calls/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type AllocationEventType = {
projectAddress: string;
}[];
isManuallyEdited: boolean | null;
leverage: string;
leverage: string | null; // elements from before the migration have leverage null
};

type EventType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const EarnHistoryItemDetailsAllocation: FC<EarnHistoryItemDetailsAllocationProps
* leverage in the event is a value from the moment event happened.
* When event happened in the already closed AW we show epochLeverage, as it's the final one.
*/
const leverageInt = parseInt(leverage, 10);
const leverageInt = leverage ? parseInt(leverage, 10) : 0;
const leverageBigInt = BigInt(leverageInt);
const epochLeverageNumber = epochLeverage ? Math.round(epochLeverage) : 0;
const epochLeverageBigInt = BigInt(epochLeverageNumber);
Expand Down Expand Up @@ -76,11 +76,18 @@ const EarnHistoryItemDetailsAllocation: FC<EarnHistoryItemDetailsAllocationProps
},
isAllocationFromCurrentAW
? {
childrenRight: <div className={styles.leverage}>{leverageInt}x</div>,
childrenRight: (
<div className={styles.leverage}>
{leverage === null ? t('sections.leverageUnknown') : `${leverageInt}x`}
</div>
),
label: t('sections.estimatedLeverage'),
tooltipProps: {
position: 'bottom-right',
text: t('sections.allocationTooltips.leverage'),
text:
leverage === null
? t('sections.allocationTooltips.leverageUnknown')
: t('sections.allocationTooltips.leverage'),
tooltipClassName: styles.tooltip,
},
}
Expand Down
2 changes: 2 additions & 0 deletions client/src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@
"when": "When",
"withdrawal": "Withdrew ETH",
"matchingFundDonation": "Matching fund donation",
"leverageUnknown": "Unknown",
"allocationTooltips": {
"leverageUnknown": "We do not know the leverage for this past allocation.",
"finalMatchFunding": "Once allocation period has finished we know the exact amount of your matched funding your donation attracted, so we show that rather than just your estimated leverage amount.",
"leverage": "Leverage shows the multiple of your donation the projects you chose will receive in matched funding. Note that it may change wildly during an epoch, and be very different to your final matched funding."
}
Expand Down

0 comments on commit 9a902ce

Please sign in to comment.