Skip to content

Commit

Permalink
fix: update productSupply prop type and add debug logs for payout cal…
Browse files Browse the repository at this point in the history
…culation
  • Loading branch information
mohandast52 committed Nov 4, 2024
1 parent 40b0d19 commit 2235021
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions apps/bond/components/BondingProducts/Bonding/Deposit/Deposit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const Deposit = ({
getProducts,
closeModal,
}) => {
console.log('Deposit -> productToken', productSupply);
const { account } = useHelpers();
const [form] = Form.useForm();
const [isLoading, setIsLoading] = useState(false);
Expand Down Expand Up @@ -135,10 +136,13 @@ export const Deposit = ({
return parseToEth(remainingLPSupply);
}, [lpBalance, productSupply, productLpPriceAfterDiscount]);

// calculate the OLAS payout based on the token amount input
const olasPayout = useMemo(() => {
if (!tokenAmountInputValue || tokenAmountInputValue > remainingLpSupplyInEth) {
return '--';
}
console.log({ tokenAmountInputValue, remainingLpSupplyInEth, productLpPriceAfterDiscount });

// if (!tokenAmountInputValue || tokenAmountInputValue > remainingLpSupplyInEth) {
// return '--';
// }

const tokenAmountValue = isSvmProduct
? tokenAmountInputValue
Expand All @@ -149,6 +153,14 @@ export const Deposit = ({
? payoutInBg.dividedBy(BigNumber(`1${'0'.repeat(28)}`)).toFixed(2)
: Number(payoutInBg.dividedBy(ONE_ETH_IN_STRING).dividedBy(ONE_ETH_IN_STRING).toFixed(2));

console.log({
tokenAmountInputValue,
remainingLpSupplyInEth,
productLpPriceAfterDiscount,
isSvmProduct,
payout,
});

return getCommaSeparatedNumber(payout, 4);
}, [tokenAmountInputValue, remainingLpSupplyInEth, productLpPriceAfterDiscount, isSvmProduct]);

Expand Down Expand Up @@ -285,7 +297,7 @@ Deposit.propTypes = {
productId: PropTypes.string,
productToken: PropTypes.string,
productLpTokenName: PropTypes.string,
productSupply: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(BigInt)]),
productSupply: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
productLpPriceAfterDiscount: PropTypes.oneOfType([
PropTypes.string,
PropTypes.instanceOf(BigInt),
Expand Down

0 comments on commit 2235021

Please sign in to comment.