@ape.swap/bonds-sdk 6.0.2 → 6.0.4
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/uikit-sdk/Tag/ListTag.js +8 -5
- package/dist/components/uikit-sdk/Tag/ListTag.js.map +1 -1
- package/dist/views/Bonds/components/BondRows/BondRow.js +3 -0
- package/dist/views/Bonds/components/BondRows/BondRow.js.map +1 -1
- package/dist/views/ProjectView/components/PriceChart/components/LineChart.js +81 -84
- package/dist/views/ProjectView/components/PriceChart/components/LineChart.js.map +1 -1
- package/dist/views/ProjectView/components/PriceChart/components/utils.js +6 -6
- package/dist/views/ProjectView/components/PriceChart/components/utils.js.map +1 -1
- package/dist/views/ProjectView/components/PriceChart/index.js +2 -1
- package/dist/views/ProjectView/components/PriceChart/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,10 +5,10 @@ import Svg from '../Svg/index.js';
|
|
|
5
5
|
import { icons } from '../Svg/types.js';
|
|
6
6
|
|
|
7
7
|
const bg = {
|
|
8
|
-
['Selling Fast']: '
|
|
9
|
-
['Short Supply']: '
|
|
10
|
-
['New Offer']: '
|
|
11
|
-
['Whale Activity']: '
|
|
8
|
+
['Selling Fast']: '#14121D',
|
|
9
|
+
['Short Supply']: '#14121D',
|
|
10
|
+
['New Offer']: '#14121D',
|
|
11
|
+
['Whale Activity']: '#14121D',
|
|
12
12
|
};
|
|
13
13
|
const colorMap = {
|
|
14
14
|
['Selling Fast']: '#EA901B',
|
|
@@ -17,7 +17,7 @@ const colorMap = {
|
|
|
17
17
|
['Whale Activity']: '#8EE3FF',
|
|
18
18
|
};
|
|
19
19
|
const ListTag = ({ text = '', marketingCampaign }) => {
|
|
20
|
-
return (jsxs(Flex, { sx: {
|
|
20
|
+
return (jsxs(Flex, { className: "list-tag", sx: {
|
|
21
21
|
//@ts-ignore
|
|
22
22
|
background: bg[text] || '#3C6AB530',
|
|
23
23
|
//@ts-ignore
|
|
@@ -32,6 +32,9 @@ const ListTag = ({ text = '', marketingCampaign }) => {
|
|
|
32
32
|
zIndex: 2,
|
|
33
33
|
gap: '5px',
|
|
34
34
|
...MCTagStyles[marketingCampaign],
|
|
35
|
+
'&:hover': {
|
|
36
|
+
background: 'rgb(20 18 29 / 0.36)',
|
|
37
|
+
},
|
|
35
38
|
}, children: [text === 'Selling Fast' && jsx(Svg, { icon: 'SellingFast', width: 20 }), text === 'Short Supply' && jsx(Svg, { icon: icons.SHORT_SUPPLY, width: 20 }), text === 'New Offer' && jsx(Svg, { icon: 'NewOffer', width: 20 }), text === 'Whale Activity' && jsx(Svg, { icon: 'WhaleActivity', width: 20 }), text.toUpperCase()] }));
|
|
36
39
|
};
|
|
37
40
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListTag.js","sources":["../../../../src/components/uikit-sdk/Tag/ListTag.tsx"],"sourcesContent":["import React from 'react'\nimport Flex from '../Flex'\nimport { MCTagStyles } from '../../../utils/campaignStyles'\nimport { MarketingCampaign } from '@ape.swap/apeswap-lists'\nimport Svg from '../Svg'\nimport { icons } from '../Svg/types'\n\nconst bg = {\n ['Selling Fast']: '
|
|
1
|
+
{"version":3,"file":"ListTag.js","sources":["../../../../src/components/uikit-sdk/Tag/ListTag.tsx"],"sourcesContent":["import React from 'react'\nimport Flex from '../Flex'\nimport { MCTagStyles } from '../../../utils/campaignStyles'\nimport { MarketingCampaign } from '@ape.swap/apeswap-lists'\nimport Svg from '../Svg'\nimport { icons } from '../Svg/types'\n\nconst bg = {\n ['Selling Fast']: '#14121D',\n ['Short Supply']: '#14121D',\n ['New Offer']: '#14121D',\n ['Whale Activity']: '#14121D',\n}\n\nconst colorMap = {\n ['Selling Fast']: '#EA901B',\n ['Short Supply']: '#FCA384',\n ['New Offer']: '#AA80F9',\n ['Whale Activity']: '#8EE3FF',\n}\n\nconst ListTag = ({ text = '', marketingCampaign }: { text?: string; marketingCampaign?: MarketingCampaign }) => {\n return (\n <Flex\n className=\"list-tag\"\n sx={{\n //@ts-ignore\n background: bg[text] || '#3C6AB530',\n //@ts-ignore\n color: colorMap[text] || '#3b78d3',\n fontSize: '10px',\n fontWeight: 600,\n alignItems: 'center',\n lineHeight: '15px',\n p: '2px 6px',\n borderRadius: '5px',\n width: 'fit-content',\n zIndex: 2,\n gap: '5px',\n ...MCTagStyles[marketingCampaign!],\n '&:hover': {\n background: 'rgb(20 18 29 / 0.36)',\n },\n }}\n >\n {text === 'Selling Fast' && <Svg icon={'SellingFast'} width={20} />}\n {text === 'Short Supply' && <Svg icon={icons.SHORT_SUPPLY} width={20} />}\n {text === 'New Offer' && <Svg icon={'NewOffer'} width={20} />}\n {text === 'Whale Activity' && <Svg icon={'WhaleActivity'} width={20} />}\n {text.toUpperCase()}\n </Flex>\n )\n}\n\nexport default ListTag\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;AAOA,MAAM,EAAE,GAAG;IACT,CAAC,cAAc,GAAG,SAAS;IAC3B,CAAC,cAAc,GAAG,SAAS;IAC3B,CAAC,WAAW,GAAG,SAAS;IACxB,CAAC,gBAAgB,GAAG,SAAS;CAC9B;AAED,MAAM,QAAQ,GAAG;IACf,CAAC,cAAc,GAAG,SAAS;IAC3B,CAAC,cAAc,GAAG,SAAS;IAC3B,CAAC,WAAW,GAAG,SAAS;IACxB,CAAC,gBAAgB,GAAG,SAAS;CAC9B;AAED,MAAM,OAAO,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,iBAAiB,EAA4D,KAAI;IAC7G,QACEA,KAAC,IAAI,EAAA,EACH,SAAS,EAAC,UAAU,EACpB,EAAE,EAAE;;AAEF,YAAA,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,WAAW;;AAEnC,YAAA,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,SAAS;AAClC,YAAA,QAAQ,EAAE,MAAM;AAChB,YAAA,UAAU,EAAE,GAAG;AACf,YAAA,UAAU,EAAE,QAAQ;AACpB,YAAA,UAAU,EAAE,MAAM;AAClB,YAAA,CAAC,EAAE,SAAS;AACZ,YAAA,YAAY,EAAE,KAAK;AACnB,YAAA,KAAK,EAAE,aAAa;AACpB,YAAA,MAAM,EAAE,CAAC;AACT,YAAA,GAAG,EAAE,KAAK;YACV,GAAG,WAAW,CAAC,iBAAkB,CAAC;AAClC,YAAA,SAAS,EAAE;AACT,gBAAA,UAAU,EAAE,sBAAsB;AACnC,aAAA;AACF,SAAA,EAAA,QAAA,EAAA,CAEA,IAAI,KAAK,cAAc,IAAIC,IAAC,GAAG,EAAA,EAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,GAAI,EAClE,IAAI,KAAK,cAAc,IAAIA,GAAA,CAAC,GAAG,EAAA,EAAC,IAAI,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE,EAAA,CAAI,EACvE,IAAI,KAAK,WAAW,IAAIA,GAAA,CAAC,GAAG,EAAA,EAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAA,CAAI,EAC5D,IAAI,KAAK,gBAAgB,IAAIA,GAAA,CAAC,GAAG,EAAA,EAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,EAAA,CAAI,EACtE,IAAI,CAAC,WAAW,EAAE,CAAA,EAAA,CACd;AAEX;;;;"}
|
|
@@ -48,6 +48,9 @@ const BondRow = ({ bondAddress, bondChain, marketingCampaign, payoutToken, billT
|
|
|
48
48
|
// Insert special campaign styles here
|
|
49
49
|
...MCBondRowStyles[marketingCampaign],
|
|
50
50
|
cursor: !bondSoldOut || (soldoutBondsCount && !isOpen) ? 'pointer' : 'default',
|
|
51
|
+
'&:hover .list-tag': {
|
|
52
|
+
background: 'rgb(20 18 29 / 0.25)',
|
|
53
|
+
},
|
|
51
54
|
}, children: [jsx("div", { className: "token-info-container", sx: { width: ['45%', '45%', '45%', '30%'], minWidth: ['unset', 'unset', 'unset', '400px'] }, children: jsx(TokenInfoAndName, { tokenSymbol: payoutToken?.symbol, chain: bondChain, tag: tag, marketingCampaign: marketingCampaign }) }), SDKConfig.useCardsView && shortDescription && (jsx("div", { className: "short-description", children: jsx(SafeHTMLComponent, { html: shortDescription }) })), jsxs("div", { className: "bond-info-columns", sx: { width: ['55%', '55%', '55%', '70%'] }, children: [!SDKConfig.useCardsView && jsx(Flex, { sx: { display: ['none', 'none', 'none', 'flex'], width: '125px' } }), jsx(BonusContainer, { trueBondPrices: trueBondPrices, minTier: minTier, bonus: bonus, airdropTooltip: airdropTooltip, isIREET: payoutToken.symbol.toLowerCase() === 'ireet' }), jsxs("div", { className: "terms-column", children: [vestingTermString, vestingCliffString && (jsx(TooltipBubble, { className: "tooltip-bubble", body: jsx(Flex, { children: vestingCliffString }), width: "180px", placement: "bottomRight", transformTip: "translate(13%, 0%)", children: jsx(Flex, { sx: { opacity: 0.6, ml: '6px' }, children: jsx(Svg, { icon: "questionCircle", width: "12px" }) }) }))] }), jsx("div", { className: "tokens-remaining-column", children: bondSoldOut ? ('-') : (jsx(ProgressBarWrapper, { title: '', value: jsx(ProgressBar, { value: percentageAvailable }), style: {
|
|
52
55
|
width: '127px',
|
|
53
56
|
height: '25px',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BondRow.js","sources":["../../../../../src/views/Bonds/components/BondRows/BondRow.tsx"],"sourcesContent":["import React from 'react'\nimport { TrueBondPrices } from '../../../../types/bonds'\nimport ProgressBar from '../../../../components/ProgressBar/ProgressBar'\nimport ProgressBarWrapper from '../../../../components/ProgressBar/ProgressBarWrapper'\nimport TokenInfoAndName from '../../../../components/TokenInfoAndName'\nimport Tooltip from '../../../../components/Tooltip/Tooltip'\nimport { ChainId, LaunchBondTiers, MarketingCampaign, Token } from '@ape.swap/apeswap-lists'\nimport useModal from '../../../../hooks/useModal'\nimport ModalHandler from './ModalHandler'\nimport track from '../../../../utils/track'\nimport BonusContainer from '../BonusComponents/BonusContainer'\nimport ModalHandlerPreTGE from './ModalHandlerPreTGE'\nimport { useSDKConfig } from '../../../../state/useSDKConfig'\nimport SafeHTMLComponent from '../../../../components/SafeHTMLComponent'\nimport { MCBondRowStyles } from '../../../../utils/campaignStyles'\nimport Flex from '../../../../components/uikit-sdk/Flex'\nimport TooltipBubble from '../../../../components/uikit-sdk/TooltipBubble'\nimport Svg from '../../../../components/uikit-sdk/Svg'\n\ninterface BondRowProps {\n bondAddress: string\n bondChain: ChainId\n marketingCampaign?: MarketingCampaign\n payoutToken: Token\n billType: string\n tag?: string\n bondSoldOut?: boolean\n trueBondPrices?: TrueBondPrices[]\n minTier?: LaunchBondTiers\n bonus?: string\n airdropTooltip?: string\n vestingTermString: string\n vestingCliffString?: string\n percentageAvailable: number\n remainingTokensString: string\n projectURL?: string\n twitterURL?: string\n shortDescription?: string\n soldoutBondsCount?: number\n isOpen?: boolean\n cgId?: string\n dexscreener?: string\n}\n\nconst BondRow: React.FC<BondRowProps> = ({\n bondAddress,\n bondChain,\n marketingCampaign,\n payoutToken,\n billType,\n tag,\n bondSoldOut,\n trueBondPrices,\n minTier,\n bonus,\n airdropTooltip,\n vestingTermString,\n vestingCliffString,\n percentageAvailable,\n remainingTokensString,\n projectURL,\n twitterURL,\n shortDescription,\n soldoutBondsCount,\n isOpen,\n cgId,\n dexscreener,\n}) => {\n const SDKConfig = useSDKConfig()\n\n // Modal\n const [openBuyModal] = useModal(\n <ModalHandler bondAddress={bondAddress} bondChain={bondChain} />,\n true,\n true,\n `buyBondModal-${bondAddress.toLowerCase()}-${bondChain}`,\n )\n\n const [openPreTGEBondModal] = useModal(\n <ModalHandlerPreTGE bondAddress={bondAddress} bondChain={bondChain} />,\n true,\n true,\n `preTGEBuyBondModal:${bondAddress.toLowerCase()}-${bondChain}}`,\n )\n\n const handleOpenModal = () => {\n if (bondSoldOut) return\n if (billType === 'fcfs') {\n openPreTGEBondModal()\n } else {\n openBuyModal()\n }\n if (typeof window !== 'undefined') {\n const locationPath = window.location.pathname.replace('/', '')\n window.history.pushState({}, '', `${locationPath}?bondAddress=${bondAddress}&bondChain=${bondChain}`)\n }\n track({\n event: 'buyModalOpen',\n chain: bondChain,\n data: {\n cat: 'Row',\n bond: payoutToken.symbol,\n bondChain: bondChain,\n },\n })\n }\n\n return (\n <div\n className=\"bond-row\"\n onClick={handleOpenModal}\n key={`${bondAddress}-${bondChain}`}\n sx={{\n borderRadius: 'normal',\n // Insert special campaign styles here\n ...MCBondRowStyles[marketingCampaign!],\n cursor: !bondSoldOut || (soldoutBondsCount && !isOpen) ? 'pointer' : 'default',\n }}\n >\n <div\n className=\"token-info-container\"\n sx={{ width: ['45%', '45%', '45%', '30%'], minWidth: ['unset', 'unset', 'unset', '400px'] }}\n >\n <TokenInfoAndName\n tokenSymbol={payoutToken?.symbol}\n chain={bondChain}\n tag={tag}\n marketingCampaign={marketingCampaign}\n />\n </div>\n {SDKConfig.useCardsView && shortDescription && (\n <div className=\"short-description\">\n <SafeHTMLComponent html={shortDescription} />\n </div>\n )}\n <div className=\"bond-info-columns\" sx={{ width: ['55%', '55%', '55%', '70%'] }}>\n {!SDKConfig.useCardsView && <Flex sx={{ display: ['none', 'none', 'none', 'flex'], width: '125px' }} />}\n <BonusContainer\n trueBondPrices={trueBondPrices}\n minTier={minTier}\n bonus={bonus}\n airdropTooltip={airdropTooltip}\n isIREET={payoutToken.symbol.toLowerCase() === 'ireet'}\n />\n <div className=\"terms-column\">\n {vestingTermString}\n {vestingCliffString && (\n <TooltipBubble\n className=\"tooltip-bubble\"\n body={<Flex>{vestingCliffString}</Flex>}\n width=\"180px\"\n placement=\"bottomRight\"\n transformTip=\"translate(13%, 0%)\"\n >\n <Flex sx={{ opacity: 0.6, ml: '6px' }}>\n <Svg icon=\"questionCircle\" width=\"12px\" />\n </Flex>\n </TooltipBubble>\n )}\n </div>\n <div className=\"tokens-remaining-column\">\n {bondSoldOut ? (\n '-'\n ) : (\n <ProgressBarWrapper\n title={''}\n value={<ProgressBar value={percentageAvailable} />}\n style={{\n width: '127px',\n height: '25px',\n flexDirection: 'column',\n justifyContent: 'center',\n display: ['none', 'none', 'none', 'flex'],\n }}\n showTooltip={true}\n toolTip={remainingTokensString}\n />\n )}\n </div>\n <div className=\"tooltip-column\">\n {soldoutBondsCount ? (\n <Flex sx={{ gap: '5px', fontSize: '13px', fontWeight: 500, opacity: 0.5 }}>\n ({soldoutBondsCount})\n <Svg icon=\"caret\" direction={isOpen ? 'up' : 'down'} width=\"8px\" />\n </Flex>\n ) : (\n <TooltipBubble\n className=\"tooltip-bubble\"\n body={\n <Tooltip\n earnTokenContract={payoutToken?.address?.[bondChain] ?? ''}\n earnTokenSymbol={payoutToken?.symbol ?? ''}\n bondContract={bondAddress ?? ''}\n projectLink={projectURL}\n twitter={twitterURL}\n chain={bondChain}\n isSoldOut={bondSoldOut}\n billType={billType}\n cgId={cgId}\n dexscreener={dexscreener}\n />\n }\n width=\"205px\"\n placement=\"bottomRight\"\n transformTip=\"translate(7%, -2%)\"\n >\n <Flex className=\"more-icon\" sx={{ opacity: 0.8 }}>\n <Svg icon=\"more\" width=\"25px\" />\n </Flex>\n </TooltipBubble>\n )}\n </div>\n </div>\n </div>\n )\n}\n\nexport default BondRow\n"],"names":["_jsx","_jsxs","Tooltip"],"mappings":";;;;;;;;;;;;;;;;;AA4CA,MAAM,OAAO,GAA2B,CAAC,EACvC,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,GAAG,EACH,WAAW,EACX,cAAc,EACd,OAAO,EACP,KAAK,EACL,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACN,IAAI,EACJ,WAAW,GACZ,KAAI;AACH,IAAA,MAAM,SAAS,GAAG,YAAY,EAAE;;AAGhC,IAAA,MAAM,CAAC,YAAY,CAAC,GAAG,QAAQ,CAC7BA,GAAA,CAAC,YAAY,EAAA,EAAC,WAAW,EAAE,WAA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AAA,EAAA,CACF,KArGD,CAAA,EAAG,WAAW,IAAI,SAAS,CAAA,CAAE,CAsG9B;AAEV;;;;"}
|
|
1
|
+
{"version":3,"file":"BondRow.js","sources":["../../../../../src/views/Bonds/components/BondRows/BondRow.tsx"],"sourcesContent":["import React from 'react'\nimport { TrueBondPrices } from '../../../../types/bonds'\nimport ProgressBar from '../../../../components/ProgressBar/ProgressBar'\nimport ProgressBarWrapper from '../../../../components/ProgressBar/ProgressBarWrapper'\nimport TokenInfoAndName from '../../../../components/TokenInfoAndName'\nimport Tooltip from '../../../../components/Tooltip/Tooltip'\nimport { ChainId, LaunchBondTiers, MarketingCampaign, Token } from '@ape.swap/apeswap-lists'\nimport useModal from '../../../../hooks/useModal'\nimport ModalHandler from './ModalHandler'\nimport track from '../../../../utils/track'\nimport BonusContainer from '../BonusComponents/BonusContainer'\nimport ModalHandlerPreTGE from './ModalHandlerPreTGE'\nimport { useSDKConfig } from '../../../../state/useSDKConfig'\nimport SafeHTMLComponent from '../../../../components/SafeHTMLComponent'\nimport { MCBondRowStyles } from '../../../../utils/campaignStyles'\nimport Flex from '../../../../components/uikit-sdk/Flex'\nimport TooltipBubble from '../../../../components/uikit-sdk/TooltipBubble'\nimport Svg from '../../../../components/uikit-sdk/Svg'\n\ninterface BondRowProps {\n bondAddress: string\n bondChain: ChainId\n marketingCampaign?: MarketingCampaign\n payoutToken: Token\n billType: string\n tag?: string\n bondSoldOut?: boolean\n trueBondPrices?: TrueBondPrices[]\n minTier?: LaunchBondTiers\n bonus?: string\n airdropTooltip?: string\n vestingTermString: string\n vestingCliffString?: string\n percentageAvailable: number\n remainingTokensString: string\n projectURL?: string\n twitterURL?: string\n shortDescription?: string\n soldoutBondsCount?: number\n isOpen?: boolean\n cgId?: string\n dexscreener?: string\n}\n\nconst BondRow: React.FC<BondRowProps> = ({\n bondAddress,\n bondChain,\n marketingCampaign,\n payoutToken,\n billType,\n tag,\n bondSoldOut,\n trueBondPrices,\n minTier,\n bonus,\n airdropTooltip,\n vestingTermString,\n vestingCliffString,\n percentageAvailable,\n remainingTokensString,\n projectURL,\n twitterURL,\n shortDescription,\n soldoutBondsCount,\n isOpen,\n cgId,\n dexscreener,\n}) => {\n const SDKConfig = useSDKConfig()\n\n // Modal\n const [openBuyModal] = useModal(\n <ModalHandler bondAddress={bondAddress} bondChain={bondChain} />,\n true,\n true,\n `buyBondModal-${bondAddress.toLowerCase()}-${bondChain}`,\n )\n\n const [openPreTGEBondModal] = useModal(\n <ModalHandlerPreTGE bondAddress={bondAddress} bondChain={bondChain} />,\n true,\n true,\n `preTGEBuyBondModal:${bondAddress.toLowerCase()}-${bondChain}}`,\n )\n\n const handleOpenModal = () => {\n if (bondSoldOut) return\n if (billType === 'fcfs') {\n openPreTGEBondModal()\n } else {\n openBuyModal()\n }\n if (typeof window !== 'undefined') {\n const locationPath = window.location.pathname.replace('/', '')\n window.history.pushState({}, '', `${locationPath}?bondAddress=${bondAddress}&bondChain=${bondChain}`)\n }\n track({\n event: 'buyModalOpen',\n chain: bondChain,\n data: {\n cat: 'Row',\n bond: payoutToken.symbol,\n bondChain: bondChain,\n },\n })\n }\n\n return (\n <div\n className=\"bond-row\"\n onClick={handleOpenModal}\n key={`${bondAddress}-${bondChain}`}\n sx={{\n borderRadius: 'normal',\n // Insert special campaign styles here\n ...MCBondRowStyles[marketingCampaign!],\n cursor: !bondSoldOut || (soldoutBondsCount && !isOpen) ? 'pointer' : 'default',\n '&:hover .list-tag': {\n background: 'rgb(20 18 29 / 0.25)',\n },\n }}\n >\n <div\n className=\"token-info-container\"\n sx={{ width: ['45%', '45%', '45%', '30%'], minWidth: ['unset', 'unset', 'unset', '400px'] }}\n >\n <TokenInfoAndName\n tokenSymbol={payoutToken?.symbol}\n chain={bondChain}\n tag={tag}\n marketingCampaign={marketingCampaign}\n />\n </div>\n {SDKConfig.useCardsView && shortDescription && (\n <div className=\"short-description\">\n <SafeHTMLComponent html={shortDescription} />\n </div>\n )}\n <div className=\"bond-info-columns\" sx={{ width: ['55%', '55%', '55%', '70%'] }}>\n {!SDKConfig.useCardsView && <Flex sx={{ display: ['none', 'none', 'none', 'flex'], width: '125px' }} />}\n <BonusContainer\n trueBondPrices={trueBondPrices}\n minTier={minTier}\n bonus={bonus}\n airdropTooltip={airdropTooltip}\n isIREET={payoutToken.symbol.toLowerCase() === 'ireet'}\n />\n <div className=\"terms-column\">\n {vestingTermString}\n {vestingCliffString && (\n <TooltipBubble\n className=\"tooltip-bubble\"\n body={<Flex>{vestingCliffString}</Flex>}\n width=\"180px\"\n placement=\"bottomRight\"\n transformTip=\"translate(13%, 0%)\"\n >\n <Flex sx={{ opacity: 0.6, ml: '6px' }}>\n <Svg icon=\"questionCircle\" width=\"12px\" />\n </Flex>\n </TooltipBubble>\n )}\n </div>\n <div className=\"tokens-remaining-column\">\n {bondSoldOut ? (\n '-'\n ) : (\n <ProgressBarWrapper\n title={''}\n value={<ProgressBar value={percentageAvailable} />}\n style={{\n width: '127px',\n height: '25px',\n flexDirection: 'column',\n justifyContent: 'center',\n display: ['none', 'none', 'none', 'flex'],\n }}\n showTooltip={true}\n toolTip={remainingTokensString}\n />\n )}\n </div>\n <div className=\"tooltip-column\">\n {soldoutBondsCount ? (\n <Flex sx={{ gap: '5px', fontSize: '13px', fontWeight: 500, opacity: 0.5 }}>\n ({soldoutBondsCount})\n <Svg icon=\"caret\" direction={isOpen ? 'up' : 'down'} width=\"8px\" />\n </Flex>\n ) : (\n <TooltipBubble\n className=\"tooltip-bubble\"\n body={\n <Tooltip\n earnTokenContract={payoutToken?.address?.[bondChain] ?? ''}\n earnTokenSymbol={payoutToken?.symbol ?? ''}\n bondContract={bondAddress ?? ''}\n projectLink={projectURL}\n twitter={twitterURL}\n chain={bondChain}\n isSoldOut={bondSoldOut}\n billType={billType}\n cgId={cgId}\n dexscreener={dexscreener}\n />\n }\n width=\"205px\"\n placement=\"bottomRight\"\n transformTip=\"translate(7%, -2%)\"\n >\n <Flex className=\"more-icon\" sx={{ opacity: 0.8 }}>\n <Svg icon=\"more\" width=\"25px\" />\n </Flex>\n </TooltipBubble>\n )}\n </div>\n </div>\n </div>\n )\n}\n\nexport default BondRow\n"],"names":["_jsx","_jsxs","Tooltip"],"mappings":";;;;;;;;;;;;;;;;;AA4CA,MAAM,OAAO,GAA2B,CAAC,EACvC,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,GAAG,EACH,WAAW,EACX,cAAc,EACd,OAAO,EACP,KAAK,EACL,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,EACN,IAAI,EACJ,WAAW,GACZ,KAAI;AACH,IAAA,MAAM,SAAS,GAAG,YAAY,EAAE;;AAGhC,IAAA,MAAM,CAAC,YAAY,CAAC,GAAG,QAAQ,CAC7BA,GAAA,CAAC,YAAY,EAAA,EAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAA,CAAI,EAChE,IAAI,EACJ,IAAI,EACJ,CAAA,aAAA,EAAgB,WAAW,CAAC,WAAW,EAAE,CAAA,CAAA,EAAI,SAAS,CAAA,CAAE,CACzD;AAED,IAAA,MAAM,CAAC,mBAAmB,CAAC,GAAG,QAAQ,CACpCA,GAAA,CAAC,kBAAkB,EAAA,EAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAA,CAAI,EACtE,IAAI,EACJ,IAAI,EACJ,CAAA,mBAAA,EAAsB,WAAW,CAAC,WAAW,EAAE,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA,CAAG,CAChE;IAED,MAAM,eAAe,GAAG,MAAK;AAC3B,QAAA,IAAI,WAAW;YAAE;AACjB,QAAA,IAAI,QAAQ,KAAK,MAAM,EAAE;AACvB,YAAA,mBAAmB,EAAE;QACvB;aAAO;AACL,YAAA,YAAY,EAAE;QAChB;AACA,QAAA,IAAI,OAAO,MAA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FA,GAAA,CAACE,eAAO,IACN,iBAAiB,EAAE,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC,IAAI,EAAE,EAC1D,eAAe,EAAE,WAAW,EAAE,MAAM,IAAI,EAAE,EAC1C,YAAY,EAAE,WAAW,IAAI,EAAE,EAC/B,WAAW,EAAE,UAAU,EACvB,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,WAAW,EAAA,CACxB,EAEJ,KAAK,EAAC,OAAO,EACb,SAAS,EAAC,aAAa,EACvB,YAAY,EAAC,oBAAoB,EAAA,QAAA,EAEjCF,IAAC,IAAI,EAAA,EAAC,SAAS,EAAC,WAAW,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAA,QAAA,EAC9CA,GAAA,CAAC,GAAG,EAAA,EAAC,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,GAAG,EAAA,CAC3B,EAAA,CACO,CACjB,EAAA,CACG,CAAA,EAAA,CACF,KAxGD,CAAA,EAAG,WAAW,IAAI,SAAS,CAAA,CAAE,CAyG9B;AAEV;;;;"}
|
|
@@ -1,98 +1,95 @@
|
|
|
1
1
|
import { jsx } from 'theme-ui/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { useRef, useMemo, useEffect } from 'react';
|
|
3
3
|
import { createChart, CrosshairMode, ColorType, LineStyle } from 'lightweight-charts';
|
|
4
4
|
import { getFirstNonZeroDigits } from '../../../../../utils/roundNumber.js';
|
|
5
5
|
import { determineValues } from './utils.js';
|
|
6
6
|
|
|
7
7
|
const LineChart = ({ historicalPrices, hasDiscount, bondPrice, tokenPrice, }) => {
|
|
8
|
-
// reference for DOM element to create with chart
|
|
9
|
-
const data = historicalPrices;
|
|
10
8
|
const chartContainerId = 'lineChartContainer';
|
|
11
|
-
const
|
|
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);
|
|
9
|
+
const chartRef = useRef(null);
|
|
20
10
|
const discount = 1 - parseFloat(bondPrice ?? '0') / parseFloat(tokenPrice ?? '0');
|
|
21
11
|
const discountToUse = discount > 0 ? discount : 0;
|
|
22
|
-
const bottomScaleMargin = discountToUse + 0.15;
|
|
12
|
+
const bottomScaleMargin = Math.min(discountToUse + 0.15, 0.85);
|
|
13
|
+
const formattedData = useMemo(() => {
|
|
14
|
+
const mapped = historicalPrices?.map((entry) => ({
|
|
15
|
+
time: parseInt(entry.timestamp),
|
|
16
|
+
value: parseFloat(getFirstNonZeroDigits(entry.close, 4)),
|
|
17
|
+
})) ?? [];
|
|
18
|
+
mapped.push({ time: Math.floor(new Date().getTime() / 1000), value: parseFloat(tokenPrice) });
|
|
19
|
+
return mapped;
|
|
20
|
+
}, [historicalPrices, tokenPrice]);
|
|
23
21
|
useEffect(() => {
|
|
24
22
|
const chartContainer = document.getElementById(chartContainerId);
|
|
25
|
-
if (chartContainer
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}, [bondPrice, bottomScaleMargin, chartCreated, formattedData, hasDiscount, tokenPrice]);
|
|
23
|
+
if (!chartContainer || chartRef.current)
|
|
24
|
+
return;
|
|
25
|
+
const [precision, minMove] = determineValues(parseFloat(bondPrice));
|
|
26
|
+
const chart = createChart(chartContainer, {
|
|
27
|
+
width: 0,
|
|
28
|
+
height: 0,
|
|
29
|
+
layout: {
|
|
30
|
+
background: { type: ColorType.Solid, color: 'transparent' },
|
|
31
|
+
textColor: '#73728E',
|
|
32
|
+
},
|
|
33
|
+
grid: {
|
|
34
|
+
vertLines: { color: '#73728E' },
|
|
35
|
+
horzLines: { color: '#73728E' },
|
|
36
|
+
},
|
|
37
|
+
crosshair: { mode: CrosshairMode.Magnet },
|
|
38
|
+
rightPriceScale: {
|
|
39
|
+
borderColor: '#73728E',
|
|
40
|
+
visible: true,
|
|
41
|
+
scaleMargins: { top: 0.12, bottom: bottomScaleMargin },
|
|
42
|
+
},
|
|
43
|
+
timeScale: {
|
|
44
|
+
borderColor: '#73728E',
|
|
45
|
+
fixLeftEdge: true,
|
|
46
|
+
fixRightEdge: true,
|
|
47
|
+
},
|
|
48
|
+
handleScroll: {
|
|
49
|
+
mouseWheel: false,
|
|
50
|
+
pressedMouseMove: false,
|
|
51
|
+
horzTouchDrag: false,
|
|
52
|
+
vertTouchDrag: false,
|
|
53
|
+
},
|
|
54
|
+
handleScale: {
|
|
55
|
+
axisPressedMouseMove: false,
|
|
56
|
+
mouseWheel: false,
|
|
57
|
+
pinch: false,
|
|
58
|
+
},
|
|
59
|
+
localization: {
|
|
60
|
+
priceFormatter: (val) => `$${getFirstNonZeroDigits(parseFloat(val), 3)}`,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const areaSeries = chart.addAreaSeries({
|
|
64
|
+
lineColor: '#5E59B5',
|
|
65
|
+
topColor: '#5E59B5',
|
|
66
|
+
bottomColor: '#514CA133',
|
|
67
|
+
priceLineWidth: 2,
|
|
68
|
+
priceLineStyle: LineStyle.Dashed,
|
|
69
|
+
priceLineVisible: true,
|
|
70
|
+
priceFormat: {
|
|
71
|
+
precision,
|
|
72
|
+
minMove,
|
|
73
|
+
formatter: (val) => getFirstNonZeroDigits(parseFloat(val), 3),
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
//@ts-ignore
|
|
77
|
+
areaSeries.setData(formattedData);
|
|
78
|
+
areaSeries.createPriceLine({
|
|
79
|
+
price: parseFloat(bondPrice),
|
|
80
|
+
color: hasDiscount ? '#38A611' : '#DF4141',
|
|
81
|
+
lineWidth: 2,
|
|
82
|
+
lineStyle: LineStyle.Dashed,
|
|
83
|
+
axisLabelVisible: true,
|
|
84
|
+
title: 'Bond Price',
|
|
85
|
+
});
|
|
86
|
+
chart.timeScale().fitContent();
|
|
87
|
+
chartRef.current = chart;
|
|
88
|
+
return () => {
|
|
89
|
+
chart.remove();
|
|
90
|
+
chartRef.current = null;
|
|
91
|
+
};
|
|
92
|
+
}, [bondPrice, bottomScaleMargin, formattedData, hasDiscount]);
|
|
96
93
|
return jsx("div", { id: chartContainerId, style: { width: '100%', height: '100%' } });
|
|
97
94
|
};
|
|
98
95
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.js","sources":["../../../../../../src/views/ProjectView/components/PriceChart/components/LineChart.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"LineChart.js","sources":["../../../../../../src/views/ProjectView/components/PriceChart/components/LineChart.tsx"],"sourcesContent":["import React, { useEffect, useRef, useMemo } 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 const chartContainerId = 'lineChartContainer'\n const chartRef = useRef<ReturnType<typeof createChart> | null>(null)\n\n const discount = 1 - parseFloat(bondPrice ?? '0') / parseFloat(tokenPrice ?? '0')\n const discountToUse = discount > 0 ? discount : 0\n const bottomScaleMargin = Math.min(discountToUse + 0.15, 0.85)\n\n const formattedData = useMemo(() => {\n const mapped =\n historicalPrices?.map((entry) => ({\n time: parseInt(entry.timestamp),\n value: parseFloat(getFirstNonZeroDigits(entry.close, 4)),\n })) ?? []\n mapped.push({ time: Math.floor(new Date().getTime() / 1000), value: parseFloat(tokenPrice) })\n return mapped\n }, [historicalPrices, tokenPrice])\n\n useEffect(() => {\n const chartContainer = document.getElementById(chartContainerId)\n if (!chartContainer || chartRef.current) return\n\n const [precision, minMove] = determineValues(parseFloat(bondPrice))\n\n const chart = createChart(chartContainer, {\n width: 0,\n height: 0,\n layout: {\n background: { type: ColorType.Solid, color: 'transparent' },\n textColor: '#73728E',\n },\n grid: {\n vertLines: { color: '#73728E' },\n horzLines: { color: '#73728E' },\n },\n crosshair: { mode: CrosshairMode.Magnet },\n rightPriceScale: {\n borderColor: '#73728E',\n visible: true,\n scaleMargins: { top: 0.12, bottom: bottomScaleMargin },\n },\n timeScale: {\n borderColor: '#73728E',\n fixLeftEdge: true,\n fixRightEdge: true,\n },\n handleScroll: {\n mouseWheel: false,\n pressedMouseMove: false,\n horzTouchDrag: false,\n vertTouchDrag: false,\n },\n handleScale: {\n axisPressedMouseMove: false,\n mouseWheel: false,\n pinch: false,\n },\n localization: {\n priceFormatter: (val: string) => `$${getFirstNonZeroDigits(parseFloat(val), 3)}`,\n },\n })\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 //@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 chartRef.current = chart\n\n return () => {\n chart.remove()\n chartRef.current = null\n }\n }, [bondPrice, bottomScaleMargin, formattedData, hasDiscount])\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;IACH,MAAM,gBAAgB,GAAG,oBAAoB;AAC7C,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAwC,IAAI,CAAC;AAEpE,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,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,IAAI,EAAE,IAAI,CAAC;AAE9D,IAA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AA,CAAC;;AAGF,QAAA,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC;QAEjC,UAAU,CAAC,eAAe,CAAC;AACzB,YAAA,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC;YAC5B,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS;AAC1C,YAAA,SAAS,EAAE,CAAC;YACZ,SAAS,EAAE,SAAS,CAAC,MAAM;AAC3B,YAAA,gBAAgB,EAAE,IAAI;AACtB,YAAA,KAAK,EAAE,YAAY;AACpB,SAAA,CAAC;AAEF,QAAA,KAAK,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE;AAC9B,QAAA,QAAQ,CAAC,OAAO,GAAG,KAAK;AAExB,QAAA,OAAO,MAAK;YACV,KAAK,CAAC,MAAM,EAAE;AACd,YAAA,QAAQ,CAAC,OAAO,GAAG,IAAI;AACzB,QAAA,CAAC;IACH,CAAC,EAAE,CAAC,SAAS,EAAE,iBAAiB,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AAE9D,IAAA,OAAOA,aAAK,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAQ;AACpF;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const determineValues = (input) => {
|
|
2
|
-
|
|
3
|
-
if (input > 1) {
|
|
2
|
+
if (input > 1)
|
|
4
3
|
return [2, 0.01];
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let
|
|
4
|
+
// Guard: 0, NaN, Infinity all cause the while loop to run forever
|
|
5
|
+
if (!input || !isFinite(input))
|
|
6
|
+
return [2, 0.01];
|
|
7
|
+
let index = 2;
|
|
8
|
+
let check = 1;
|
|
9
9
|
while (input <= check) {
|
|
10
10
|
index += 1;
|
|
11
11
|
check *= 0.1;
|
|
@@ -1 +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
|
|
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 > 1) return [2, 0.01]\n // Guard: 0, NaN, Infinity all cause the while loop to run forever\n if (!input || !isFinite(input)) return [2, 0.01]\n\n let index = 2\n let check = 1\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;IACjE,IAAI,KAAK,GAAG,CAAC;AAAE,QAAA,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC;;AAE/B,IAAA,IAAI,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC;IAEhD,IAAI,KAAK,GAAG,CAAC;IACb,IAAI,KAAK,GAAG,CAAC;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;;;;"}
|
|
@@ -18,6 +18,7 @@ const PriceChart = ({ selectedBond, historicalPrices, }) => {
|
|
|
18
18
|
const hasDiscount = (trueBondPrice?.bonus ?? 0) > 0;
|
|
19
19
|
const contractAddress = selectedBond.contractAddress[selectedBond.chainId];
|
|
20
20
|
const [show, setShow] = useState(false);
|
|
21
|
+
const priceBelowChartPrecision = earnTokenPrice > 0 && earnTokenPrice < 1e-6;
|
|
21
22
|
const [chartOption, setChartOption] = useState('line');
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
// This effect is to ensure that the charts are only rendered on the client
|
|
@@ -31,7 +32,7 @@ const PriceChart = ({ selectedBond, historicalPrices, }) => {
|
|
|
31
32
|
}, 50);
|
|
32
33
|
return () => clearTimeout(timer);
|
|
33
34
|
}, [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
|
+
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 && !priceBelowChartPrecision ? (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
|
};
|
|
36
37
|
|
|
37
38
|
export { PriceChart as default };
|
|
@@ -1 +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,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,YAAY,CAAC,OAAO,CAAC;IAE1E,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC;IAChD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAyB,MAAM,CAAC;IAE9E,SAAS,CAAC,MAAK;;QAEb,OAAO,CAAC,IAAI,CAAC;IACf,CAAC,EAAE,EAAE,CAAC;IAEN,SAAS,CAAC,MAAK;;QAEb,OAAO,CAAC,KAAK,CAAC;AACd,QAAA,MAAM,KAAK,GAAG,UAAU,CAAC,MAAK;YAC5B,OAAO,CAAC,IAAI,CAAC;QACf,CAAC,EAAE,EAAE,CAAC;AACN,QAAA,OAAO,MAAM,YAAY,CAAC,KAAK,CAAC;AAClC,IAAA,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;AAErB,IAAA,QACEA,IAAA,CAAC,IAAI,EAAA,EAAC,EAAE,EAAE,MAAM,CAAC,cAAc,aAC7BA,IAAA,CAAC,IAAI,EAAA,EAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAA,QAAA,EAAA,CAClFC,GAAA,CAAC,IAAI,EAAA,EAAA,QAAA,EAAA,QAAA,EAAA,CAAc,EACnBD,IAAA,CAAC,IAAI,
|
|
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 priceBelowChartPrecision = earnTokenPrice > 0 && earnTokenPrice < 1e-6\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 && !priceBelowChartPrecision ? (\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,YAAY,CAAC,OAAO,CAAC;IAE1E,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC;IAChD,MAAM,wBAAwB,GAAG,cAAc,GAAG,CAAC,IAAI,cAAc,GAAG,IAAI;IAC5E,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAyB,MAAM,CAAC;IAE9E,SAAS,CAAC,MAAK;;QAEb,OAAO,CAAC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