@ape.swap/bonds-sdk 5.1.31 → 5.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/TokenSelectorPanel/index.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/Icons/Discount.d.ts +4 -0
- package/dist/components/uikit-sdk/Svg/Icons/Discount.js +18 -0
- package/dist/components/uikit-sdk/Svg/Icons/Discount.js.map +1 -0
- package/dist/components/uikit-sdk/Svg/index.js +3 -0
- package/dist/components/uikit-sdk/Svg/index.js.map +1 -1
- package/dist/components/uikit-sdk/Svg/types.d.ts +1 -0
- package/dist/components/uikit-sdk/Svg/types.js +1 -0
- package/dist/components/uikit-sdk/Svg/types.js.map +1 -1
- package/dist/config/constants/addresses.d.ts +3 -0
- package/dist/config/constants/addresses.js +4 -1
- package/dist/config/constants/addresses.js.map +1 -1
- package/dist/config/constants/queryKeys.d.ts +1 -0
- package/dist/config/constants/queryKeys.js +1 -2
- package/dist/config/constants/queryKeys.js.map +1 -1
- package/dist/config/constants/variables.d.ts +1 -0
- package/dist/config/constants/variables.js +2 -1
- package/dist/config/constants/variables.js.map +1 -1
- package/dist/state/tiers/useTierPoints.d.ts +19 -5
- package/dist/state/tiers/useTierPoints.js +37 -22
- package/dist/state/tiers/useTierPoints.js.map +1 -1
- package/dist/state/tokenPrices/useAbondPrice.d.ts +1 -0
- package/dist/state/tokenPrices/useAbondPrice.js +10 -0
- package/dist/state/tokenPrices/useAbondPrice.js.map +1 -0
- package/dist/state/tokenPrices/useTokenPrice.js +7 -3
- package/dist/state/tokenPrices/useTokenPrice.js.map +1 -1
- package/dist/state/zap/useSoulZapBondQuote.js +18 -2
- package/dist/state/zap/useSoulZapBondQuote.js.map +1 -1
- package/dist/state/zap/useTierOptimizationPreview.d.ts +27 -0
- package/dist/utils/bondPriceHelpers.js.map +1 -1
- package/dist/utils/formatNumber.d.ts +0 -1
- package/dist/utils/formatNumber.js +1 -16
- package/dist/utils/formatNumber.js.map +1 -1
- package/dist/views/Bonds/components/BonusComponents/BonusTable.js +3 -3
- package/dist/views/Bonds/components/BonusComponents/BonusTable.js.map +1 -1
- package/dist/views/Bonds/utils.js.map +1 -1
- package/dist/views/BuyBond/BuyComponent.js +25 -20
- package/dist/views/BuyBond/BuyComponent.js.map +1 -1
- package/dist/views/BuyBond/components/Estimations.d.ts +3 -1
- package/dist/views/BuyBond/components/Estimations.js +21 -4
- package/dist/views/BuyBond/components/Estimations.js.map +1 -1
- package/dist/views/BuyBond/components/GetUpToComponent/GetUpToComponent.js.map +1 -1
- package/dist/views/BuyBond/components/PointsLeftForNextTier/PointsLeftForNextTier.d.ts +11 -0
- package/dist/views/BuyBond/components/PointsLeftForNextTier/PointsLeftForNextTier.js +142 -0
- package/dist/views/BuyBond/components/PointsLeftForNextTier/PointsLeftForNextTier.js.map +1 -0
- package/dist/views/BuyBond/utils.d.ts +20 -0
- package/dist/views/BuyBond/utils.js +64 -0
- package/dist/views/BuyBond/utils.js.map +1 -0
- package/dist/views/ProjectView/ProjectView.js +9 -8
- package/dist/views/ProjectView/ProjectView.js.map +1 -1
- package/dist/views/ProjectView/components/RecommendationCards/index.js +2 -7
- package/dist/views/ProjectView/components/RecommendationCards/index.js.map +1 -1
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowPreTGE.js +2 -2
- package/dist/views/YourBonds/components/UserBondRow/UserBondRowPreTGE.js.map +1 -1
- package/package.json +1 -1
- package/dist/views/ProjectView/components/PriceChart/components/CandleStickChart.js +0 -111
- package/dist/views/ProjectView/components/PriceChart/components/CandleStickChart.js.map +0 -1
- package/dist/views/ProjectView/components/PriceChart/components/LineChart.js +0 -100
- package/dist/views/ProjectView/components/PriceChart/components/LineChart.js.map +0 -1
- package/dist/views/ProjectView/components/PriceChart/components/utils.js +0 -20
- package/dist/views/ProjectView/components/PriceChart/components/utils.js.map +0 -1
- package/dist/views/ProjectView/components/PriceChart/index.js +0 -38
- package/dist/views/ProjectView/components/PriceChart/index.js.map +0 -1
- package/dist/views/ProjectView/components/PriceChart/styles.js +0 -44
- package/dist/views/ProjectView/components/PriceChart/styles.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PointsLeftForNextTier.js","sources":["../../../../../src/views/BuyBond/components/PointsLeftForNextTier/PointsLeftForNextTier.tsx"],"sourcesContent":["import React, { useState } from 'react'\nimport Flex from '../../../../components/uikit-sdk/Flex'\nimport { BondsData } from '../../../../types/bonds'\nimport useTierPoints, {\n getUserTier,\n TIERS_COLORS,\n TIERS_NAMES,\n TIERS_WEIGHT,\n} from '../../../../state/tiers/useTierPoints'\nimport { BillVersion, LaunchBondTiers } from '@ape.swap/apeswap-lists'\nimport { getBalanceNumber } from '../../../../utils/getBalanceNumber'\nimport { formatNumberSI } from '../../../../utils/formatNumber'\nimport { useAbondPrice } from '../../../../state/tokenPrices/useAbondPrice'\nimport Svg from '../../../../components/uikit-sdk/Svg'\nimport { AnimatePresence, motion } from 'framer-motion'\nimport { calculateOptimizationData } from '../../utils'\n\nconst getNextTierInfo = (userPoints: string) => {\n const tiers = [\n { tier: LaunchBondTiers.Silver, threshold: TIERS_WEIGHT[LaunchBondTiers.Silver] },\n { tier: LaunchBondTiers.Gold, threshold: TIERS_WEIGHT[LaunchBondTiers.Gold] },\n { tier: LaunchBondTiers.Diamond, threshold: TIERS_WEIGHT[LaunchBondTiers.Diamond] },\n { tier: LaunchBondTiers.Legend, threshold: TIERS_WEIGHT[LaunchBondTiers.Legend] },\n { tier: LaunchBondTiers.Mythical, threshold: TIERS_WEIGHT[LaunchBondTiers.Mythical] },\n ]\n\n const userPointsBN = getBalanceNumber(userPoints)\n\n for (const { tier, threshold } of tiers) {\n const thresholdNumber = getBalanceNumber(threshold)\n if (userPointsBN < thresholdNumber) {\n const pointsNeeded = thresholdNumber - userPointsBN\n return { nextTier: tier, pointsNeeded }\n }\n }\n\n return null // User is at max tier (Mythical)\n}\n\ninterface GetUpToComponentProps {\n bond: BondsData\n inputAmount: string\n setInputValue: (value: string) => void\n inputTokenDecimals: number\n inputTokenPrice?: number\n}\n\nconst PointsLeftForNextTier: React.FC<GetUpToComponentProps> = ({\n bond,\n inputAmount,\n setInputValue,\n inputTokenDecimals,\n inputTokenPrice,\n}) => {\n const [isOpen, setIsOpen] = useState(false)\n // Hooks & Data\n const { data: userPoints } = useTierPoints()\n const abondPrice = useAbondPrice()\n const userTier = getUserTier(userPoints)\n const nextTierInfo = getNextTierInfo(userPoints || '0')\n const inputAmountUSD = parseFloat(inputAmount) * (inputTokenPrice ?? 0)\n const necessaryUSDAmount = (nextTierInfo?.pointsNeeded! / 4) * abondPrice!\n const fee = ((bond.tierBoostRate ?? 0) + 100) / 100 - 1\n const feeToBeCollected = inputAmountUSD * fee\n const feeInAbond = feeToBeCollected / abondPrice!\n const pointsToBeEarned = feeInAbond * 4\n\n const optimizationData = calculateOptimizationData(inputAmount, userPoints!, bond, inputTokenPrice, abondPrice)\n const nextTierData = optimizationData?.data?.[0]\n const highestProfitableTier = optimizationData?.highestProfitableTier\n\n const handleSetNextTierAmount = (amount: number) => {\n const inputValueInSelectedToken = amount / (inputTokenPrice ?? 0)\n setInputValue(inputValueInSelectedToken.toFixed(inputTokenDecimals))\n }\n\n return (\n userTier !== LaunchBondTiers.Legend &&\n bond.billVersion === BillVersion.V4 && (\n <Flex\n sx={{\n width: '100%',\n mt: '10px',\n fontSize: '12px',\n fontWeight: 400,\n flexDirection: 'column',\n position: 'relative',\n cursor: 'pointer',\n }}\n onClick={() => setIsOpen(!isOpen)}\n >\n {highestProfitableTier ? (\n <Flex\n sx={{\n border: '1px solid rgba(22, 101, 52, 0.53)',\n borderRadius: 'normal',\n position: 'relative',\n overflow: 'hidden',\n pl: '10px',\n pr: ['10px', '10px', '10px', '20px'],\n py: '6px',\n background: 'linear-gradient(90deg, #0A2A1A 0%, #1A2A28 100%) !important',\n color: 'rgba(134, 237, 171, 0.70)',\n minHeight: '27px',\n alignItems: 'center',\n gap: '5px',\n flexWrap: 'wrap',\n }}\n >\n <span sx={{ flex: 1 }}>\n <span sx={{ display: 'inline-flex', verticalAlign: 'sub', mr: '4px' }}>\n <Svg icon=\"Discount\" width={14} color={'#4AD980'} />\n </span>\n <span sx={{ fontWeight: 700 }}>Congratulations!</span> With your purchase you will accumulate points to\n upgrade to {/*@ts-ignore*/}\n <span sx={{ fontWeight: 700, color: TIERS_COLORS[highestProfitableTier?.tier] }}>\n {highestProfitableTier.tierName}\n </span>{' '}\n <span sx={{ fontWeight: 700 }}>Tier!</span>\n </span>\n <Svg icon={'caret'} direction={isOpen ? 'up' : 'down'} width={10} />\n </Flex>\n ) : (\n (userTier ?? 0) < LaunchBondTiers.Mythical &&\n nextTierData && (\n <Flex\n sx={{\n border: '1px solid #9960C5',\n borderRadius: 'normal',\n position: 'relative',\n overflow: 'hidden',\n pl: '10px',\n pr: '20px',\n py: '2px',\n alignItems: 'center',\n background: '#312341',\n justifyContent: 'space-between',\n }}\n >\n <Flex sx={{ alignItems: 'center', justifyContent: 'space-between', width: '100%' }}>\n <Flex sx={{ alignItems: 'center' }}>\n <img\n src={`https://ape.bond/images/launch/${nextTierData?.tierName?.toLowerCase()}.png`}\n alt=\"minTier\"\n style={{ width: '21px', height: '21px', marginRight: '3px', zIndex: 1 }}\n />\n Doing a ${formatNumberSI(nextTierData?.minBreakevenWithFeeUSD!)} bond purchase will grant you a\n {/*@ts-ignore*/}\n <span sx={{ color: TIERS_COLORS[nextTierData?.tier], px: '3px', fontWeight: 600 }}>\n {nextTierData?.tierName}\n </span>\n Tier.\n </Flex>\n <span\n sx={{\n mx: '5px',\n color: 'primaryButton',\n fontWeight: 500,\n cursor: 'pointer',\n ':hover': { textDecoration: 'underline' },\n }}\n onClick={(e) => {\n e.stopPropagation()\n handleSetNextTierAmount(nextTierData.minBreakevenWithFeeUSD * 1.01)\n }}\n >\n {'Upgrade now >'}\n </span>\n </Flex>\n <Svg icon={'caret'} direction={isOpen ? 'up' : 'down'} width={10} />\n </Flex>\n )\n )}\n <AnimatePresence>\n {isOpen && optimizationData && (\n <motion.div\n initial={{ height: 0 }}\n animate={{ height: 'fit-content' }}\n transition={{ opacity: { duration: 0.2 } }}\n exit={{ height: 0 }}\n sx={{ overflow: 'hidden', width: '100%', marginTop: '5px', cursor: 'pointer' }}\n >\n {optimizationData?.data?.slice(1, optimizationData?.data.length)?.map((data) => {\n return (\n <Flex\n sx={{\n border: '1px solid #9960C5',\n borderRadius: 'normal',\n position: 'relative',\n overflow: 'hidden',\n pl: '10px',\n pr: '20px',\n py: '2px',\n mt: '3px',\n alignItems: 'center',\n background: '#312341',\n justifyContent: 'space-between',\n }}\n onClick={() => handleSetNextTierAmount(data.minBreakevenWithFeeUSD * 1.01)}\n key={data.tierName}\n >\n <span sx={{ flex: 1 }}>\n <span sx={{ display: 'inline-flex', verticalAlign: 'bottom' }}>\n <img\n src={`https://ape.bond/images/launch/${data?.tierName?.toLowerCase()}.png`}\n alt=\"minTier\"\n style={{ width: '21px', height: '21px', marginRight: '3px', zIndex: 1 }}\n />\n </span>\n Doing a ${formatNumberSI(data?.minBreakevenWithFeeUSD!)} bond purchase will grant you a\n {/*@ts-ignore*/}\n <span sx={{ color: TIERS_COLORS[data?.tier], px: '3px', fontWeight: 600 }}>{data?.tierName}</span>\n Tier.\n <span\n sx={{\n ml: '5px',\n mr: '15px',\n color: 'primaryButton',\n fontWeight: 500,\n cursor: 'pointer',\n ':hover': { textDecoration: 'underline' },\n display: ['inline', 'inline', 'inline', 'none'],\n }}\n onClick={() => handleSetNextTierAmount(data.minBreakevenWithFeeUSD * 1.01)}\n >\n {`Upgrade now >`}\n </span>\n </span>\n <span\n sx={{\n ml: '5px',\n mr: '15px',\n color: 'primaryButton',\n fontWeight: 500,\n cursor: 'pointer',\n ':hover': { textDecoration: 'underline' },\n display: ['none', 'none', 'none', 'flex'],\n }}\n onClick={() => handleSetNextTierAmount(data.minBreakevenWithFeeUSD * 1.01)}\n >\n {`Upgrade now >`}\n </span>\n </Flex>\n )\n })}\n </motion.div>\n )}\n </AnimatePresence>\n <Flex sx={{ mt: '15px' }}>Debbuging table</Flex>\n <Flex\n sx={{\n width: '100%',\n mt: '10px',\n fontSize: '12px',\n fontWeight: 400,\n flexDirection: 'column',\n position: 'relative',\n '& > :nth-of-type(even)': {\n background: 'white3',\n },\n '& > :nth-of-type(odd)': {\n background: 'white4',\n },\n }}\n >\n <Flex sx={{ width: '100%', justifyContent: 'space-between', p: '3px' }}>\n <Flex>User Points</Flex>\n <Flex>{formatNumberSI(getBalanceNumber(userPoints!))}</Flex>\n </Flex>\n <Flex sx={{ width: '100%', justifyContent: 'space-between', p: '3px' }}>\n {/*@ts-ignore*/}\n <Flex>Points needed for {TIERS_NAMES[nextTierInfo?.nextTier]}</Flex>\n <Flex>{formatNumberSI(nextTierInfo?.pointsNeeded)}</Flex>\n </Flex>\n <Flex sx={{ width: '100%', justifyContent: 'space-between', p: '3px' }}>\n <Flex>usd Abond necessary for next tier</Flex>\n <Flex>${formatNumberSI(necessaryUSDAmount)}</Flex>\n </Flex>\n <Flex sx={{ width: '100%', justifyContent: 'space-between', p: '3px' }}>\n <Flex>Fee percentage</Flex>\n <Flex>\n {bond.tierBoostRate}% (${formatNumberSI(feeToBeCollected)})\n </Flex>\n </Flex>\n {/*<Flex sx={{ width: '100%', justifyContent: 'space-between', p: '3px' }}>*/}\n {/* <Flex>Input Amount USD</Flex>*/}\n {/* <Flex>${formatNumberSI(inputAmountUSD)}</Flex>*/}\n {/*</Flex>*/}\n {/*<Flex sx={{ width: '100%', justifyContent: 'space-between', p: '3px' }}>*/}\n {/* <Flex>USD Fee to be collected</Flex>*/}\n {/* <Flex>${formatNumberSI(feeToBeCollected)}</Flex>*/}\n {/*</Flex>*/}\n {/*<Flex sx={{ width: '100%', justifyContent: 'space-between', p: '3px' }}>*/}\n {/* <Flex>Fee in ABOND</Flex>*/}\n {/* <Flex>{formatNumberSI(feeInAbond)} ABOND</Flex>*/}\n {/*</Flex>*/}\n <Flex sx={{ width: '100%', justifyContent: 'space-between', p: '3px' }}>\n <Flex>Points To Be Earned through tierBoostRate</Flex>\n <Flex>{formatNumberSI(pointsToBeEarned, 0)}</Flex>\n </Flex>\n {/*<Flex sx={{ width: '100%', justifyContent: 'space-between', p: '3px' }}>*/}\n {/* <Flex>Enough points to upgrade?</Flex>*/}\n {/* <Flex>{arePointsEnough ? 'Yes 🔥' : 'No :('}</Flex>*/}\n {/*</Flex>*/}\n {/*<Flex sx={{ width: '100%', justifyContent: 'space-between', p: '3px' }}>*/}\n {/* <Flex>Fee in ABOND</Flex>*/}\n {/* <Flex>{formatNumberSI(feeInAbond)} ABOND</Flex>*/}\n {/*</Flex>*/}\n </Flex>\n </Flex>\n )\n )\n}\n\nexport default PointsLeftForNextTier\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,eAAe,GAAG,CAAC,UAAkB,KAAI;AAC7C,IAAA,MAAM,KAAK,GAAG;AACZ,QAAA,EAAE,IAAI,EAAE,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE;AACjF,QAAA,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;AAC7E,QAAA,EAAE,IAAI,EAAE,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE;AACnF,QAAA,EAAE,IAAI,EAAE,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE;AACjF,QAAA,EAAE,IAAI,EAAE,eAAe,CAAC,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;KACtF;AAED,IAAA,MAAM,YAAY,GAAG,gBAAgB,CAAC,UAAU,CAAC;IAEjD,KAAK,MAAM,EAAE,IAAI,E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,CAAC,IAAI,EAAA,EAAA,QAAA,EAAA,gBAAA,EAAA,CAAsB,EAC3BD,KAAC,IAAI,EAAA,EAAA,QAAA,EAAA,CACF,IAAI,CAAC,aAAa,UAAM,cAAc,CAAC,gBAAgB,CAAC,EAAA,GAAA,CAAA,EAAA,CACpD,IACF,EAaPA,IAAA,CAAC,IAAI,EAAA,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC,EAAE,KAAK,EAAE,EAAA,QAAA,EAAA,CACpEC,IAAC,IAAI,EAAA,EAAA,QAAA,EAAA,2CAAA,EAAA,CAAiD,EACtDA,GAAA,CAAC,IAAI,cAAE,cAAc,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAA,CAAQ,CAAA,EAAA,CAC7C,IASF,CAAA,EAAA,CACF,CACR;AAEL;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BondsData } from '../../types/bonds';
|
|
2
|
+
export declare function calculateOptimizationData(inputAmount: string, userPoints: string | undefined, bond: BondsData, inputTokenPriceUsd?: number, abondPriceUsd?: number): {
|
|
3
|
+
tierBoostPoints: number;
|
|
4
|
+
highestProfitableTier: {
|
|
5
|
+
tier: number;
|
|
6
|
+
tierName: string;
|
|
7
|
+
isProfitable: boolean;
|
|
8
|
+
tierCostUSD: number;
|
|
9
|
+
minBreakevenWithFeeUSD: number;
|
|
10
|
+
necessaryPointsToUpgrade: number;
|
|
11
|
+
};
|
|
12
|
+
data: {
|
|
13
|
+
tier: number;
|
|
14
|
+
tierName: string;
|
|
15
|
+
isProfitable: boolean;
|
|
16
|
+
tierCostUSD: number;
|
|
17
|
+
minBreakevenWithFeeUSD: number;
|
|
18
|
+
necessaryPointsToUpgrade: number;
|
|
19
|
+
}[];
|
|
20
|
+
} | null;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { findHighestTrueBondPrice } from '../../utils/bondPriceHelpers.js';
|
|
2
|
+
import { getUserTier, TIERS_NAMES } from '../../state/tiers/useTierPoints.js';
|
|
3
|
+
|
|
4
|
+
const ABOND_PRICE_SAFETY_BUFFER_MIN = 0.05; // 5% floor
|
|
5
|
+
const ABOND_PRICE_SAFETY_BUFFER_SCALE = 0.0001; // 0.01% of rawTierCostUsd
|
|
6
|
+
function calculateOptimizationData(inputAmount, userPoints = '0', bond, inputTokenPriceUsd = 0, abondPriceUsd) {
|
|
7
|
+
const { trueBondPrices } = bond;
|
|
8
|
+
if (!trueBondPrices) {
|
|
9
|
+
console.log('no truebondprices');
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (!abondPriceUsd) {
|
|
13
|
+
console.log('No Abond Price');
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (inputTokenPriceUsd <= 0) {
|
|
17
|
+
console.log('missing token price');
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const currentTierData = findHighestTrueBondPrice(userPoints, trueBondPrices);
|
|
21
|
+
const currentTier = getUserTier(userPoints);
|
|
22
|
+
const bonus_curr = 1 + currentTierData?.bonusWithFee / 100;
|
|
23
|
+
const currentPoints = BigInt(userPoints);
|
|
24
|
+
const inputAmountUSD = parseFloat(inputAmount || '0') * inputTokenPriceUsd;
|
|
25
|
+
const tierBoostRate = (bond.tierBoostRate ?? 0) / 100;
|
|
26
|
+
const tierBoostUsd = inputAmountUSD * tierBoostRate;
|
|
27
|
+
const feeInAbond = tierBoostUsd / abondPriceUsd;
|
|
28
|
+
const tierBoostPoints = feeInAbond * 4;
|
|
29
|
+
const dataToReturn = {};
|
|
30
|
+
for (const tierData of trueBondPrices) {
|
|
31
|
+
if (tierData.boost <= currentTier)
|
|
32
|
+
continue;
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
const tierName = TIERS_NAMES[tierData.boost];
|
|
35
|
+
const pointsNeededWei = BigInt(tierData.points) - currentPoints;
|
|
36
|
+
const abondNeededRaw = Math.ceil(Number(pointsNeededWei) / 1e18 / 4);
|
|
37
|
+
const rawTierCostUsd = abondNeededRaw * abondPriceUsd;
|
|
38
|
+
const dynamicBuffer = Math.max(ABOND_PRICE_SAFETY_BUFFER_MIN, rawTierCostUsd * ABOND_PRICE_SAFETY_BUFFER_SCALE);
|
|
39
|
+
const bufferedAbondPrice = abondPriceUsd * (1 + dynamicBuffer);
|
|
40
|
+
const newBonusWithThisTier = tierData.bonusWithFee;
|
|
41
|
+
const tierCostUsd = abondNeededRaw * bufferedAbondPrice;
|
|
42
|
+
const bonus_new = 1 + newBonusWithThisTier / 100;
|
|
43
|
+
const denominator = bonus_new - bonus_curr + tierBoostRate;
|
|
44
|
+
const minBreakeven = denominator > 0 ? tierCostUsd / denominator : Infinity;
|
|
45
|
+
// for debugging purposes
|
|
46
|
+
// const originalOutputUsd = minBreakeven * bonus_curr
|
|
47
|
+
// const outputAfterUpgrade = minBreakeven * bonus_new - (tierCostUsd - minBreakeven * tierBoostRate)
|
|
48
|
+
const isProfitable = inputAmountUSD > (minBreakeven ?? 0);
|
|
49
|
+
dataToReturn[tierData.boost] = {
|
|
50
|
+
tier: tierData.boost,
|
|
51
|
+
tierName,
|
|
52
|
+
isProfitable,
|
|
53
|
+
tierCostUSD: tierCostUsd,
|
|
54
|
+
minBreakevenWithFeeUSD: minBreakeven,
|
|
55
|
+
necessaryPointsToUpgrade: abondNeededRaw * 4,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const profitableTiers = Object.values(dataToReturn).filter((item) => item.isProfitable);
|
|
59
|
+
const highestProfitableTier = profitableTiers[profitableTiers.length - 1];
|
|
60
|
+
return { tierBoostPoints, highestProfitableTier, data: Object.values(dataToReturn) };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { calculateOptimizationData };
|
|
64
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/views/BuyBond/utils.ts"],"sourcesContent":["import { BondsData } from '../../types/bonds'\nimport { findHighestTrueBondPrice } from '../../utils/bondPriceHelpers'\nimport { getUserTier, NewTiers, TIERS_NAMES } from '../../state/tiers/useTierPoints'\n\nconst ABOND_PRICE_SAFETY_BUFFER_MIN = 0.05 // 5% floor\nconst ABOND_PRICE_SAFETY_BUFFER_SCALE = 0.0001 // 0.01% of rawTierCostUsd\n\nexport function calculateOptimizationData(\n inputAmount: string,\n userPoints = '0',\n bond: BondsData,\n inputTokenPriceUsd = 0,\n abondPriceUsd?: number,\n) {\n const { trueBondPrices } = bond\n\n if (!trueBondPrices) {\n console.log('no truebondprices')\n return null\n }\n if (!abondPriceUsd) {\n console.log('No Abond Price')\n return null\n }\n\n if (inputTokenPriceUsd <= 0) {\n console.log('missing token price')\n return null\n }\n\n const currentTierData = findHighestTrueBondPrice(userPoints, trueBondPrices)\n const currentTier = getUserTier(userPoints)!\n\n const bonus_curr = 1 + currentTierData?.bonusWithFee! / 100\n const currentPoints = BigInt(userPoints)\n\n const inputAmountUSD = parseFloat(inputAmount || '0') * inputTokenPriceUsd\n\n const tierBoostRate = (bond.tierBoostRate ?? 0) / 100\n const tierBoostUsd = inputAmountUSD * tierBoostRate\n const feeInAbond = tierBoostUsd / abondPriceUsd\n const tierBoostPoints = feeInAbond * 4\n\n const dataToReturn: Record<\n number,\n {\n tier: number\n tierName: string\n isProfitable: boolean\n tierCostUSD: number\n minBreakevenWithFeeUSD: number\n necessaryPointsToUpgrade: number\n }\n > = {}\n\n for (const tierData of trueBondPrices) {\n if (tierData.boost <= currentTier) continue\n // @ts-ignore\n const tierName = TIERS_NAMES[tierData.boost]\n\n const pointsNeededWei = BigInt(tierData.points) - currentPoints\n const abondNeededRaw = Math.ceil(Number(pointsNeededWei) / 1e18 / 4)\n\n const rawTierCostUsd = abondNeededRaw * abondPriceUsd\n const dynamicBuffer = Math.max(ABOND_PRICE_SAFETY_BUFFER_MIN, rawTierCostUsd * ABOND_PRICE_SAFETY_BUFFER_SCALE)\n const bufferedAbondPrice = abondPriceUsd * (1 + dynamicBuffer)\n\n const newBonusWithThisTier = tierData.bonusWithFee\n\n const tierCostUsd = abondNeededRaw * bufferedAbondPrice\n const bonus_new = 1 + newBonusWithThisTier / 100\n\n const denominator = bonus_new - bonus_curr + tierBoostRate\n const minBreakeven = denominator > 0 ? tierCostUsd / denominator : Infinity\n\n // for debugging purposes\n // const originalOutputUsd = minBreakeven * bonus_curr\n // const outputAfterUpgrade = minBreakeven * bonus_new - (tierCostUsd - minBreakeven * tierBoostRate)\n\n const isProfitable = inputAmountUSD > (minBreakeven ?? 0)\n\n dataToReturn[tierData.boost] = {\n tier: tierData.boost as NewTiers,\n tierName,\n isProfitable,\n tierCostUSD: tierCostUsd,\n minBreakevenWithFeeUSD: minBreakeven,\n necessaryPointsToUpgrade: abondNeededRaw * 4,\n }\n }\n\n const profitableTiers = Object.values(dataToReturn).filter((item) => item.isProfitable)\n const highestProfitableTier = profitableTiers[profitableTiers.length - 1]\n\n return { tierBoostPoints, highestProfitableTier, data: Object.values(dataToReturn) }\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,6BAA6B,GAAG,IAAI,CAAA;AAC1C,MAAM,+BAA+B,GAAG,MAAM,CAAA;AAExC,SAAU,yBAAyB,CACvC,WAAmB,EACnB,UAAU,GAAG,GAAG,EAChB,IAAe,EACf,kBAAkB,GAAG,CAAC,EACtB,aAAsB,EAAA;AAEtB,IAAA,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI;IAE/B,IAAI,CAAC,cAAc,EAAE;AACnB,QAAA,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAChC,QAAA,OAAO,IAAI;IACb;IACA,IAAI,CAAC,aAAa,EAAE;AAClB,QAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;AAC7B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,IAAI,kBAAkB,IAAI,CAAC,EAAE;AAC3B,QAAA,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;AAClC,QAAA,OAAO,IAAI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AkB;AACvD,QAAA,MAAM,SAAS,GAAG,CAAC,GAAG,oBAAoB,GAAG,GAAG;AAEhD,QAAA,MAAM,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa;AAC1D,QAAA,MAAM,YAAY,GAAG,WAAW,GAAG,CAAC,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ;;;;QAM3E,MAAM,YAAY,GAAG,cAAc,IAAI,YAAY,IAAI,CAAC,CAAC;AAEzD,QAAA,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG;YAC7B,IAAI,EAAE,QAAQ,CAAC,KAAiB;YAChC,QAAQ;YACR,YAAY;AACZ,YAAA,WAAW,EAAE,WAAW;AACxB,YAAA,sBAAsB,EAAE,YAAY;YACpC,wBAAwB,EAAE,cAAc,GAAG,CAAC;SAC7C;IACH;IAEA,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,YAAY,CAAC;IACvF,MAAM,qBAAqB,GAAG,eAAe,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;AAEzE,IAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;AACtF;;;;"}
|
|
@@ -9,7 +9,6 @@ import BondCards from '../BuyBond/components/BondCards/BondCards.js';
|
|
|
9
9
|
import ProjectInfo from './components/ProjectInfo/index.js';
|
|
10
10
|
import BondStats from './components/BondStats/index.js';
|
|
11
11
|
import BondLeaderboard from './components/BondLeaderboard/index.js';
|
|
12
|
-
import PriceChart from './components/PriceChart/index.js';
|
|
13
12
|
import BuyComponent from '../BuyBond/BuyComponent.js';
|
|
14
13
|
import useTokenPrices from '../../state/tokenPrices/useTokenPrices.js';
|
|
15
14
|
import useHistoricalPrice from '../../state/historicalPrice/useHistoricalPrice.js';
|
|
@@ -40,13 +39,15 @@ const ProjectView = ({ bondAddress, bondChain }) => {
|
|
|
40
39
|
'&& > div > div': {
|
|
41
40
|
background: 'white2',
|
|
42
41
|
},
|
|
43
|
-
}, children: jsx(BondCards, { bondData: bondData }) })), bondData ? (jsx(Fragment, { children: jsxs(Flex, { sx: { width: '100%', flexDirection: 'column', mt: '10px' }, children: [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
}, children: jsx(BondCards, { bondData: bondData }) })), bondData ? (jsx(Fragment, { children: jsxs(Flex, { sx: { width: '100%', flexDirection: 'column', mt: '10px' }, children: [jsx(Flex, { sx: { width: '100%', flexDirection: ['column', 'column', 'column', 'row'], alignItems: 'stretch' }, children: jsx(Flex, { sx: {
|
|
43
|
+
background: 'white2',
|
|
44
|
+
borderRadius: 'normal',
|
|
45
|
+
// TODO: uncomment this
|
|
46
|
+
width: ['100%', '100%', '100%', '50%'],
|
|
47
|
+
// width: '100%',
|
|
48
|
+
//
|
|
49
|
+
mt: '5px',
|
|
50
|
+
}, children: jsx(BuyComponent, { bondAddress: bondData?.contractAddress?.[bondData.chainId], bondChain: bondData.chainId, isProjectView: true }) }) }), jsx(Flex, { sx: { width: '100%', mt: '10px' }, children: jsx(ProjectInfo, { selectedBond2: bondData }) }), jsx(Flex, { sx: { width: '100%', mt: '10px' }, children: jsx(BondStats, { selectedBond: bondData }) }), jsx(Flex, { sx: { width: '100%', mt: '10px', mb: '50px' }, children: jsx(BondLeaderboard, { selectedBond: bondData }) })] }) })) : (jsx(Flex, { sx: { width: '100%', justifyContent: 'center', fontSize: '12px', fontWeight: 500 }, children: "Loading..." }))] }));
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
export { ProjectView as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectView.js","sources":["../../../src/views/ProjectView/ProjectView.tsx"],"sourcesContent":["import React, { useEffect } from 'react'\nimport useBondsData from '../../state/bonds/useBondsData'\nimport Flex from '../../components/uikit-sdk/Flex'\nimport { styles } from './styles'\nimport RecommendationCards from './components/RecommendationCards'\nimport NavPanel from './components/NavPanel'\nimport BondCards from '../BuyBond/components/BondCards/BondCards'\nimport ProjectInfo from './components/ProjectInfo'\nimport BondStats from './components/BondStats'\nimport BondLeaderboard from './components/BondLeaderboard'\nimport PriceChart from './components/PriceChart'\nimport BuyBond from '../BuyBond/BuyComponent'\nimport useTokenPrices from '../../state/tokenPrices/useTokenPrices'\nimport useHistoricalPrice from '../../state/historicalPrice/useHistoricalPrice'\n\nexport interface HistoricalPrices {\n timestamp: string\n open: number\n close: number\n}\n\nexport interface ProjectViewProps {\n bondAddress: string\n bondChain: string\n}\n\nconst ProjectView: React.FC<ProjectViewProps> = ({ bondAddress, bondChain }) => {\n // Hooks\n const { data: bonds, refetch } = useBondsData()\n const { data: tokenPrices } = useTokenPrices()\n const bondData = bonds?.find(\n (bond) =>\n bond?.contractAddress?.[bond.chainId]?.toLowerCase() === (bondAddress as string)?.toLowerCase() &&\n (bondChain as string) === bond.chainId.toString(),\n )\n\n const { data: historicalPrices } = useHistoricalPrice(bondData?.cgId)\n\n useEffect(() => {\n if ((bonds?.length ?? 0) > 0 && !bondData) {\n window.location.href = '/bonds'\n }\n })\n\n useEffect(() => {\n if (Object.keys(tokenPrices ?? {})?.length > 0 && bonds?.length === 0) {\n console.log('Found prices and no bonds, realtimeapi failed. Refetching bonds')\n refetch()\n }\n /* eslint-disable react-hooks/exhaustive-deps */\n }, [Object.keys(tokenPrices ?? {})?.length, bonds?.length, refetch])\n\n return (\n <Flex sx={styles.mainViewContainer}>\n <RecommendationCards />\n <NavPanel contractAddress={bondData?.contractAddress?.[bondData.chainId]} />\n {bondData && (\n <Flex\n sx={{\n width: '100%',\n mt: '10px',\n display: ['none', 'none', 'none', 'block'],\n '&& > div > div': {\n background: 'white2',\n },\n }}\n >\n <BondCards bondData={bondData} />\n </Flex>\n )}\n {bondData ? (\n <>\n <Flex sx={{ width: '100%', flexDirection: 'column', mt: '10px' }}>\n <Flex sx={{ width: '100%', flexDirection: ['column', 'column', 'column', 'row'], alignItems: 'stretch' }}>\n <Flex\n sx={{\n background: 'white2',\n borderRadius: 'normal',\n //
|
|
1
|
+
{"version":3,"file":"ProjectView.js","sources":["../../../src/views/ProjectView/ProjectView.tsx"],"sourcesContent":["import React, { useEffect } from 'react'\nimport useBondsData from '../../state/bonds/useBondsData'\nimport Flex from '../../components/uikit-sdk/Flex'\nimport { styles } from './styles'\nimport RecommendationCards from './components/RecommendationCards'\nimport NavPanel from './components/NavPanel'\nimport BondCards from '../BuyBond/components/BondCards/BondCards'\nimport ProjectInfo from './components/ProjectInfo'\nimport BondStats from './components/BondStats'\nimport BondLeaderboard from './components/BondLeaderboard'\nimport PriceChart from './components/PriceChart'\nimport BuyBond from '../BuyBond/BuyComponent'\nimport useTokenPrices from '../../state/tokenPrices/useTokenPrices'\nimport useHistoricalPrice from '../../state/historicalPrice/useHistoricalPrice'\n\nexport interface HistoricalPrices {\n timestamp: string\n open: number\n close: number\n}\n\nexport interface ProjectViewProps {\n bondAddress: string\n bondChain: string\n}\n\nconst ProjectView: React.FC<ProjectViewProps> = ({ bondAddress, bondChain }) => {\n // Hooks\n const { data: bonds, refetch } = useBondsData()\n const { data: tokenPrices } = useTokenPrices()\n const bondData = bonds?.find(\n (bond) =>\n bond?.contractAddress?.[bond.chainId]?.toLowerCase() === (bondAddress as string)?.toLowerCase() &&\n (bondChain as string) === bond.chainId.toString(),\n )\n\n const { data: historicalPrices } = useHistoricalPrice(bondData?.cgId)\n\n useEffect(() => {\n if ((bonds?.length ?? 0) > 0 && !bondData) {\n window.location.href = '/bonds'\n }\n })\n\n useEffect(() => {\n if (Object.keys(tokenPrices ?? {})?.length > 0 && bonds?.length === 0) {\n console.log('Found prices and no bonds, realtimeapi failed. Refetching bonds')\n refetch()\n }\n /* eslint-disable react-hooks/exhaustive-deps */\n }, [Object.keys(tokenPrices ?? {})?.length, bonds?.length, refetch])\n\n return (\n <Flex sx={styles.mainViewContainer}>\n <RecommendationCards />\n <NavPanel contractAddress={bondData?.contractAddress?.[bondData.chainId]} />\n {bondData && (\n <Flex\n sx={{\n width: '100%',\n mt: '10px',\n display: ['none', 'none', 'none', 'block'],\n '&& > div > div': {\n background: 'white2',\n },\n }}\n >\n <BondCards bondData={bondData} />\n </Flex>\n )}\n {bondData ? (\n <>\n <Flex sx={{ width: '100%', flexDirection: 'column', mt: '10px' }}>\n <Flex sx={{ width: '100%', flexDirection: ['column', 'column', 'column', 'row'], alignItems: 'stretch' }}>\n <Flex\n sx={{\n background: 'white2',\n borderRadius: 'normal',\n // TODO: uncomment this\n width: ['100%', '100%', '100%', '50%'],\n // width: '100%',\n //\n mt: '5px',\n }}\n >\n <BuyBond\n bondAddress={bondData?.contractAddress?.[bondData.chainId]}\n bondChain={bondData.chainId}\n isProjectView\n />\n </Flex>\n {/*TODO: uncomment this*/}\n {/*<PriceChart selectedBond={bondData} historicalPrices={historicalPrices} />*/}\n </Flex>\n <Flex sx={{ width: '100%', mt: '10px' }}>\n <ProjectInfo selectedBond2={bondData} />\n </Flex>\n <Flex sx={{ width: '100%', mt: '10px' }}>\n <BondStats selectedBond={bondData} />\n </Flex>\n <Flex sx={{ width: '100%', mt: '10px', mb: '50px' }}>\n <BondLeaderboard selectedBond={bondData} />\n </Flex>\n </Flex>\n </>\n ) : (\n <Flex sx={{ width: '100%', justifyContent: 'center', fontSize: '12px', fontWeight: 500 }}>Loading...</Flex>\n )}\n </Flex>\n )\n}\n\nexport default ProjectView\n"],"names":["_jsxs","_jsx","_Fragment","BuyBond"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAM,WAAW,GAA+B,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,KAAI;;IAE7E,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,YAAY,EAAE;IAC/C,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE;IAC9C,MAAM,QAAQ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,CAAC,WAAW,EAAA,EAAC,aAAa,EAAE,QAAQ,EAAA,CAAI,EAAA,CACnC,EACPA,GAAA,CAAC,IAAI,EAAA,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,YACrCA,GAAA,CAAC,SAAS,EAAA,EAAC,YAAY,EAAE,QAAQ,EAAA,CAAI,EAAA,CAChC,EACPA,GAAA,CAAC,IAAI,EAAA,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAA,QAAA,EACjDA,GAAA,CAAC,eAAe,EAAA,EAAC,YAAY,EAAE,QAAQ,EAAA,CAAI,EAAA,CACtC,CAAA,EAAA,CACF,EAAA,CACN,KAEHA,GAAA,CAAC,IAAI,EAAA,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,EAAA,QAAA,EAAA,YAAA,EAAA,CAAmB,CAC5G,CAAA,EAAA,CACI;AAEX;;;;"}
|
|
@@ -4,7 +4,6 @@ import { useTopTags } from '../../../../hooks/useTopTags.js';
|
|
|
4
4
|
import useBondsData from '../../../../state/bonds/useBondsData.js';
|
|
5
5
|
import Flex from '../../../../components/uikit-sdk/Flex/index.js';
|
|
6
6
|
import RecommendationSelector from '../../../../components/MenuSelect/RecommendationSelector.js';
|
|
7
|
-
import SmallRecommendationCard from '../../../Bonds/components/RecommendationCards/SmallRecommendationCard.js';
|
|
8
7
|
import { TIERS_WEIGHT } from '../../../../state/tiers/useTierPoints.js';
|
|
9
8
|
import { LaunchBondTiers } from '@ape.swap/apeswap-lists';
|
|
10
9
|
import useGetBondRecommendations from '../../../../state/recommendations/useGetBondRecommendations.js';
|
|
@@ -38,7 +37,7 @@ const RecommendationCards = () => {
|
|
|
38
37
|
? a.discount
|
|
39
38
|
: (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], a?.trueBondPrices)?.bonus ?? 0)))
|
|
40
39
|
?.slice(0, 3);
|
|
41
|
-
|
|
40
|
+
slicedBonds?.map((bond) => {
|
|
42
41
|
let contractAddress = '';
|
|
43
42
|
if ('contractAddress' in bond) {
|
|
44
43
|
contractAddress = bond.contractAddress;
|
|
@@ -78,11 +77,7 @@ const RecommendationCards = () => {
|
|
|
78
77
|
}, onClick: () => window.open('/apebond-ai', '_blank') }) })] }), jsx(Flex, { sx: {
|
|
79
78
|
my: '10px',
|
|
80
79
|
minHeight: '47.45px',
|
|
81
|
-
}
|
|
82
|
-
parsedBondsToRender.length > 0 &&
|
|
83
|
-
parsedBondsToRender.map((bond, index) => {
|
|
84
|
-
return jsx(SmallRecommendationCard, { recommendation: bond }, `${bond.payoutTokenName}-${index}`);
|
|
85
|
-
}) })] }));
|
|
80
|
+
} })] }));
|
|
86
81
|
};
|
|
87
82
|
|
|
88
83
|
export { RecommendationCards as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/views/ProjectView/components/RecommendationCards/index.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport { useTopTags } from '../../../../hooks/useTopTags'\nimport useBondsData from '../../../../state/bonds/useBondsData'\nimport { SmallCardBond } from '../../../Bonds/components/RecommendationCards'\nimport Flex from '../../../../components/uikit-sdk/Flex'\nimport RecommendationSelector from '../../../../components/MenuSelect/RecommendationSelector'\nimport SmallRecommendationCard from '../../../Bonds/components/RecommendationCards/SmallRecommendationCard'\nimport { TIERS_WEIGHT } from '../../../../state/tiers/useTierPoints'\nimport { LaunchBondTiers } from '@ape.swap/apeswap-lists'\nimport useGetBondRecommendations from '../../../../state/recommendations/useGetBondRecommendations'\nimport { useHotBondContracts } from '../../../../state/hotBonds/useHotBonds'\nimport { findHighestTrueBondPrice } from '../../../../utils/bondPriceHelpers'\nimport useEVMAccount from '../../../../hooks/accounts/useEVMAccount'\n\nconst RecommendationCards = () => {\n const topTags = useTopTags()\n const { address: account } = useEVMAccount()\n const options = account ? ['For You', 'Hot', ...topTags] : ['Hot', ...topTags]\n const [activeOption, setActiveOption] = useState(options[0])\n const { data: hotBonds } = useHotBondContracts()\n\n const { data: forYouRecommendations } = useGetBondRecommendations(account, undefined, '3')\n const { data: bonds } = useBondsData()\n const sortedBonds =\n bonds && bonds?.length > 0\n ? [...bonds].sort(\n (a, b) =>\n (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], b?.trueBondPrices)?.bonus ?? 0) -\n (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], a?.trueBondPrices)?.bonus ?? 0),\n )\n : undefined\n\n const filteredBonds = sortedBonds?.filter(\n (bond) =>\n bond?.tags?.includes(activeOption) &&\n !bond?.soldOut &&\n (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], bond?.trueBondPrices)?.bonus ?? 0) < 50,\n )\n\n // This should come from the API\n const hotRecommendations = sortedBonds?.filter((bond) =>\n hotBonds?.includes(bond?.contractAddress?.[bond.chainId]?.toLowerCase() ?? ''),\n )\n\n const selectedBonds =\n activeOption === 'For You' ? forYouRecommendations : activeOption === 'Hot' ? hotRecommendations : filteredBonds\n\n const slicedBonds = selectedBonds\n ?.sort(\n (a, b) =>\n ('discount' in b\n ? b.discount\n : (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], b?.trueBondPrices)?.bonus ?? 0))! -\n ('discount' in a\n ? a.discount\n : (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], a?.trueBondPrices)?.bonus ?? 0))!,\n )\n ?.slice(0, 3)\n\n const parsedBondsToRender: SmallCardBond[] | undefined = slicedBonds?.map((bond) => {\n let contractAddress = ''\n if ('contractAddress' in bond) {\n contractAddress = bond.contractAddress as string\n }\n if ('billAddress' in bond) {\n contractAddress = bond.billAddress as string\n }\n\n return {\n payoutTokenName: bond?.showcaseTokenName ?? '',\n contractAddress,\n vestingTerm: bond.vestingTerm ?? 0,\n bonus:\n 'bonus' in bond\n ? bond.bonus\n : (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], bond?.trueBondPrices)?.bonusWithFee ?? 0),\n chainId: bond.chainId,\n }\n })\n\n useEffect(() => {\n if (account) {\n setActiveOption('For You')\n } else {\n setActiveOption('Hot')\n }\n }, [account])\n\n return (\n <Flex sx={{ mt: '15px', flexDirection: 'column', width: '100%', display: ['none', 'none', 'none', 'flex'] }}>\n <Flex sx={{ width: '100%', justifyContent: 'space-between' }}>\n <Flex>\n <Flex\n sx={{\n width: ['60px', '60px', '60px', 'unset'],\n mr: ['0px', '0px', '0px', '15px'],\n alignItems: 'center',\n color: 'grey',\n fontSize: ['11px'],\n fontWeight: 500,\n }}\n >\n BONDS MARKETS:\n </Flex>\n <RecommendationSelector options={options} activeOption={activeOption} setActiveOption={setActiveOption} />\n </Flex>\n <Flex sx={{ display: ['none', 'none', 'none', 'flex'] }}>\n <img\n width={190}\n height={20}\n alt=\"poweredBy\"\n src=\"/images/bills/powered.png\"\n sx={{\n width: '190px',\n height: '20px',\n cursor: 'pointer',\n }}\n onClick={() => window.open('/apebond-ai', '_blank')}\n />\n </Flex>\n </Flex>\n <Flex\n sx={{\n my: '10px',\n minHeight: '47.45px',\n }}\n >\n {parsedBondsToRender
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/views/ProjectView/components/RecommendationCards/index.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport { useTopTags } from '../../../../hooks/useTopTags'\nimport useBondsData from '../../../../state/bonds/useBondsData'\nimport { SmallCardBond } from '../../../Bonds/components/RecommendationCards'\nimport Flex from '../../../../components/uikit-sdk/Flex'\nimport RecommendationSelector from '../../../../components/MenuSelect/RecommendationSelector'\nimport SmallRecommendationCard from '../../../Bonds/components/RecommendationCards/SmallRecommendationCard'\nimport { TIERS_WEIGHT } from '../../../../state/tiers/useTierPoints'\nimport { LaunchBondTiers } from '@ape.swap/apeswap-lists'\nimport useGetBondRecommendations from '../../../../state/recommendations/useGetBondRecommendations'\nimport { useHotBondContracts } from '../../../../state/hotBonds/useHotBonds'\nimport { findHighestTrueBondPrice } from '../../../../utils/bondPriceHelpers'\nimport useEVMAccount from '../../../../hooks/accounts/useEVMAccount'\n\nconst RecommendationCards = () => {\n const topTags = useTopTags()\n const { address: account } = useEVMAccount()\n const options = account ? ['For You', 'Hot', ...topTags] : ['Hot', ...topTags]\n const [activeOption, setActiveOption] = useState(options[0])\n const { data: hotBonds } = useHotBondContracts()\n\n const { data: forYouRecommendations } = useGetBondRecommendations(account, undefined, '3')\n const { data: bonds } = useBondsData()\n const sortedBonds =\n bonds && bonds?.length > 0\n ? [...bonds].sort(\n (a, b) =>\n (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], b?.trueBondPrices)?.bonus ?? 0) -\n (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], a?.trueBondPrices)?.bonus ?? 0),\n )\n : undefined\n\n const filteredBonds = sortedBonds?.filter(\n (bond) =>\n bond?.tags?.includes(activeOption) &&\n !bond?.soldOut &&\n (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], bond?.trueBondPrices)?.bonus ?? 0) < 50,\n )\n\n // This should come from the API\n const hotRecommendations = sortedBonds?.filter((bond) =>\n hotBonds?.includes(bond?.contractAddress?.[bond.chainId]?.toLowerCase() ?? ''),\n )\n\n const selectedBonds =\n activeOption === 'For You' ? forYouRecommendations : activeOption === 'Hot' ? hotRecommendations : filteredBonds\n\n const slicedBonds = selectedBonds\n ?.sort(\n (a, b) =>\n ('discount' in b\n ? b.discount\n : (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], b?.trueBondPrices)?.bonus ?? 0))! -\n ('discount' in a\n ? a.discount\n : (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], a?.trueBondPrices)?.bonus ?? 0))!,\n )\n ?.slice(0, 3)\n\n const parsedBondsToRender: SmallCardBond[] | undefined = slicedBonds?.map((bond) => {\n let contractAddress = ''\n if ('contractAddress' in bond) {\n contractAddress = bond.contractAddress as string\n }\n if ('billAddress' in bond) {\n contractAddress = bond.billAddress as string\n }\n\n return {\n payoutTokenName: bond?.showcaseTokenName ?? '',\n contractAddress,\n vestingTerm: bond.vestingTerm ?? 0,\n bonus:\n 'bonus' in bond\n ? bond.bonus\n : (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], bond?.trueBondPrices)?.bonusWithFee ?? 0),\n chainId: bond.chainId,\n }\n })\n\n useEffect(() => {\n if (account) {\n setActiveOption('For You')\n } else {\n setActiveOption('Hot')\n }\n }, [account])\n\n return (\n <Flex sx={{ mt: '15px', flexDirection: 'column', width: '100%', display: ['none', 'none', 'none', 'flex'] }}>\n <Flex sx={{ width: '100%', justifyContent: 'space-between' }}>\n <Flex>\n <Flex\n sx={{\n width: ['60px', '60px', '60px', 'unset'],\n mr: ['0px', '0px', '0px', '15px'],\n alignItems: 'center',\n color: 'grey',\n fontSize: ['11px'],\n fontWeight: 500,\n }}\n >\n BONDS MARKETS:\n </Flex>\n <RecommendationSelector options={options} activeOption={activeOption} setActiveOption={setActiveOption} />\n </Flex>\n <Flex sx={{ display: ['none', 'none', 'none', 'flex'] }}>\n <img\n width={190}\n height={20}\n alt=\"poweredBy\"\n src=\"/images/bills/powered.png\"\n sx={{\n width: '190px',\n height: '20px',\n cursor: 'pointer',\n }}\n onClick={() => window.open('/apebond-ai', '_blank')}\n />\n </Flex>\n </Flex>\n <Flex\n sx={{\n my: '10px',\n minHeight: '47.45px',\n }}\n >\n {/*{parsedBondsToRender &&*/}\n {/* parsedBondsToRender.length > 0 &&*/}\n {/* parsedBondsToRender.map((bond, index) => {*/}\n {/* return <SmallRecommendationCard recommendation={bond} key={`${bond.payoutTokenName}-${index}`} />*/}\n {/* })}*/}\n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,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAA,CAAI,CAAA,EAAA,CACrG,EACPA,GAAA,CAAC,IAAI,EAAA,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAA,QAAA,EACrDA,GAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,EAAE,EACV,GAAG,EAAC,WAAW,EACf,GAAG,EAAC,2BAA2B,EAC/B,EAAE,EAAE;AACF,gCAAA,KAAK,EAAE,OAAO;AACd,gCAAA,MAAM,EAAE,MAAM;AACd,gCAAA,MAAM,EAAE,SAAS;6BAClB,EACD,OAAO,EAAE,MAAM,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,GACnD,EAAA,CACG,CAAA,EAAA,CACF,EACPA,GAAA,CAAC,IAAI,EAAA,EACH,EAAE,EAAE;AACF,oBAAA,EAAE,EAAE,MAAM;AACV,oBAAA,SAAS,EAAE,SAAS;iBACrB,EAAA,CAOI,CAAA,EAAA,CACF;AAEX;;;;"}
|
|
@@ -8,7 +8,7 @@ import PreTgeActions from './PreTGEActions.js';
|
|
|
8
8
|
import { getBalanceNumber } from '../../../../utils/getBalanceNumber.js';
|
|
9
9
|
import BigNumber from 'bignumber.js';
|
|
10
10
|
import { formatTimeLeft, getTimePeriods } from '../../../../utils/getTimePeriods.js';
|
|
11
|
-
import { formatNumberSI
|
|
11
|
+
import { formatNumberSI } from '../../../../utils/formatNumber.js';
|
|
12
12
|
import { getPendingVestingString } from '../../../../utils/displayHelpers.js';
|
|
13
13
|
|
|
14
14
|
const UserBondRowPreTGE = ({ userBond }) => {
|
|
@@ -37,7 +37,7 @@ const UserBondRowPreTGE = ({ userBond }) => {
|
|
|
37
37
|
const pendingUSD = pendingAmount * (userBond?.earnTokenPrice ?? 0);
|
|
38
38
|
return (jsxs("div", { className: "your-bonds", onClick: () => null, children: [jsxs("div", { className: "token-info-container", children: [jsx(TokenInfoAndName, { tokenSymbol: userBond.earnToken.symbol, chain: userBond.chainId, tag: userBond.tags?.[0], vestEnds: isRedeemable ? 'Claim now!' : !hasRedeemed ? `Claim in ${redeemableIn}` : `Ends in ${vestingString}`, isHotBond: true }), jsx("div", { className: "tooltip-column", children: jsx(TooltipBubble, { className: "tooltip-bubble", body: jsx(BondInfoTooltip, { earnTokenContract: userBond?.earnToken.address[userBond?.chainId] || '', earnTokenSymbol: userBond?.earnToken.symbol || '', bondContract: userBond?.contractAddress?.[userBond?.chainId] || '', projectLink: userBond?.projectLink, twitter: userBond?.twitter, chain: userBond?.chainId }), width: "205px", placement: "bottomRight", transformTip: "translate(5%, 0%)", children: jsx(Flex, { sx: {
|
|
39
39
|
opacity: 0.8,
|
|
40
|
-
}, children: jsx(Svg, { icon: "more", width: "25px" }) }) }) })] }), jsxs("div", { className: "your-bonds-columns-container", children: [jsx(Flex, { sx: { display: ['none', 'none', 'none', 'flex'], width: '125px' } }), jsxs("div", { className: "your-bonds-content", children: [jsx("div", { className: "your-bonds-content-title", children: "Claimable" }), jsxs("div", { className: "your-bonds-content-tokens-amount", children: [formatNumberSI(claimableAmount, 3), jsxs("div", { className: "your-bonds-content-tokens-usd-amount", children: ["($",
|
|
40
|
+
}, children: jsx(Svg, { icon: "more", width: "25px" }) }) }) })] }), jsxs("div", { className: "your-bonds-columns-container", children: [jsx(Flex, { sx: { display: ['none', 'none', 'none', 'flex'], width: '125px' } }), jsxs("div", { className: "your-bonds-content", children: [jsx("div", { className: "your-bonds-content-title", children: "Claimable" }), jsxs("div", { className: "your-bonds-content-tokens-amount", children: [formatNumberSI(claimableAmount, 3), jsxs("div", { className: "your-bonds-content-tokens-usd-amount", children: ["($", formatNumberSI(claimableUSD), ")"] })] })] }), jsxs("div", { className: "your-bonds-content", children: [jsx("div", { className: "your-bonds-content-title", children: "Pending" }), jsxs("div", { className: "your-bonds-content-tokens-amount", children: [formatNumberSI(pendingAmount, 3), jsxs("div", { className: "your-bonds-content-tokens-usd-amount", children: ["($", formatNumberSI(pendingUSD), ")"] })] })] }), jsx("div", { className: "your-bonds-content hide-mobile", children: vestingString }), jsx("div", { className: "your-bonds-column-button", children: jsx(PreTgeActions, { userBond: userBond }) })] })] }));
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
export { UserBondRowPreTGE as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserBondRowPreTGE.js","sources":["../../../../../src/views/YourBonds/components/UserBondRow/UserBondRowPreTGE.tsx"],"sourcesContent":["import React from 'react'\nimport TokenInfoAndName from '../../../../components/TokenInfoAndName'\nimport Svg from '../../../../components/uikit-sdk/Svg'\nimport TooltipBubble from '../../../../components/uikit-sdk/TooltipBubble'\nimport Tooltip from '../../../../components/Tooltip/Tooltip'\nimport { Flex } from 'theme-ui'\nimport PreTgeActions from './PreTGEActions'\nimport { getBalanceNumber } from '../../../../utils/getBalanceNumber'\nimport BigNumber from 'bignumber.js'\nimport { formatTimeLeft, getTimePeriods } from '../../../../utils/getTimePeriods'\nimport { formatNumberSI
|
|
1
|
+
{"version":3,"file":"UserBondRowPreTGE.js","sources":["../../../../../src/views/YourBonds/components/UserBondRow/UserBondRowPreTGE.tsx"],"sourcesContent":["import React from 'react'\nimport TokenInfoAndName from '../../../../components/TokenInfoAndName'\nimport Svg from '../../../../components/uikit-sdk/Svg'\nimport TooltipBubble from '../../../../components/uikit-sdk/TooltipBubble'\nimport Tooltip from '../../../../components/Tooltip/Tooltip'\nimport { Flex } from 'theme-ui'\nimport PreTgeActions from './PreTGEActions'\nimport { getBalanceNumber } from '../../../../utils/getBalanceNumber'\nimport BigNumber from 'bignumber.js'\nimport { formatTimeLeft, getTimePeriods } from '../../../../utils/getTimePeriods'\nimport { formatNumberSI } from '../../../../utils/formatNumber'\nimport { getPendingVestingString } from '../../../../utils/displayHelpers'\nimport { PreTGEUserBonds } from '../../../../state/bonds/useUserBondsPreTGE'\n\nconst UserBondRowPreTGE = ({ userBond }: { userBond: PreTGEUserBonds }) => {\n const saleFinalized = userBond.finalized\n const hasRedeemed = userBond?.accountInfo?.hasRedeemed\n const isRedeemable = !hasRedeemed && saleFinalized\n\n const redeemableIn = formatTimeLeft((userBond?.redeemTime ?? 0) - new Date().getTime() / 1000, true, true)\n const depositAmount = getBalanceNumber(\n new BigNumber(userBond?.accountInfo?.depositAmount ?? '0'),\n userBond?.lpToken?.decimals?.[userBond?.chainId]!,\n )\n const truePricePaid = getBalanceNumber(\n new BigNumber(userBond?.accountInfo?.truePricePaid ?? '0'),\n userBond?.lpToken?.decimals?.[userBond?.chainId]!,\n )\n\n const initialRelease = userBond?.initialRelease\n const vestingTimePeriods = getTimePeriods(userBond.vestingTerm, false)\n const vestingString = hasRedeemed\n ? getPendingVestingString(userBond?.userOwnedBillsData)\n : initialRelease === 1\n ? `0 D`\n : `${vestingTimePeriods.months} Months`\n\n const userAllocation = depositAmount / (userBond?.initPrice ?? 0)\n const initialReleaseTokens =\n !hasRedeemed && saleFinalized && userBond?.initialRelease ? userAllocation * userBond?.initialRelease : 0\n\n // pendingRewards variable follows the naming of the SC, but it actually means currently claimable tokens\n const pendingRewards = getBalanceNumber(\n new BigNumber(userBond?.userOwnedBillsData?.pendingRewards ?? '0'),\n userBond?.earnToken?.decimals?.[userBond.chainId]!,\n )\n // payout variable follows the naming of the SC, but it actually means total tokens vested\n const payout = getBalanceNumber(\n new BigNumber(userBond?.userOwnedBillsData?.payout ?? '0'),\n userBond?.earnToken?.decimals?.[userBond.chainId]!,\n )\n\n const claimableAmount = hasRedeemed ? pendingRewards : initialReleaseTokens\n const claimableUSD = claimableAmount * (userBond.initPrice ?? 0)\n const pendingAmount = hasRedeemed ? payout : depositAmount / truePricePaid\n const pendingUSD = pendingAmount * (userBond?.earnTokenPrice ?? 0)\n\n return (\n <div className=\"your-bonds\" onClick={() => null}>\n <div className=\"token-info-container\">\n <TokenInfoAndName\n tokenSymbol={userBond.earnToken.symbol}\n chain={userBond.chainId}\n tag={userBond.tags?.[0]}\n vestEnds={\n isRedeemable ? 'Claim now!' : !hasRedeemed ? `Claim in ${redeemableIn}` : `Ends in ${vestingString}`\n }\n isHotBond\n />\n <div className=\"tooltip-column\">\n <TooltipBubble\n className=\"tooltip-bubble\"\n body={\n <Tooltip\n earnTokenContract={userBond?.earnToken.address[userBond?.chainId] || ''}\n earnTokenSymbol={userBond?.earnToken.symbol || ''}\n bondContract={userBond?.contractAddress?.[userBond?.chainId] || ''}\n projectLink={userBond?.projectLink}\n twitter={userBond?.twitter}\n chain={userBond?.chainId}\n />\n }\n width=\"205px\"\n placement=\"bottomRight\"\n transformTip=\"translate(5%, 0%)\"\n >\n <Flex\n sx={{\n opacity: 0.8,\n }}\n >\n <Svg icon=\"more\" width=\"25px\" />\n </Flex>\n </TooltipBubble>\n </div>\n </div>\n <div className=\"your-bonds-columns-container\">\n <Flex sx={{ display: ['none', 'none', 'none', 'flex'], width: '125px' }} />\n <div className=\"your-bonds-content\">\n <div className=\"your-bonds-content-title\">Claimable</div>\n <div className=\"your-bonds-content-tokens-amount\">\n {formatNumberSI(claimableAmount, 3)}\n <div className=\"your-bonds-content-tokens-usd-amount\">(${formatNumberSI(claimableUSD)})</div>\n </div>\n </div>\n <div className=\"your-bonds-content\">\n <div className=\"your-bonds-content-title\">Pending</div>\n <div className=\"your-bonds-content-tokens-amount\">\n {formatNumberSI(pendingAmount, 3)}\n <div className=\"your-bonds-content-tokens-usd-amount\">(${formatNumberSI(pendingUSD)})</div>\n </div>\n </div>\n <div className=\"your-bonds-content hide-mobile\">{vestingString}</div>\n <div className=\"your-bonds-column-button\">\n <PreTgeActions userBond={userBond} />\n </div>\n </div>\n </div>\n )\n}\n\nexport default UserBondRowPreTGE\n"],"names":["_jsxs","_jsx","Tooltip"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,iBAAiB,GAAG,CAAC,EAAE,QAAQ,EAAiC,KAAI;AACxE,IAAA,MAAM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A,KAAA,EAAA,EAAK,SAAS,EAAC,sCAAsC,EAAA,QAAA,EAAA,CAAA,IAAA,EAAI,cAAc,CAAC,YAAY,CAAC,EAAA,GAAA,CAAA,EAAA,CAAQ,CAAA,EAAA,CACzF,CAAA,EAAA,CACF,EACNA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,oBAAoB,aACjCC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,0BAA0B,EAAA,QAAA,EAAA,SAAA,EAAA,CAAc,EACvDD,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kCAAkC,EAAA,QAAA,EAAA,CAC9C,cAAc,CAAC,aAAa,EAAE,CAAC,CAAC,EACjCA,IAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,sCAAsC,EAAA,QAAA,EAAA,CAAA,IAAA,EAAI,cAAc,CAAC,UAAU,CAAC,EAAA,GAAA,CAAA,EAAA,CAAQ,CAAA,EAAA,CACvF,CAAA,EAAA,CACF,EACNC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,gCAAgC,YAAE,aAAa,EAAA,CAAO,EACrEA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,0BAA0B,EAAA,QAAA,EACvCA,IAAC,aAAa,EAAA,EAAC,QAAQ,EAAE,QAAQ,EAAA,CAAI,EAAA,CACjC,CAAA,EAAA,CACF,CAAA,EAAA,CACF;AAEV;;;;"}
|
package/package.json
CHANGED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'theme-ui/jsx-runtime';
|
|
2
|
-
import { useState, useRef, useEffect } from 'react';
|
|
3
|
-
import { createChart, CrosshairMode, ColorType, LineStyle } from 'lightweight-charts';
|
|
4
|
-
import { determineValues } from './utils.js';
|
|
5
|
-
import { getFirstNonZeroDigits } from '../../../../../utils/roundNumber.js';
|
|
6
|
-
|
|
7
|
-
const CandleStickChart = ({ historicalPrices, hasDiscount, bondPrice, tokenPrice, }) => {
|
|
8
|
-
// reference for DOM element to create with chart
|
|
9
|
-
const data = historicalPrices;
|
|
10
|
-
const chartContainerId = 'candleStickChartContainer';
|
|
11
|
-
const formattedData = data?.map((entry) => {
|
|
12
|
-
return {
|
|
13
|
-
time: parseFloat(entry.timestamp),
|
|
14
|
-
open: entry.open,
|
|
15
|
-
low: entry.open,
|
|
16
|
-
close: entry.close,
|
|
17
|
-
high: entry.close,
|
|
18
|
-
};
|
|
19
|
-
});
|
|
20
|
-
// pointer to the chart object
|
|
21
|
-
const [chartCreated, setChartCreated] = useState();
|
|
22
|
-
const chartInitiatedRef = useRef(false);
|
|
23
|
-
const discount = 1 - parseFloat(bondPrice ?? '0') / parseFloat(tokenPrice ?? '0');
|
|
24
|
-
const discountToUse = discount > 0 ? discount : 0;
|
|
25
|
-
const bottomScaleMargin = discountToUse + 0.1;
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
const chartContainer = document.getElementById(chartContainerId);
|
|
28
|
-
if (chartContainer && !chartCreated && !chartInitiatedRef.current) {
|
|
29
|
-
console.log('creating chart');
|
|
30
|
-
const chart = createChart(chartContainer, {
|
|
31
|
-
width: 0,
|
|
32
|
-
height: 0,
|
|
33
|
-
layout: {
|
|
34
|
-
background: {
|
|
35
|
-
type: ColorType.Solid,
|
|
36
|
-
color: 'transparent',
|
|
37
|
-
},
|
|
38
|
-
textColor: '#73728E',
|
|
39
|
-
},
|
|
40
|
-
grid: {
|
|
41
|
-
vertLines: {
|
|
42
|
-
color: '#73728E',
|
|
43
|
-
},
|
|
44
|
-
horzLines: {
|
|
45
|
-
color: '#73728E',
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
crosshair: {
|
|
49
|
-
mode: CrosshairMode.Magnet,
|
|
50
|
-
},
|
|
51
|
-
rightPriceScale: {
|
|
52
|
-
borderColor: '#73728E',
|
|
53
|
-
visible: true,
|
|
54
|
-
scaleMargins: {
|
|
55
|
-
top: 0.12,
|
|
56
|
-
bottom: bottomScaleMargin,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
timeScale: {
|
|
60
|
-
borderColor: '#73728E',
|
|
61
|
-
},
|
|
62
|
-
localization: {
|
|
63
|
-
priceFormatter: (val) => `$${getFirstNonZeroDigits(parseFloat(val), 3)}`,
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
const [precision, minMove] = determineValues(parseFloat(bondPrice));
|
|
67
|
-
const candleSeries = chart.addCandlestickSeries({
|
|
68
|
-
upColor: '#38A611',
|
|
69
|
-
downColor: '#DF4141',
|
|
70
|
-
borderDownColor: '#DF4141',
|
|
71
|
-
borderUpColor: '#38A611',
|
|
72
|
-
wickDownColor: '#DF4141',
|
|
73
|
-
wickUpColor: '#38A611',
|
|
74
|
-
priceLineWidth: 2,
|
|
75
|
-
priceLineStyle: LineStyle.Dashed,
|
|
76
|
-
priceLineVisible: true,
|
|
77
|
-
priceFormat: {
|
|
78
|
-
precision,
|
|
79
|
-
minMove,
|
|
80
|
-
formatter: (val) => getFirstNonZeroDigits(parseFloat(val), 3),
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
const open = formattedData?.[formattedData?.length - 1]?.close ?? 0;
|
|
84
|
-
formattedData?.push({
|
|
85
|
-
time: new Date().getTime() / 1000,
|
|
86
|
-
open: open,
|
|
87
|
-
low: open,
|
|
88
|
-
close: parseFloat(tokenPrice),
|
|
89
|
-
high: parseFloat(tokenPrice),
|
|
90
|
-
});
|
|
91
|
-
//@ts-ignore
|
|
92
|
-
candleSeries.setData(formattedData);
|
|
93
|
-
candleSeries.createPriceLine({
|
|
94
|
-
price: parseFloat(bondPrice),
|
|
95
|
-
color: hasDiscount ? '#38A611' : '#DF4141',
|
|
96
|
-
lineWidth: 2,
|
|
97
|
-
lineStyle: LineStyle.Dashed,
|
|
98
|
-
axisLabelVisible: true,
|
|
99
|
-
title: `Bond Price`,
|
|
100
|
-
});
|
|
101
|
-
chart.timeScale().fitContent();
|
|
102
|
-
//@ts-ignore
|
|
103
|
-
setChartCreated(chart);
|
|
104
|
-
chartInitiatedRef.current = true;
|
|
105
|
-
}
|
|
106
|
-
}, [bondPrice, bottomScaleMargin, chartCreated, formattedData, hasDiscount, tokenPrice]);
|
|
107
|
-
return jsx("div", { id: chartContainerId, style: { width: '100%', height: '100%' } });
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export { CandleStickChart as default };
|
|
111
|
-
//# sourceMappingURL=CandleStickChart.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CandleStickChart.js","sources":["../../../../../../src/views/ProjectView/components/PriceChart/components/CandleStickChart.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef } from 'react'\nimport { ColorType, createChart, CrosshairMode, LineStyle } from 'lightweight-charts'\nimport { determineValues } from './utils'\nimport { HistoricalPrices } from '../../../ProjectView'\nimport { getFirstNonZeroDigits } from '../../../../../utils/roundNumber'\n\nconst CandleStickChart = ({\n historicalPrices,\n hasDiscount,\n bondPrice,\n tokenPrice,\n}: {\n historicalPrices?: HistoricalPrices[] | null\n hasDiscount: boolean\n bondPrice: string\n tokenPrice: string\n}) => {\n // reference for DOM element to create with chart\n const data = historicalPrices\n const chartContainerId = 'candleStickChartContainer'\n\n const formattedData = data?.map((entry) => {\n return {\n time: parseFloat(entry.timestamp),\n open: entry.open,\n low: entry.open,\n close: entry.close,\n high: entry.close,\n }\n })\n\n // pointer to the chart object\n const [chartCreated, setChartCreated] = useState()\n const chartInitiatedRef = useRef(false)\n\n const discount = 1 - parseFloat(bondPrice ?? '0') / parseFloat(tokenPrice ?? '0')\n const discountToUse = discount > 0 ? discount : 0\n const bottomScaleMargin = discountToUse + 0.1\n\n useEffect(() => {\n const chartContainer = document.getElementById(chartContainerId)\n if (chartContainer && !chartCreated && !chartInitiatedRef.current) {\n console.log('creating chart')\n const chart = createChart(chartContainer, {\n width: 0,\n height: 0,\n layout: {\n background: {\n type: ColorType.Solid,\n color: 'transparent',\n },\n textColor: '#73728E',\n },\n grid: {\n vertLines: {\n color: '#73728E',\n },\n horzLines: {\n color: '#73728E',\n },\n },\n crosshair: {\n mode: CrosshairMode.Magnet,\n },\n rightPriceScale: {\n borderColor: '#73728E',\n visible: true,\n scaleMargins: {\n top: 0.12,\n bottom: bottomScaleMargin,\n },\n },\n timeScale: {\n borderColor: '#73728E',\n },\n localization: {\n priceFormatter: (val: string) => `$${getFirstNonZeroDigits(parseFloat(val), 3)}`,\n },\n })\n const [precision, minMove] = determineValues(parseFloat(bondPrice))\n\n const candleSeries = chart.addCandlestickSeries({\n upColor: '#38A611',\n downColor: '#DF4141',\n borderDownColor: '#DF4141',\n borderUpColor: '#38A611',\n wickDownColor: '#DF4141',\n wickUpColor: '#38A611',\n priceLineWidth: 2,\n priceLineStyle: LineStyle.Dashed,\n priceLineVisible: true,\n priceFormat: {\n precision,\n minMove,\n formatter: (val: string) => getFirstNonZeroDigits(parseFloat(val), 3),\n },\n })\n const open = formattedData?.[formattedData?.length - 1]?.close ?? 0\n formattedData?.push({\n time: new Date().getTime() / 1000,\n open: open,\n low: open,\n close: parseFloat(tokenPrice),\n high: parseFloat(tokenPrice),\n })\n //@ts-ignore\n candleSeries.setData(formattedData)\n candleSeries.createPriceLine({\n price: parseFloat(bondPrice),\n color: hasDiscount ? '#38A611' : '#DF4141',\n lineWidth: 2,\n lineStyle: LineStyle.Dashed,\n axisLabelVisible: true,\n title: `Bond Price`,\n })\n\n chart.timeScale().fitContent()\n //@ts-ignore\n setChartCreated(chart)\n chartInitiatedRef.current = true\n }\n }, [bondPrice, bottomScaleMargin, chartCreated, formattedData, hasDiscount, tokenPrice])\n\n return <div id={chartContainerId} style={{ width: '100%', height: '100%' }}></div>\n}\n\nexport default CandleStickChart\n"],"names":["_jsx"],"mappings":";;;;;;AAMA,MAAM,gBAAgB,GAAG,CAAC,EACxB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,UAAU,GAMX,KAAI;;IAEH,MAAM,IAAI,GAAG,gBAAgB;IAC7B,MAAM,gBAAgB,GA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