@ape.swap/bonds-sdk 5.1.34 → 5.1.37
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/GiftBox.d.ts +4 -0
- package/dist/components/uikit-sdk/Svg/Icons/GiftBox.js +10 -0
- package/dist/components/uikit-sdk/Svg/Icons/GiftBox.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/components/uikit-sdk/TooltipBubble/types.d.ts +2 -2
- package/dist/components/uikit-sdk/TooltipBubble/types.js.map +1 -1
- package/dist/config/constants/queryKeys.d.ts +1 -0
- package/dist/config/constants/queryKeys.js.map +1 -1
- package/dist/state/tiers/useTierPoints.d.ts +15 -2
- package/dist/state/tiers/useTierPoints.js +31 -4
- package/dist/state/tiers/useTierPoints.js.map +1 -1
- package/dist/state/zap/useSoulZapBondQuote.js +6 -3
- package/dist/state/zap/useSoulZapBondQuote.js.map +1 -1
- package/dist/utils/formatNumber.d.ts +6 -0
- package/dist/utils/formatNumber.js +39 -3
- package/dist/utils/formatNumber.js.map +1 -1
- package/dist/views/Bonds/components/BondRows/ActiveBondRows.js +1 -2
- package/dist/views/Bonds/components/BondRows/ActiveBondRows.js.map +1 -1
- package/dist/views/Bonds/components/BonusComponents/BonusTable.js +3 -2
- package/dist/views/Bonds/components/BonusComponents/BonusTable.js.map +1 -1
- package/dist/views/Bonds/components/ChainBanner/ChainBanner.js +22 -36
- package/dist/views/Bonds/components/ChainBanner/ChainBanner.js.map +1 -1
- package/dist/views/BuyBond/BuyComponent.js +10 -9
- package/dist/views/BuyBond/BuyComponent.js.map +1 -1
- package/dist/views/BuyBond/components/BondModalHeader.js +21 -3
- package/dist/views/BuyBond/components/BondModalHeader.js.map +1 -1
- package/dist/views/BuyBond/components/Estimations.d.ts +1 -1
- package/dist/views/BuyBond/components/Estimations.js +15 -9
- package/dist/views/BuyBond/components/Estimations.js.map +1 -1
- package/dist/views/BuyBond/components/GetUpToComponent/GetUpToComponent.js +27 -7
- package/dist/views/BuyBond/components/GetUpToComponent/GetUpToComponent.js.map +1 -1
- package/dist/views/BuyBond/components/NewRateModal/NewRateModal.js +4 -3
- package/dist/views/BuyBond/components/NewRateModal/NewRateModal.js.map +1 -1
- package/dist/views/BuyBond/components/PointsLeftForNextTier/PointsLeftForNextTier.js +6 -5
- package/dist/views/BuyBond/components/PointsLeftForNextTier/PointsLeftForNextTier.js.map +1 -1
- package/dist/views/ProjectView/ProjectView.js +7 -9
- package/dist/views/ProjectView/ProjectView.js.map +1 -1
- package/dist/views/ProjectView/components/PriceChart/components/CandleStickChart.js +111 -0
- package/dist/views/ProjectView/components/PriceChart/components/CandleStickChart.js.map +1 -0
- package/dist/views/ProjectView/components/PriceChart/components/LineChart.js +100 -0
- package/dist/views/ProjectView/components/PriceChart/components/LineChart.js.map +1 -0
- package/dist/views/ProjectView/components/PriceChart/components/utils.js +20 -0
- package/dist/views/ProjectView/components/PriceChart/components/utils.js.map +1 -0
- package/dist/views/ProjectView/components/PriceChart/index.js +38 -0
- package/dist/views/ProjectView/components/PriceChart/index.js.map +1 -0
- package/dist/views/ProjectView/components/PriceChart/styles.js +44 -0
- package/dist/views/ProjectView/components/PriceChart/styles.js.map +1 -0
- package/dist/views/ProjectView/components/RecommendationCards/index.js +7 -2
- package/dist/views/ProjectView/components/RecommendationCards/index.js.map +1 -1
- package/dist/views/SingleBond/SoldOutBuyBondPlaceholder.js +4 -3
- package/dist/views/SingleBond/SoldOutBuyBondPlaceholder.js.map +1 -1
- package/dist/views/TransactionModal/TransactionModal.js +5 -4
- package/dist/views/TransactionModal/TransactionModal.js.map +1 -1
- package/package.json +2 -3
- package/dist/components/TabNavigation/index.js +0 -33
- package/dist/components/TabNavigation/index.js.map +0 -1
- package/dist/views/RakuraiComponent/RakuraiComponent.d.ts +0 -3
- package/dist/views/RakuraiComponent/RakuraiComponent.js +0 -229
- package/dist/views/RakuraiComponent/RakuraiComponent.js.map +0 -1
- package/dist/views/RakuraiComponent/useRakuraiStats.d.ts +0 -7
- package/dist/views/RakuraiComponent/useRakuraiStats.js +0 -42
- package/dist/views/RakuraiComponent/useRakuraiStats.js.map +0 -1
- package/dist/views/RakuraiComponent/useSolanaStakeBalances.d.ts +0 -8
- package/dist/views/RakuraiComponent/useSolanaStakeBalances.js +0 -47
- package/dist/views/RakuraiComponent/useSolanaStakeBalances.js.map +0 -1
|
@@ -0,0 +1,100 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;IAC7B,MAAM,gBAAgB,GAAG,oBAAoB;IAE7C,MAAM,aAAa,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,KAAI;QACxC,OAAO;AACL,YAAA,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC;YAC/B,KAAK,EAAE,UAAU,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SACzD;AACH,IAAA,CAAC,CAAC;;IAGF,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,EAAE;AAClD,IAAA,MAAM,iBAAiB,GAAG,MAAM,CAAC,KAAK,CAAC;AAEvC,IAAA,MAAM,QAAQ,GAAG,CAAC,GAAG,UAAU,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,UAAU,CAAC,UAAU,IAAI,GAAG,CAAC;AACjF,IAAA,MAAM,aAAa,GAAG,QAAQ,GAAG,CAAC,GAAG,QAAQ,GAAG,CAAC;AACjD,IAAA,MAAM,iBAAiB,GAAG,aAAa,GAAG,IAAI;IAE9C,SAAS,CAAC,MAAK;QACb,MAAM,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,gBAAgB,CAAC;QAChE,IAAI,cAAc,IAAI,CAAC,YAAY,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE;AACjE,YAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;AAC7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0 +1,20 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,cAA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,IAAI,GAAG,EAC3B,UAAU,EAAE,YAAY,CAAC,gBAAgB,IAAI,GAAG,GAChD,KAEFA,GAAA,CAAC,gBAAgB,EAAA,EACf,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,IAAI,GAAG,EAC3B,UAAU,EAAE,YAAY,CAAC,gBAAgB,IAAI,GAAG,EAAA,CAChD,CACH,KAEDD,IAAA,CAAC,IAAI,IAAC,EAAE,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,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;;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,KA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;;;;"}
|
|
@@ -4,6 +4,7 @@ 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';
|
|
7
8
|
import { TIERS_WEIGHT } from '../../../../state/tiers/useTierPoints.js';
|
|
8
9
|
import { LaunchBondTiers } from '@ape.swap/apeswap-lists';
|
|
9
10
|
import useGetBondRecommendations from '../../../../state/recommendations/useGetBondRecommendations.js';
|
|
@@ -37,7 +38,7 @@ const RecommendationCards = () => {
|
|
|
37
38
|
? a.discount
|
|
38
39
|
: (findHighestTrueBondPrice(TIERS_WEIGHT[LaunchBondTiers.Legend], a?.trueBondPrices)?.bonus ?? 0)))
|
|
39
40
|
?.slice(0, 3);
|
|
40
|
-
slicedBonds?.map((bond) => {
|
|
41
|
+
const parsedBondsToRender = slicedBonds?.map((bond) => {
|
|
41
42
|
let contractAddress = '';
|
|
42
43
|
if ('contractAddress' in bond) {
|
|
43
44
|
contractAddress = bond.contractAddress;
|
|
@@ -77,7 +78,11 @@ const RecommendationCards = () => {
|
|
|
77
78
|
}, onClick: () => window.open('/apebond-ai', '_blank') }) })] }), jsx(Flex, { sx: {
|
|
78
79
|
my: '10px',
|
|
79
80
|
minHeight: '47.45px',
|
|
80
|
-
}
|
|
81
|
+
}, children: parsedBondsToRender &&
|
|
82
|
+
parsedBondsToRender.length > 0 &&
|
|
83
|
+
parsedBondsToRender.map((bond, index) => {
|
|
84
|
+
return jsx(SmallRecommendationCard, { recommendation: bond }, `${bond.payoutTokenName}-${index}`);
|
|
85
|
+
}) })] }));
|
|
81
86
|
};
|
|
82
87
|
|
|
83
88
|
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 {
|
|
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 </Flex>\n </Flex>\n )\n}\n\nexport default RecommendationCards\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,mBAAmB,GAAG,MAAK;AAC/B,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE;IAC5B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE;IAC5C,MAAM,OAAO,GAAG,OAAO,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC;AAC9E,IAAA,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,mBAAmB,EAAE;AAEhD,IAAA,MAAM,EAAE,IAAI,EAAE,qBAAqB,EAAE,GAAG,yBAAyB,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC;IAC1F,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE;IACtC,MAAM,WAAW,GACf,KAAK,IAAI,KA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EAAA,QAAA,EAEA,mBAAmB;oBAClB,mBAAmB,CAAC,MAAM,GAAG,CAAC;oBAC9B,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,KAAI;AACtC,wBAAA,OAAOA,GAAA,CAAC,uBAAuB,EAAA,EAAC,cAAc,EAAE,IAAI,EAAA,EAAO,CAAA,EAAG,IAAI,CAAC,eAAe,CAAA,CAAA,EAAI,KAAK,CAAA,CAAE,CAAI;AACnG,oBAAA,CAAC,CAAC,EAAA,CACC,CAAA,EAAA,CACF;AAEX;;;;"}
|
|
@@ -19,8 +19,9 @@ const SoldOutBuyBondPlaceholder = ({ bond }) => {
|
|
|
19
19
|
const SDKConfig = useSDKConfig();
|
|
20
20
|
// Hooks
|
|
21
21
|
const { address: account } = useEVMAccount();
|
|
22
|
-
const { data:
|
|
23
|
-
const
|
|
22
|
+
const { data: tierState } = useTierPoints();
|
|
23
|
+
const { promotionalPoints } = tierState || {};
|
|
24
|
+
const userTier = getUserTier(promotionalPoints ?? '0');
|
|
24
25
|
// State
|
|
25
26
|
const bondData = bond;
|
|
26
27
|
const minTier = bondData?.minTier !== undefined ? bondData.minTier : null;
|
|
@@ -62,7 +63,7 @@ const SoldOutBuyBondPlaceholder = ({ bond }) => {
|
|
|
62
63
|
justifyContent: 'center',
|
|
63
64
|
}, children: "SOLD OUT" })] }), jsx(BondModalHeader, { bondData: bondData,
|
|
64
65
|
// onDismiss={onDismiss}
|
|
65
|
-
showProjectInfoButton: SDKConfig?.referenceId === 'apebond' }), jsx(ProjectDescription, { description: bondData.shortDescription }), jsx(BondCards, { bondData: { ...bondData, bonusWithFee: -1 } }), jsx(Estimations, { depositAmount: '0',
|
|
66
|
+
showProjectInfoButton: SDKConfig?.referenceId === 'apebond' }), jsx(ProjectDescription, { description: bondData.shortDescription }), jsx(BondCards, { bondData: { ...bondData, bonusWithFee: -1 } }), jsx(Estimations, { depositAmount: '0', inputValue: '0', inputTokenPrice: 0,
|
|
66
67
|
/*@ts-ignore*/
|
|
67
68
|
bondData: bondData, youSpendString: '0', isZap: isZap, fetchingZapQuote: false, zapError: false }), jsx(TokenSelectorPanel, { typedValue: inputValue, setTypedValue: setInputValue, selectedToken: inputToken, handleValueBtn: () => null, handleCurrencySelect: () => null, bondChainId: bondData?.chainId, enableZap: zapSupported.includes(bondData?.chainId), bondPrincipalToken: bondData?.lpToken, tokenBalance: inputCurrencyBalance ?? undefined, selectedTokenPrice: 0, inputDisabled: true }), jsxs(Flex, { className: "modaltable-container button-container", children: [account && (minTier === null || (userTier !== null && userTier >= minTier)) && (jsx(Flex, { className: "button-container get", children: jsxs(Button, { className: "action-button", variant: "secondary", fullWidth: true, disabled: true, children: ["Get ", getSymbol(bondData?.lpToken)] }) })), jsx(Flex, { className: "button-container buy", children: jsx(Button, { className: "action-button", fullWidth: true, disabled: true, children: "Buy" }) })] })] }) })) : (jsx(Fragment, {}));
|
|
68
69
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SoldOutBuyBondPlaceholder.js","sources":["../../../src/views/SingleBond/SoldOutBuyBondPlaceholder.tsx"],"sourcesContent":["import React, { useState } from 'react'\nimport Button from '../../components/uikit-sdk/Button/Button'\nimport Flex from '../../components/uikit-sdk/Flex'\nimport { BillsConfig } from '@ape.swap/apeswap-lists'\nimport TokenSelectorPanel from '../../components/TokenSelectorPanel'\nimport useCurrencyBalance from '../../state/balance/useCurrencyBalance'\nimport useTokenFromZapList from '../../hooks/useTokenFromZapList'\nimport { useSDKConfig } from '../../state/useSDKConfig'\nimport { zapSupported, ZapSupportedChainId } from '../../config/constants/variables'\nimport { getSymbol } from '../../utils/getNativeTicker'\nimport
|
|
1
|
+
{"version":3,"file":"SoldOutBuyBondPlaceholder.js","sources":["../../../src/views/SingleBond/SoldOutBuyBondPlaceholder.tsx"],"sourcesContent":["import React, { useState } from 'react'\nimport Button from '../../components/uikit-sdk/Button/Button'\nimport Flex from '../../components/uikit-sdk/Flex'\nimport { BillsConfig } from '@ape.swap/apeswap-lists'\nimport TokenSelectorPanel from '../../components/TokenSelectorPanel'\nimport useCurrencyBalance from '../../state/balance/useCurrencyBalance'\nimport useTokenFromZapList from '../../hooks/useTokenFromZapList'\nimport { useSDKConfig } from '../../state/useSDKConfig'\nimport { zapSupported, ZapSupportedChainId } from '../../config/constants/variables'\nimport { getSymbol } from '../../utils/getNativeTicker'\nimport useTierPoints, { getUserTier } from '../../state/tiers/useTierPoints'\nimport BondModalHeader from '../BuyBond/components/BondModalHeader'\nimport { BondsData } from '../../types/bonds'\nimport ProjectDescription from '../BuyBond/components/ProjectDescription'\nimport BondCards from '../BuyBond/components/BondCards/BondCards'\nimport Estimations from '../BuyBond/components/Estimations'\nimport useEVMAccount from '../../hooks/accounts/useEVMAccount'\n\nexport interface SoldOutProps {\n onDismiss?: () => void\n bond: BillsConfig\n}\n\nconst SoldOutBuyBondPlaceholder: React.FC<SoldOutProps> = ({ bond }) => {\n const SDKConfig = useSDKConfig()\n // Hooks\n const { address: account } = useEVMAccount()\n const { data: tierState } = useTierPoints()\n const { promotionalPoints } = tierState || {}\n const userTier = getUserTier(promotionalPoints ?? '0')\n\n // State\n const bondData = bond\n const minTier = bondData?.minTier !== undefined ? bondData.minTier : null\n const [inputValue, setInputValue] = useState('')\n const [inputTokenString] = useState(bondData?.lpToken?.address?.[bondData.chainId])\n\n // Data\n const inputToken = useTokenFromZapList(inputTokenString, bondData?.chainId, bondData?.lpToken)\n const isZap = inputTokenString?.toLowerCase() !== bondData?.lpToken?.address?.[bondData?.chainId]?.toLowerCase()\n\n const { data: inputCurrencyBalance } = useCurrencyBalance(\n inputToken ?? null,\n account ?? null,\n bondData?.chainId ?? null,\n )\n\n return bondData ? (\n <Flex className=\"modal-content\">\n <Flex className=\"modaltable-container\">\n <Flex\n sx={{\n position: 'absolute',\n width: 'calc(100% + 40px)',\n height: 'calc(100% + 20px)',\n top: '0',\n left: '-20px',\n overflow: 'hidden',\n borderRadius: 'normal',\n }}\n >\n <Flex\n sx={{\n position: 'absolute',\n width: '100%',\n height: '100%',\n zIndex: 999,\n backgroundColor: 'rgba(255,255,255,0.1)',\n backdropFilter: 'blur(1px)',\n WebkitBackdropFilter: 'blur(1px)', // Ensure compatibility with Safari\n }}\n ></Flex>\n <Flex\n sx={{\n position: 'absolute',\n top: '50px',\n left: '-50px',\n backgroundColor: 'error',\n color: 'white',\n padding: '5px 20px',\n fontSize: '14px',\n fontWeight: 'bold',\n transform: 'rotate(-45deg)',\n zIndex: 1000, // Ensure it appears above other elements\n boxShadow: '0 2px 4px rgba(0,0,0,0.2)',\n width: '220px',\n justifyContent: 'center',\n }}\n >\n SOLD OUT\n </Flex>\n </Flex>\n <BondModalHeader\n bondData={bondData as unknown as BondsData}\n // onDismiss={onDismiss}\n showProjectInfoButton={SDKConfig?.referenceId === 'apebond'}\n />\n <ProjectDescription description={bondData.shortDescription} />\n {/*@ts-ignore*/}\n <BondCards bondData={{ ...bondData, bonusWithFee: -1 }} />\n <Estimations\n depositAmount={'0'}\n inputValue={'0'}\n inputTokenPrice={0}\n /*@ts-ignore*/\n bondData={bondData}\n youSpendString={'0'}\n isZap={isZap}\n fetchingZapQuote={false}\n zapError={false}\n />\n <TokenSelectorPanel\n typedValue={inputValue}\n setTypedValue={setInputValue}\n selectedToken={inputToken}\n handleValueBtn={() => null}\n handleCurrencySelect={() => null}\n bondChainId={bondData?.chainId}\n enableZap={zapSupported.includes(bondData?.chainId as ZapSupportedChainId)}\n bondPrincipalToken={bondData?.lpToken}\n tokenBalance={inputCurrencyBalance ?? undefined}\n selectedTokenPrice={0}\n inputDisabled={true}\n />\n <Flex className=\"modaltable-container button-container\">\n {account && (minTier === null || (userTier !== null && userTier >= minTier)) && (\n <Flex className=\"button-container get\">\n <Button className=\"action-button\" variant=\"secondary\" fullWidth disabled>\n Get {getSymbol(bondData?.lpToken)}\n </Button>\n </Flex>\n )}\n <Flex className=\"button-container buy\">\n <Button className=\"action-button\" fullWidth disabled>\n Buy\n </Button>\n </Flex>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Ae,EAAC,OAAO,EAAC,WAAW,EAAC,SAAS,EAAA,IAAA,EAAC,QAAQ,EAAA,IAAA,EAAA,QAAA,EAAA,CAAA,MAAA,EACjE,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA,EAAA,CAC1B,EAAA,CACJ,CACR,EACDD,GAAA,CAAC,IAAI,IAAC,SAAS,EAAC,sBAAsB,EAAA,QAAA,EACpCA,GAAA,CAAC,MAAM,EAAA,EAAC,SAAS,EAAC,eAAe,EAAC,SAAS,EAAA,IAAA,EAAC,QAAQ,EAAA,IAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAE3C,EAAA,CACJ,IACF,CAAA,EAAA,CACF,EAAA,CACF,KAEPA,GAAA,CAAAE,QAAA,EAAA,EAAA,CAAK,CACN;AACH;;;;"}
|
|
@@ -27,7 +27,8 @@ const stepDelay = 1000;
|
|
|
27
27
|
const TransactionModal = ({ onDismiss, txChain, approvalState, approveCallback, loadingTx, txCallback, bondData, inputToken, inputValue, depositAmount, buyTxHash, rateChanged, }) => {
|
|
28
28
|
// Hooks
|
|
29
29
|
const { chain } = useEVMAccount();
|
|
30
|
-
const { data:
|
|
30
|
+
const { data: tierPointsState } = useTierPoints();
|
|
31
|
+
const { promotionalPoints } = tierPointsState || {};
|
|
31
32
|
const inputTokenPrice = useCurrencyPrice(inputToken ?? null, txChain);
|
|
32
33
|
const { switchChainAsync } = useSwitchChain();
|
|
33
34
|
const SDKConfig = useSDKConfig();
|
|
@@ -43,7 +44,7 @@ const TransactionModal = ({ onDismiss, txChain, approvalState, approveCallback,
|
|
|
43
44
|
const [loadingSwitchChain, setLoadingSwitchChain] = useState(false);
|
|
44
45
|
const [approveLoading, setApproveLoading] = useState(false);
|
|
45
46
|
// Values for regular bonds
|
|
46
|
-
const estimatedOutputAmount = getPayoutAmount(bondData, depositAmount,
|
|
47
|
+
const estimatedOutputAmount = getPayoutAmount(bondData, depositAmount, promotionalPoints ?? '0');
|
|
47
48
|
const estimatedOutputUSD = estimatedOutputAmount * parseFloat(bondData?.payoutTokenPrice ?? '0');
|
|
48
49
|
const preTGEEstimatedOutput = parseFloat(inputValue) / (bondData?.initPrice ?? 0);
|
|
49
50
|
const preTGEEstimatedOutputUSD = preTGEEstimatedOutput * (bondData?.tgePrice ?? 0);
|
|
@@ -127,7 +128,7 @@ const TransactionModal = ({ onDismiss, txChain, approvalState, approveCallback,
|
|
|
127
128
|
const splited = typeof inputToken !== 'string' ? inputToken?.symbol?.split('-') : undefined;
|
|
128
129
|
const trueBondPrice = findHighestTrueBondPrice(
|
|
129
130
|
// @ts-ignore
|
|
130
|
-
TIERS_WEIGHT[getUserTier(
|
|
131
|
+
TIERS_WEIGHT[getUserTier(promotionalPoints)] ?? '0', bondData?.trueBondPrices);
|
|
131
132
|
return (jsxs(Modal, { children: [jsx(ModalHeader, { onDismiss: onDismiss, hideDivider: true }), jsxs(Flex, { sx: { flexDirection: 'column', width: '100%' }, children: [jsxs(Flex, { sx: { width: '100%', alignItems: 'center', p: '10px' }, children: [showSwitchChainFlow && (jsx(StepBubble, { number: 1, title: 'Switch Chain', currentStep: currentStep, loading: loadingSwitchChain })), jsx(StepBubble, { number: showSwitchChainFlow ? 2 : 1, title: 'Approve', currentStep: currentStep, loading: approveLoading || approvalState === ApprovalState.PENDING }), jsx(StepBubble, { number: showSwitchChainFlow ? 3 : 2, title: 'Buy', currentStep: currentStep, loading: loadingTx || verifyingTx, hideBar: true })] }), jsx(Flex, { sx: { width: '100%', mt: '40px', justifyContent: 'center' }, children: jsx(LoadingSpinner, { isLoading: loadingSwitchChain ||
|
|
132
133
|
approveLoading ||
|
|
133
134
|
loadingTx ||
|
|
@@ -165,7 +166,7 @@ const TransactionModal = ({ onDismiss, txChain, approvalState, approveCallback,
|
|
|
165
166
|
borderRadius: 'normal',
|
|
166
167
|
color: 'textDisabledButton',
|
|
167
168
|
justifyContent: 'center',
|
|
168
|
-
}, children: [bondData.earnToken.symbol, " (", getVestingTermsString(bondData), ")"] }), jsxs(Flex, { sx: { width: '100%', background: 'white3', p: '10px', borderRadius: 'normal', mt: '10px' }, children: [jsx(TokenImage, { symbol: bondData.earnToken.symbol, size: 40, chain: txChain }), jsxs(Flex, { sx: { width: '100%', justifyContent: 'space-between', alignItems: 'center' }, children: [jsxs(Flex, { sx: { flexDirection: 'column', fontSize: '12px', ml: '10px' }, children: [jsxs(Flex, { sx: { color: 'textDisabledButton', fontWeight: 400, textDecoration: 'line-through' }, children: ["$", earnTokenPrice(bondData)] }), jsxs(Flex, { sx: { color: 'green', fontWeight: 600 }, children: ["$", discountEarnTokenPriceForUser(bondData, SDKConfig.useTiers, getUserTier(
|
|
169
|
+
}, children: [bondData.earnToken.symbol, " (", getVestingTermsString(bondData), ")"] }), jsxs(Flex, { sx: { width: '100%', background: 'white3', p: '10px', borderRadius: 'normal', mt: '10px' }, children: [jsx(TokenImage, { symbol: bondData.earnToken.symbol, size: 40, chain: txChain }), jsxs(Flex, { sx: { width: '100%', justifyContent: 'space-between', alignItems: 'center' }, children: [jsxs(Flex, { sx: { flexDirection: 'column', fontSize: '12px', ml: '10px' }, children: [jsxs(Flex, { sx: { color: 'textDisabledButton', fontWeight: 400, textDecoration: 'line-through' }, children: ["$", earnTokenPrice(bondData)] }), jsxs(Flex, { sx: { color: 'green', fontWeight: 600 }, children: ["$", discountEarnTokenPriceForUser(bondData, SDKConfig.useTiers, getUserTier(promotionalPoints) ?? undefined)] })] }), jsxs(Flex, { sx: {
|
|
169
170
|
p: '5px',
|
|
170
171
|
borderRadius: 'normal',
|
|
171
172
|
border: '1px solid var(--theme-ui-colors-success)',
|