@ape.swap/bonds-sdk 1.0.78-2.test.27 → 1.0.78-2.test.28
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/BondRows/BondRow.d.ts +1 -1
- package/dist/components/BondRows/BondRow.js +16 -14
- package/dist/scss/BondModal.scss +5 -0
- package/dist/views/BondModal/BondModal.js +2 -2
- package/dist/views/BondModal/helper.d.ts +1 -1
- package/dist/views/BondModal/helper.js +3 -3
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
2
|
-
import BigNumber from
|
|
3
|
-
import { ChainId } from
|
|
4
|
-
import ProgressBar from
|
|
5
|
-
import ProgressBarWrapper from
|
|
6
|
-
import TokenInfoAndName from
|
|
7
|
-
import Tooltip from
|
|
8
|
-
import { Svg, TooltipBubble } from
|
|
9
|
-
import { formatDollar, formatValue } from
|
|
10
|
-
import getTimePeriods from
|
|
11
|
-
import { BLOCK_EXPLORER } from
|
|
12
|
-
import { useEffect, useState } from
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { ChainId } from '../../enum/apeswaplists';
|
|
4
|
+
import ProgressBar from '../ProgressBar/ProgressBar';
|
|
5
|
+
import ProgressBarWrapper from '../ProgressBar/ProgressBarWrapper';
|
|
6
|
+
import TokenInfoAndName from '../TokenInfoAndName';
|
|
7
|
+
import Tooltip from '../Tooltip/Tooltip';
|
|
8
|
+
import { Svg, TooltipBubble } from '../uikit-sdk';
|
|
9
|
+
import { formatDollar, formatValue } from '../../utils/formatNumbers';
|
|
10
|
+
import getTimePeriods from '../../utils/getTimePeriods';
|
|
11
|
+
import { BLOCK_EXPLORER } from '../../config/constants/chains';
|
|
12
|
+
import { useEffect, useState } from 'react';
|
|
13
13
|
import '../../scss/BondRow.scss';
|
|
14
|
-
import { Flex } from
|
|
14
|
+
import { Flex } from 'theme-ui';
|
|
15
15
|
var BondRow = function (_a) {
|
|
16
16
|
var _b, _c, _d;
|
|
17
17
|
var bond = _a.bond, hotBonds = _a.hotBonds;
|
|
@@ -19,7 +19,7 @@ var BondRow = function (_a) {
|
|
|
19
19
|
var _e = useState(false), isModalOpen = _e[0], setIsModalOpen = _e[1];
|
|
20
20
|
useEffect(function () {
|
|
21
21
|
if (isModalOpen === true) {
|
|
22
|
-
if (typeof window !==
|
|
22
|
+
if (typeof window !== 'undefined') {
|
|
23
23
|
var newUrl = "/?bondAddress=".concat(bond.billAddress, "&bondChain=").concat(bond.chainId);
|
|
24
24
|
window.history.pushState({ path: newUrl }, '', newUrl);
|
|
25
25
|
console.log(isModalOpen);
|
|
@@ -32,6 +32,8 @@ var BondRow = function (_a) {
|
|
|
32
32
|
}, []);
|
|
33
33
|
var rowClick = function (bond) {
|
|
34
34
|
setIsModalOpen(true);
|
|
35
|
+
var newUrl = "/?bondAddress=".concat(bond.billAddress, "&bondChain=").concat(bond.chainId);
|
|
36
|
+
window.location.href = newUrl;
|
|
35
37
|
};
|
|
36
38
|
// Functions for calcuations
|
|
37
39
|
var vestingTime = function (vestingTerm) {
|
|
@@ -65,7 +67,7 @@ var BondRow = function (_a) {
|
|
|
65
67
|
var _a;
|
|
66
68
|
var discount = (_a = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _a !== void 0 ? _a : 0;
|
|
67
69
|
var vestingDays = vestingTime(bond.vestingTerm).days;
|
|
68
|
-
return parseFloat(((
|
|
70
|
+
return parseFloat(((discount * 365) / vestingDays).toFixed(2));
|
|
69
71
|
};
|
|
70
72
|
return (_jsxs(Flex, { className: "bonds-container bondrow-container", onClick: function () { return rowClick(bond); }, children: [_jsxs(Flex, { className: "column column-tokens", children: [_jsx(Flex, { className: "column column-tokeninfoname", children: _jsx(TokenInfoAndName, { bill: bond }) }), _jsx(Flex, { className: "column column-tokenicons", children: _jsx(TooltipBubble, { className: "tooltip-bubble", body: _jsx(Tooltip, { tokenContract: (bond === null || bond === void 0 ? void 0 : bond.earnToken.address[bond.chainId]) || '', secondURL: getBillContractURL(bond), secondURLTitle: 'View Bond Contract', thirdURL: "https://dashboard.ape.bond/bond/".concat((_b = bond === null || bond === void 0 ? void 0 : bond.billAddress) === null || _b === void 0 ? void 0 : _b.toLowerCase()), thirdURLTitle: 'View Insights', twitter: bond === null || bond === void 0 ? void 0 : bond.twitter, projectLink: bond === null || bond === void 0 ? void 0 : bond.projectLink, audit: bond === null || bond === void 0 ? void 0 : bond.audit, chain: (_c = bond.chainId) !== null && _c !== void 0 ? _c : ChainId.BSC }), width: "205px", placement: "bottomRight", transformTip: "translate(11%, 0%)", children: _jsx(Svg, { icon: "more", width: "20px" }) }) })] }), _jsxs(Flex, { className: "column column-bondinfo", children: [_jsx(Flex, { className: "column column-discount ".concat(getDiscountColor(bond === null || bond === void 0 ? void 0 : bond.discount)), children: (bond === null || bond === void 0 ? void 0 : bond.discount) !== undefined ? "".concat(bond.discount.toFixed(2), "%") : '-' }), _jsx(Flex, { className: "column column-arr", children: calculateARR(bond) !== undefined ? "".concat(calculateARR(bond), "%") : '-' }), _jsx(Flex, { className: "column column-terms", children: vestingTime(bond.vestingTerm).days ? "".concat(vestingTime(bond.vestingTerm).days, " D") : '-' }), _jsx(Flex, { className: "column column-tokensremaining", children: _jsx(ProgressBarWrapper, { title: '', value: _jsx(ProgressBar, { value: remainingPercentage(bond) }), style: {
|
|
71
73
|
width: '127px',
|
package/dist/scss/BondModal.scss
CHANGED
|
@@ -310,9 +310,9 @@ var BondModal = function (_a) {
|
|
|
310
310
|
toNumber(inputValue) / toNumber(earnTokenPrice(bond))).toFixed(2), _jsx("span", { className: "text-highlight", children: "\u00A0additional" })] }), _jsx(Flex, { className: "button-container buy", sx: { justifyContent: 'end' }, children: chainId !== bond.chainId ? (_jsx(Button, { className: "switch-button button-narrow", disabled: isPending || isConfirming || (bond === null || bond === void 0 ? void 0 : bond.soldOut) || !account, onClick: function (event) {
|
|
311
311
|
event.stopPropagation();
|
|
312
312
|
switchChain({ chainId: bond.chainId });
|
|
313
|
-
}, children: !account ? 'Connect Wallet' : "Switch to ".concat(NETWORK_LABEL[bond.chainId]) })) : approveTx != null && isConfirmed ? (_jsx(Button, { className: "action-button button-narrow", disabled: isPending || isConfirming || (bond === null || bond === void 0 ? void 0 : bond.soldOut) || !account, onClick: handleBuy, children: getActionButtonText(bond) })) : (_jsx(Button, { className: "action-button button-narrow", disabled: isPending || isConfirming || (bond === null || bond === void 0 ? void 0 : bond.soldOut) || !account, onClick: handleApprove, children: getActionButtonText(bond) })) })] }), _jsx(Flex, { sx: { width: '100%', marginTop: '10px', marginBottom: '10px' }, children: _jsx("hr", { className: "fading-hr" }) }), _jsxs(Flex, { sx: { width: '100%' }, children: [_jsxs(Flex, { sx: { width: '50%', flexDirection: 'column' }, children: ["Market Price: $", formatUSDNumber((toNumber(youGet(bond, inputValue)) * toNumber(earnTokenPrice(bond))).toString()), _jsx("hr", { className: "fading-hr" }), _jsx("span", { className: "text-highlight flex-inline", children: "Our price: " }), _jsxs("span", { className: "flex-inline", children: ["$", formatUSDNumber((toNumber(inputValue) * toNumber(bond.principalTokenPrice)).toString()), ' '] }), _jsxs("span", { className: "text-highlight flex-inline", children: ["(discount rate ", bond === null || bond === void 0 ? void 0 : bond.discount.toFixed(2), "%)"] })] }), _jsx(Flex, { sx: { width: '50px', alignItems: 'center', justifyContent: 'center' }, children: "vs." }), _jsxs(Flex, { sx: { width: '50%', flexDirection: 'column' }, children: ["If purchased from market: ", (toNumber(inputValue) / toNumber(earnTokenPrice(bond))).toFixed(0), ' ', bond.earnToken.symbol, _jsx("hr", { className: "fading-hr" }), _jsx("span", { className: "text-highlight flex-inline", children: "Amount you will get:" }), ' ', youGet(bond, inputValue),
|
|
313
|
+
}, children: !account ? 'Connect Wallet' : "Switch to ".concat(NETWORK_LABEL[bond.chainId]) })) : approveTx != null && isConfirmed ? (_jsx(Button, { className: "action-button button-narrow", disabled: isPending || isConfirming || (bond === null || bond === void 0 ? void 0 : bond.soldOut) || !account, onClick: handleBuy, children: getActionButtonText(bond) })) : (_jsx(Button, { className: "action-button button-narrow", disabled: isPending || isConfirming || (bond === null || bond === void 0 ? void 0 : bond.soldOut) || !account, onClick: handleApprove, children: getActionButtonText(bond) })) })] }), _jsx(Flex, { sx: { width: '100%', marginTop: '10px', marginBottom: '10px' }, children: _jsx("hr", { className: "fading-hr" }) }), _jsxs(Flex, { sx: { width: '100%' }, children: [_jsxs(Flex, { sx: { width: '50%', flexDirection: 'column' }, children: ["Market Price: $", formatUSDNumber((toNumber(youGet(bond, inputValue)) * toNumber(earnTokenPrice(bond))).toString()), _jsx("hr", { className: "fading-hr" }), _jsx("span", { className: "text-highlight flex-inline", children: "Our price: " }), _jsxs("span", { className: "flex-inline", children: ["$", formatUSDNumber((toNumber(inputValue) * toNumber(bond.principalTokenPrice)).toString()), ' '] }), _jsxs("span", { className: "text-highlight flex-inline", children: ["(discount rate ", bond === null || bond === void 0 ? void 0 : bond.discount.toFixed(2), "%)"] })] }), _jsx(Flex, { sx: { width: '50px', alignItems: 'center', justifyContent: 'center' }, children: "vs." }), _jsxs(Flex, { sx: { width: '50%', flexDirection: 'column' }, children: ["If purchased from market: ", (toNumber(inputValue) / toNumber(earnTokenPrice(bond))).toFixed(0), ' ', bond.earnToken.symbol, _jsx("hr", { className: "fading-hr" }), _jsx("span", { className: "text-highlight flex-inline", children: "Amount you will get:" }), ' ', inputValue ? toNumber(youGet(bond, inputValue)).toFixed(2) : 0, ' ', _jsx("span", { className: "flex-inline", children: bond.earnToken.symbol })] })] })] })] })] }), _jsxs(Flex, { className: "footer-details", children: [_jsxs(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: [_jsx("strong", { children: "Vesting start date:" }), "\u00A0", moment().format('DD-MMM-YYYY')] }), _jsxs(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: [_jsx("strong", { children: "Vesting end date:" }), "\u00A0", moment()
|
|
314
314
|
.add(vestingTime((_u = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _u !== void 0 ? _u : 0).days, 'days')
|
|
315
|
-
.format('DD-MMM-YYYY')] }),
|
|
315
|
+
.format('DD-MMM-YYYY')] }), _jsxs(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: [_jsx("strong", { children: "Vesting type:" }), "\u00A0Linear"] }), _jsxs(Flex, { sx: { width: '25%', justifyContent: 'center' }, className: "text-highlight", children: ["What are bonds?", _jsx("i", { className: "fa-solid fa-angle-down" })] })] }), accordionVisible && (_jsx(Flex, { className: "modaltable-container accordion-container", children: _jsx(AccordionText, { title: accordionTitle, body: accordionBody, isVisible: accordionVisible }) }))] }) })) }, bond.billAddress));
|
|
316
316
|
}) }));
|
|
317
317
|
};
|
|
318
318
|
export default BondModal;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BondsDataResponse } from
|
|
1
|
+
import { BondsDataResponse } from '../../types/bonds';
|
|
2
2
|
declare function formatNumber(input: string): string;
|
|
3
3
|
declare function formatUSDNumber(input: string): string;
|
|
4
4
|
declare const youSpend: (inputValue: string) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import BigNumber from
|
|
2
|
-
import { formatNumberSI } from
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { formatNumberSI } from '../../utils/formatNumber';
|
|
3
3
|
function formatNumber(input) {
|
|
4
4
|
var number = new BigNumber(input);
|
|
5
5
|
if (number.isNaN())
|
|
@@ -35,7 +35,7 @@ var youGet = function (bond, inputValue) {
|
|
|
35
35
|
var _a;
|
|
36
36
|
var bigValue = new BigNumber(inputValue).times(new BigNumber(10).pow(18));
|
|
37
37
|
var billValue = bigValue.div(new BigNumber((_a = bond.trueBillPrice) !== null && _a !== void 0 ? _a : 0));
|
|
38
|
-
return
|
|
38
|
+
return billValue.toString();
|
|
39
39
|
};
|
|
40
40
|
var youGetUSD = function (bond, inputValue) {
|
|
41
41
|
var _a;
|