Skip to content

Commit a9d7e7d

Browse files
authored
calc long fixed apr based on amount of base paid (#1805)
* calc long fixed apr based on amount of base paid * remove console logs
1 parent bcf8c3f commit a9d7e7d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongPreview/OpenLongStats.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,6 @@ export function OpenLongStats({
7878
hyperdriveAddress: hyperdrive.address,
7979
});
8080

81-
if (isZapToken && zapTokenPrice && baseTokenPrice) {
82-
const fiatValueOfZapAmount = fixed(zapTokenPrice).mul(
83-
amountPaid,
84-
activeToken.decimals,
85-
);
86-
const zapAmountInBase = fiatValueOfZapAmount.div(baseTokenPrice);
87-
const slipageAmount = parseFixed("0.005");
88-
finalAmountPaid = parseFixed("1")
89-
.sub(slipageAmount)
90-
.mul(zapAmountInBase).bigint;
91-
}
92-
9381
const isBaseAmount = asBase || hyperdrive.isSharesPeggedToBase;
9482
const amountPaidInBase = isBaseAmount
9583
? amountPaid
@@ -102,6 +90,20 @@ export function OpenLongStats({
10290
const termLengthMS = Number(hyperdrive.poolConfig.positionDuration * 1000n);
10391
const numDays = convertMillisecondsToDays(termLengthMS);
10492

93+
if (isZapToken && zapTokenPrice && baseTokenPrice) {
94+
const fiatValueOfZapAmount = fixed(zapTokenPrice).mul(
95+
amountPaid,
96+
activeToken.decimals,
97+
);
98+
const zapAmountInBase = fiatValueOfZapAmount.div(baseTokenPrice);
99+
const slipageAmount = parseFixed("0.005");
100+
finalAmountPaid = parseFixed("1")
101+
.sub(slipageAmount)
102+
.mul(zapAmountInBase).bigint;
103+
} else {
104+
finalAmountPaid = amountPaidInBase;
105+
}
106+
105107
return (
106108
<div className="flex flex-row justify-between px-4 py-8">
107109
<PrimaryStat

0 commit comments

Comments
 (0)