@ape.swap/bonds-sdk 5.1.32 → 5.1.34
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 +2 -2
- 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
|
@@ -1,100 +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 { getFirstNonZeroDigits } from '../../../../../utils/roundNumber.js';
|
|
5
|
-
import { determineValues } from './utils.js';
|
|
6
|
-
|
|
7
|
-
const LineChart = ({ historicalPrices, hasDiscount, bondPrice, tokenPrice, }) => {
|
|
8
|
-
// reference for DOM element to create with chart
|
|
9
|
-
const data = historicalPrices;
|
|
10
|
-
const chartContainerId = 'lineChartContainer';
|
|
11
|
-
const formattedData = data?.map((entry) => {
|
|
12
|
-
return {
|
|
13
|
-
time: parseInt(entry.timestamp),
|
|
14
|
-
value: parseFloat(getFirstNonZeroDigits(entry.close, 4)),
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
// pointer to the chart object
|
|
18
|
-
const [chartCreated, setChartCreated] = useState();
|
|
19
|
-
const chartInitiatedRef = useRef(false);
|
|
20
|
-
const discount = 1 - parseFloat(bondPrice ?? '0') / parseFloat(tokenPrice ?? '0');
|
|
21
|
-
const discountToUse = discount > 0 ? discount : 0;
|
|
22
|
-
const bottomScaleMargin = discountToUse + 0.15;
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
const chartContainer = document.getElementById(chartContainerId);
|
|
25
|
-
if (chartContainer && !chartCreated && !chartInitiatedRef.current) {
|
|
26
|
-
console.log('creating chart');
|
|
27
|
-
const chart = createChart(chartContainer, {
|
|
28
|
-
width: 0,
|
|
29
|
-
height: 0,
|
|
30
|
-
layout: {
|
|
31
|
-
background: {
|
|
32
|
-
type: ColorType.Solid,
|
|
33
|
-
color: 'transparent',
|
|
34
|
-
},
|
|
35
|
-
textColor: '#73728E',
|
|
36
|
-
},
|
|
37
|
-
grid: {
|
|
38
|
-
vertLines: {
|
|
39
|
-
color: '#73728E',
|
|
40
|
-
},
|
|
41
|
-
horzLines: {
|
|
42
|
-
color: '#73728E',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
crosshair: {
|
|
46
|
-
mode: CrosshairMode.Magnet,
|
|
47
|
-
},
|
|
48
|
-
rightPriceScale: {
|
|
49
|
-
borderColor: '#73728E',
|
|
50
|
-
visible: true,
|
|
51
|
-
scaleMargins: {
|
|
52
|
-
top: 0.12,
|
|
53
|
-
bottom: bottomScaleMargin,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
timeScale: {
|
|
57
|
-
borderColor: '#73728E',
|
|
58
|
-
},
|
|
59
|
-
localization: {
|
|
60
|
-
priceFormatter: (val) => {
|
|
61
|
-
return `$${getFirstNonZeroDigits(parseFloat(val), 3)}`;
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
const [precision, minMove] = determineValues(parseFloat(bondPrice));
|
|
66
|
-
const areaSeries = chart.addAreaSeries({
|
|
67
|
-
lineColor: '#5E59B5',
|
|
68
|
-
topColor: '#5E59B5',
|
|
69
|
-
bottomColor: '#514CA133',
|
|
70
|
-
priceLineWidth: 2,
|
|
71
|
-
priceLineStyle: LineStyle.Dashed,
|
|
72
|
-
priceLineVisible: true,
|
|
73
|
-
priceFormat: {
|
|
74
|
-
precision,
|
|
75
|
-
minMove,
|
|
76
|
-
formatter: (val) => getFirstNonZeroDigits(parseFloat(val), 3),
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
formattedData?.push({ time: Math.floor(new Date().getTime() / 1000), value: parseFloat(tokenPrice) });
|
|
80
|
-
//@ts-ignore
|
|
81
|
-
areaSeries.setData(formattedData);
|
|
82
|
-
areaSeries.createPriceLine({
|
|
83
|
-
price: parseFloat(bondPrice),
|
|
84
|
-
color: hasDiscount ? '#38A611' : '#DF4141',
|
|
85
|
-
lineWidth: 2,
|
|
86
|
-
lineStyle: LineStyle.Dashed,
|
|
87
|
-
axisLabelVisible: true,
|
|
88
|
-
title: `Bond Price`,
|
|
89
|
-
});
|
|
90
|
-
chart.timeScale().fitContent();
|
|
91
|
-
//@ts-ignore
|
|
92
|
-
setChartCreated(chart);
|
|
93
|
-
chartInitiatedRef.current = true;
|
|
94
|
-
}
|
|
95
|
-
}, [bondPrice, bottomScaleMargin, chartCreated, formattedData, hasDiscount, tokenPrice]);
|
|
96
|
-
return jsx("div", { id: chartContainerId, style: { width: '100%', height: '100%' } });
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export { LineChart as default };
|
|
100
|
-
//# sourceMappingURL=LineChart.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.js","sources":["../../../../../../src/views/ProjectView/components/PriceChart/components/LineChart.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef } from 'react'\nimport { ColorType, createChart, CrosshairMode, LineStyle } from 'lightweight-charts'\nimport { HistoricalPrices } from '../../../ProjectView'\nimport { getFirstNonZeroDigits } from '../../../../../utils/roundNumber'\nimport { determineValues } from './utils'\n\nconst LineChart = ({\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 = 'lineChartContainer'\n\n const formattedData = data?.map((entry) => {\n return {\n time: parseInt(entry.timestamp),\n value: parseFloat(getFirstNonZeroDigits(entry.close, 4)),\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.15\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\n localization: {\n priceFormatter: (val: string) => {\n return `$${getFirstNonZeroDigits(parseFloat(val), 3)}`\n },\n },\n })\n const [precision, minMove] = determineValues(parseFloat(bondPrice))\n\n const areaSeries = chart.addAreaSeries({\n lineColor: '#5E59B5',\n topColor: '#5E59B5',\n bottomColor: '#514CA133',\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\n formattedData?.push({ time: Math.floor(new Date().getTime() / 1000), value: parseFloat(tokenPrice) })\n //@ts-ignore\n areaSeries.setData(formattedData)\n\n areaSeries.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 LineChart\n"],"names":["_jsx"],"mappings":";;;;;;AAMA,MAAM,SAAS,GAAG,CAAC,EACjB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,UAAU,GAMX,KAAI;;IAEH,MAAM,IAAI,GAAG,gBAAgB;I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IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;;AAErG,YAAA,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC;YAEjC,UAAU,CAAC,eAAe,CAAC;AACzB,gBAAA,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC;gBAC5B,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS;AAC1C,gBAAA,SAAS,EAAE,CAAC;gBACZ,SAAS,EAAE,SAAS,CAAC,MAAM;AAC3B,gBAAA,gBAAgB,EAAE,IAAI;AACtB,gBAAA,KAAK,EAAE,CAAA,UAAA,CAAY;AACpB,aAAA,CAAC;AAEF,YAAA,KAAK,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE;;YAE9B,eAAe,CAAC,KAAK,CAAC;AACtB,YAAA,iBAAiB,CAAC,OAAO,GAAG,IAAI;QAClC;AACF,IAAA,CAAC,EAAE,CAAC,SAAS,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAExF,IAAA,OAAOA,aAAK,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAQ;AACpF;;;;"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const determineValues = (input) => {
|
|
2
|
-
// if input is larger than 1 return [2, 0.01]
|
|
3
|
-
if (input > 1) {
|
|
4
|
-
return [2, 0.01];
|
|
5
|
-
}
|
|
6
|
-
// loop that starts handling the cases smaller than or equal to 1
|
|
7
|
-
let index = 2; // Index to get next value to consider. Start from 1 since we handled the "greater than 1" case.
|
|
8
|
-
let check = 1; // Start with 0.1 as the value to compare with. If input is smaller, increase index and decrease check by a factor of 10.
|
|
9
|
-
while (input <= check) {
|
|
10
|
-
index += 1;
|
|
11
|
-
check *= 0.1;
|
|
12
|
-
}
|
|
13
|
-
const decimalString = '0.' + Array(index).join('0') + '1';
|
|
14
|
-
// Convert string back to number
|
|
15
|
-
const decimalNumber = Number(decimalString);
|
|
16
|
-
return [index, decimalNumber];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { determineValues };
|
|
20
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../../../src/views/ProjectView/components/PriceChart/components/utils.ts"],"sourcesContent":["export const determineValues = (input: number): [number, number] => {\n // if input is larger than 1 return [2, 0.01]\n if (input > 1) {\n return [2, 0.01]\n }\n // loop that starts handling the cases smaller than or equal to 1\n let index = 2 // Index to get next value to consider. Start from 1 since we handled the \"greater than 1\" case.\n let check = 1 // Start with 0.1 as the value to compare with. If input is smaller, increase index and decrease check by a factor of 10.\n while (input <= check) {\n index += 1\n check *= 0.1\n }\n const decimalString = '0.' + Array(index).join('0') + '1'\n // Convert string back to number\n const decimalNumber = Number(decimalString)\n return [index, decimalNumber]\n}\n"],"names":[],"mappings":"AAAO,MAAM,eAAe,GAAG,CAAC,KAAa,KAAsB;;AAEjE,IAAA,IAAI,KAAK,GAAG,CAAC,EAAE;AACb,QAAA,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC;IAClB;;AAEA,IAAA,IAAI,KAAK,GAAG,CAAC,CAAA;AACb,IAAA,IAAI,KAAK,GAAG,CAAC,CAAA;AACb,IAAA,OAAO,KAAK,IAAI,KAAK,EAAE;QACrB,KAAK,IAAI,CAAC;QACV,KAAK,IAAI,GAAG;IACd;AACA,IAAA,MAAM,aAAa,GAAG,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG;;AAEzD,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;AAC3C,IAAA,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC;AAC/B;;;;"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'theme-ui/jsx-runtime';
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
import CandleStickChart from './components/CandleStickChart.js';
|
|
4
|
-
import LineChart from './components/LineChart.js';
|
|
5
|
-
import { styles } from './styles.js';
|
|
6
|
-
import { getFirstNonZeroDigits } from '../../../../utils/roundNumber.js';
|
|
7
|
-
import Flex from '../../../../components/uikit-sdk/Flex/index.js';
|
|
8
|
-
import Svg from '../../../../components/uikit-sdk/Svg/index.js';
|
|
9
|
-
import { TIERS_WEIGHT } from '../../../../state/tiers/useTierPoints.js';
|
|
10
|
-
import { LaunchBondTiers } from '@ape.swap/apeswap-lists';
|
|
11
|
-
import { discountEarnTokenPrice } from '../../../../utils/displayHelpers.js';
|
|
12
|
-
import { findHighestTrueBondPrice } from '../../../../utils/bondPriceHelpers.js';
|
|
13
|
-
|
|
14
|
-
const PriceChart = ({ selectedBond, historicalPrices, }) => {
|
|
15
|
-
const earnTokenPrice = parseFloat(selectedBond?.payoutTokenPrice ?? '0');
|
|
16
|
-
const trueBondPrice = findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], selectedBond?.trueBondPrices);
|
|
17
|
-
const bondPrice = discountEarnTokenPrice(selectedBond, true);
|
|
18
|
-
const hasDiscount = (trueBondPrice?.bonus ?? 0) > 0;
|
|
19
|
-
const contractAddress = selectedBond.contractAddress[selectedBond.chainId];
|
|
20
|
-
const [show, setShow] = useState(false);
|
|
21
|
-
const [chartOption, setChartOption] = useState('line');
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
// This effect is to ensure that the charts are only rendered on the client
|
|
24
|
-
setShow(true);
|
|
25
|
-
}, []);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
// This effect is to ensure the charts are re-rendered everytime the selectedBond changes
|
|
28
|
-
setShow(false);
|
|
29
|
-
const timer = setTimeout(() => {
|
|
30
|
-
setShow(true);
|
|
31
|
-
}, 50);
|
|
32
|
-
return () => clearTimeout(timer);
|
|
33
|
-
}, [contractAddress]);
|
|
34
|
-
return (jsxs(Flex, { sx: styles.priceContainer, children: [jsxs(Flex, { sx: { width: '100%', justifyContent: 'space-between', mb: '15px', pr: '20px' }, children: [jsx(Flex, { children: "Prices" }), jsxs(Flex, { children: [jsxs(Flex, { sx: { color: hasDiscount ? 'success' : 'error', fontSize: '12px', fontWeight: 500, mr: '15px' }, children: ["Bond Price: $", bondPrice] }), jsxs(Flex, { sx: { color: 'textDisabledButton', fontSize: '12px', fontWeight: 500 }, children: ["Market Price: $", getFirstNonZeroDigits(earnTokenPrice ?? 0)] })] })] }), show && (jsxs(Flex, { sx: styles.container, children: [jsxs(Flex, { sx: styles.buttonsContainer, children: [jsx(Flex, { sx: { ...styles.button, mr: '15px' }, onClick: () => setChartOption('line'), children: jsx(Svg, { icon: "lineChart", width: 20 }) }), jsx(Flex, { sx: styles.button, onClick: () => setChartOption('candleStick'), children: "D" })] }), historicalPrices && historicalPrices.length > 0 ? (chartOption === 'line' ? (jsx(LineChart, { historicalPrices: historicalPrices, hasDiscount: hasDiscount, bondPrice: bondPrice ?? '0', tokenPrice: selectedBond.payoutTokenPrice ?? '0' })) : (jsx(CandleStickChart, { historicalPrices: historicalPrices, hasDiscount: hasDiscount, bondPrice: bondPrice ?? '0', tokenPrice: selectedBond.payoutTokenPrice ?? '0' }))) : (jsxs(Flex, { sx: { flexDirection: 'column', justifyContent: 'center', alignItems: 'center', width: '100%' }, children: [jsx(Svg, { icon: "placeholderMonkey" }), jsx(Flex, { sx: { mt: '15px' }, children: "No Historical Price for this Token" })] }))] }))] }));
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export { PriceChart as default };
|
|
38
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/views/ProjectView/components/PriceChart/index.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react'\nimport CandleStickChart from './components/CandleStickChart'\nimport LineChart from './components/LineChart'\nimport { styles } from './styles'\nimport { BondsData } from '../../../../types/bonds'\nimport { HistoricalPrices } from '../../ProjectView'\nimport { getFirstNonZeroDigits } from '../../../../utils/roundNumber'\nimport Flex from '../../../../components/uikit-sdk/Flex'\nimport Svg from '../../../../components/uikit-sdk/Svg'\nimport { TIERS_WEIGHT } from '../../../../state/tiers/useTierPoints'\nimport { LaunchBondTiers } from '@ape.swap/apeswap-lists'\nimport { discountEarnTokenPrice } from '../../../../utils/displayHelpers'\nimport { findHighestTrueBondPrice } from '../../../../utils/bondPriceHelpers'\n\nconst PriceChart = ({\n selectedBond,\n historicalPrices,\n}: {\n selectedBond: BondsData\n historicalPrices?: HistoricalPrices[] | null\n}) => {\n const earnTokenPrice = parseFloat(selectedBond?.payoutTokenPrice ?? '0')\n const trueBondPrice = findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], selectedBond?.trueBondPrices)\n const bondPrice = discountEarnTokenPrice(selectedBond, true)\n const hasDiscount = (trueBondPrice?.bonus ?? 0) > 0\n const contractAddress = selectedBond.contractAddress[selectedBond.chainId]\n\n const [show, setShow] = useState<boolean>(false)\n const [chartOption, setChartOption] = useState<'line' | 'candleStick'>('line')\n\n useEffect(() => {\n // This effect is to ensure that the charts are only rendered on the client\n setShow(true)\n }, [])\n\n useEffect(() => {\n // This effect is to ensure the charts are re-rendered everytime the selectedBond changes\n setShow(false)\n const timer = setTimeout(() => {\n setShow(true)\n }, 50)\n return () => clearTimeout(timer)\n }, [contractAddress])\n\n return (\n <Flex sx={styles.priceContainer}>\n <Flex sx={{ width: '100%', justifyContent: 'space-between', mb: '15px', pr: '20px' }}>\n <Flex>Prices</Flex>\n <Flex>\n <Flex sx={{ color: hasDiscount ? 'success' : 'error', fontSize: '12px', fontWeight: 500, mr: '15px' }}>\n Bond Price: ${bondPrice}\n </Flex>\n <Flex sx={{ color: 'textDisabledButton', fontSize: '12px', fontWeight: 500 }}>\n Market Price: ${getFirstNonZeroDigits(earnTokenPrice ?? 0)}\n </Flex>\n </Flex>\n </Flex>\n {show && (\n <Flex sx={styles.container}>\n <Flex sx={styles.buttonsContainer}>\n <Flex sx={{ ...styles.button, mr: '15px' }} onClick={() => setChartOption('line')}>\n <Svg icon=\"lineChart\" width={20} />\n </Flex>\n <Flex sx={styles.button} onClick={() => setChartOption('candleStick')}>\n D\n </Flex>\n </Flex>\n {historicalPrices && historicalPrices.length > 0 ? (\n chartOption === 'line' ? (\n <LineChart\n historicalPrices={historicalPrices}\n hasDiscount={hasDiscount}\n bondPrice={bondPrice ?? '0'}\n tokenPrice={selectedBond.payoutTokenPrice ?? '0'}\n />\n ) : (\n <CandleStickChart\n historicalPrices={historicalPrices}\n hasDiscount={hasDiscount}\n bondPrice={bondPrice ?? '0'}\n tokenPrice={selectedBond.payoutTokenPrice ?? '0'}\n />\n )\n ) : (\n <Flex sx={{ flexDirection: 'column', justifyContent: 'center', alignItems: 'center', width: '100%' }}>\n <Svg icon=\"placeholderMonkey\" />\n <Flex sx={{ mt: '15px' }}>No Historical Price for this Token</Flex>\n </Flex>\n )}\n </Flex>\n )}\n </Flex>\n )\n}\n\nexport default PriceChart\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,UAAU,GAAG,CAAC,EAClB,YAAY,EACZ,gBAAgB,GAIjB,KAAI;IACH,MAAM,cAAc,GAAG,UAAU,CAAC,YAAY,EAAE,gBAAgB,IAAI,GAAG,CAAC;AACxE,IAAA,MAAM,aAAa,GAAG,wBAAwB,CAAC,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,cAAc,CAAC;IAClH,MAAM,SAAS,GAAG,sBAAsB,CAAC,YAAY,EAAE,IAAI,CAAC;IAC5D,MAAM,WAAW,GAAG,CAAC,aAAa,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC;IACnD,MAAM,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC,YA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AAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,aAClGC,GAAA,CAAC,GAAG,EAAA,EAAC,IAAI,EAAC,mBAAmB,EAAA,CAAG,EAChCA,GAAA,CAAC,IAAI,EAAA,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAA,QAAA,EAAA,oCAAA,EAAA,CAA2C,IAC9D,CACR,CAAA,EAAA,CACI,CACR,CAAA,EAAA,CACI;AAEX;;;;"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const styles = {
|
|
2
|
-
priceContainer: {
|
|
3
|
-
width: ['100%', '100%', '100%', '50%'],
|
|
4
|
-
fontSize: ['12px', '12px', '12px', '16px'],
|
|
5
|
-
flexDirection: 'column',
|
|
6
|
-
background: 'white2',
|
|
7
|
-
borderRadius: 'normal',
|
|
8
|
-
p: '20px',
|
|
9
|
-
pr: '0px',
|
|
10
|
-
alignItems: 'center',
|
|
11
|
-
mt: ['15px', '15px', '15px', '5px'],
|
|
12
|
-
minHeight: ['330px', '330px', '330px', '430px'],
|
|
13
|
-
ml: ['0px', '0px', '0px', '5px'],
|
|
14
|
-
},
|
|
15
|
-
container: {
|
|
16
|
-
position: 'relative',
|
|
17
|
-
width: '100%',
|
|
18
|
-
height: '100%',
|
|
19
|
-
},
|
|
20
|
-
buttonsContainer: {
|
|
21
|
-
position: 'absolute',
|
|
22
|
-
top: 0,
|
|
23
|
-
left: 0,
|
|
24
|
-
zIndex: 20,
|
|
25
|
-
},
|
|
26
|
-
button: {
|
|
27
|
-
width: '35px',
|
|
28
|
-
height: '35px',
|
|
29
|
-
fontSize: '12px',
|
|
30
|
-
borderRadius: 'small',
|
|
31
|
-
background: 'white3',
|
|
32
|
-
border: '1px solid grey',
|
|
33
|
-
display: 'flex',
|
|
34
|
-
justifyContent: 'center',
|
|
35
|
-
alignItems: 'center',
|
|
36
|
-
cursor: 'pointer',
|
|
37
|
-
'&:hover': {
|
|
38
|
-
background: 'white4',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export { styles };
|
|
44
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sources":["../../../../../src/views/ProjectView/components/PriceChart/styles.ts"],"sourcesContent":["import { ThemeUIStyleObject } from 'theme-ui'\n\nexport const styles: Record<'priceContainer' | 'container' | 'buttonsContainer' | 'button', ThemeUIStyleObject> = {\n priceContainer: {\n width: ['100%', '100%', '100%', '50%'],\n fontSize: ['12px', '12px', '12px', '16px'],\n flexDirection: 'column',\n background: 'white2',\n borderRadius: 'normal',\n p: '20px',\n pr: '0px',\n alignItems: 'center',\n mt: ['15px', '15px', '15px', '5px'],\n minHeight: ['330px', '330px', '330px', '430px'],\n ml: ['0px', '0px', '0px', '5px'],\n },\n container: {\n position: 'relative',\n width: '100%',\n height: '100%',\n },\n buttonsContainer: {\n position: 'absolute',\n top: 0,\n left: 0,\n zIndex: 20,\n },\n button: {\n width: '35px',\n height: '35px',\n fontSize: '12px',\n borderRadius: 'small',\n background: 'white3',\n border: '1px solid grey',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n cursor: 'pointer',\n '&:hover': {\n background: 'white4',\n },\n },\n}\n"],"names":[],"mappings":"AAEO,MAAM,MAAM,GAA+F;AAChH,IAAA,cAAc,EAAE;QACd,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;QACtC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;AAC1C,QAAA,aAAa,EAAE,QAAQ;AACvB,QAAA,UAAU,EAAE,QAAQ;AACpB,QAAA,YAAY,EAAE,QAAQ;AACtB,QAAA,CAAC,EAAE,MAAM;AACT,QAAA,EAAE,EAAE,KAAK;AACT,QAAA,UAAU,EAAE,QAAQ;QACpB,EAAE,EAAE,CAAC,MAAM,EAAE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