@ape.swap/bonds-sdk 1.0.109 → 1.0.110
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.
|
@@ -21,6 +21,7 @@ import { Button } from '../uikit/Button';
|
|
|
21
21
|
import Svg from '../uikit/Svg';
|
|
22
22
|
import axios from 'axios';
|
|
23
23
|
import { BigNumber } from 'bignumber.js';
|
|
24
|
+
import { getFirstNonZeroDigits } from '../../utils/roundNumber';
|
|
24
25
|
var BondModal = function (_a) {
|
|
25
26
|
var isOpen = _a.isOpen, onClose = _a.onClose, bondAddress = _a.bondAddress;
|
|
26
27
|
if (!isOpen)
|
|
@@ -42,7 +43,11 @@ var BondModal = function (_a) {
|
|
|
42
43
|
var discountEarnTokenPrice = function (bond) {
|
|
43
44
|
var _a, _b;
|
|
44
45
|
var earnTokenPrice = parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0');
|
|
45
|
-
return earnTokenPrice - earnTokenPrice * (((_b = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _b !== void 0 ? _b : 0) / 100);
|
|
46
|
+
return getFirstNonZeroDigits(earnTokenPrice - earnTokenPrice * (((_b = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _b !== void 0 ? _b : 0) / 100));
|
|
47
|
+
};
|
|
48
|
+
var earnTokenPrice = function (bond) {
|
|
49
|
+
var _a;
|
|
50
|
+
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
46
51
|
};
|
|
47
52
|
var maxBuy = function (bond) {
|
|
48
53
|
var _a, _b, _c, _d;
|
|
@@ -54,8 +59,8 @@ var BondModal = function (_a) {
|
|
|
54
59
|
return !available ? 0 : (singlePurchaseLimit.lt(safeAvailable) ? singlePurchaseLimit : safeAvailable);
|
|
55
60
|
};
|
|
56
61
|
return (_jsx(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: bondData.map(function (bond) {
|
|
57
|
-
var _a, _b, _c, _d, _e, _f
|
|
58
|
-
return (_jsx(React.Fragment, { children: _jsx(Flex, __assign({ className: "modal modal-backdrop" }, { children: _jsxs(Flex, __assign({ className: "modal modal-content" }, { children: [isActive && account && (_jsxs("p", { children: ["Wallet Address: ", account] })), _jsxs(Flex, __assign({ className: "modal modal-header" }, { children: [_jsx(Flex, __assign({ className: "new" }, { children: "NEW" })), _jsxs(Flex, __assign({ className: "project-info" }, { children: ["Project Info", _jsx(Flex, __assign({ className: "project-info icon" }, { children: _jsx(Svg, { icon: "expand" }) }))] })), _jsx(Flex, __assign({ className: "svg-close", onClick: onClose }, { children: _jsx(Svg, { icon: "close" }) }))] })), _jsxs(Flex, __assign({ className: "modal-container table-container" }, { children: [_jsxs(Flex, __assign({ className: "modal-container title-container" }, { children: [_jsx(Flex, __assign({ className: "title-container bond" }, { children: bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName })), _jsxs(Flex, __assign({ className: "title-container bond-price" }, { children: [_jsxs(Flex, __assign({ className: "bond-price price" }, { children: ["$", (
|
|
62
|
+
var _a, _b, _c, _d, _e, _f;
|
|
63
|
+
return (_jsx(React.Fragment, { children: _jsx(Flex, __assign({ className: "modal modal-backdrop" }, { children: _jsxs(Flex, __assign({ className: "modal modal-content" }, { children: [isActive && account && (_jsxs("p", { children: ["Wallet Address: ", account] })), _jsxs(Flex, __assign({ className: "modal modal-header" }, { children: [_jsx(Flex, __assign({ className: "new" }, { children: "NEW" })), _jsxs(Flex, __assign({ className: "project-info" }, { children: ["Project Info", _jsx(Flex, __assign({ className: "project-info icon" }, { children: _jsx(Svg, { icon: "expand" }) }))] })), _jsx(Flex, __assign({ className: "svg-close", onClick: onClose }, { children: _jsx(Svg, { icon: "close" }) }))] })), _jsxs(Flex, __assign({ className: "modal-container table-container" }, { children: [_jsxs(Flex, __assign({ className: "modal-container title-container" }, { children: [_jsx(Flex, __assign({ className: "title-container bond" }, { children: bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName })), _jsxs(Flex, __assign({ className: "title-container bond-price" }, { children: [_jsxs(Flex, __assign({ className: "bond-price price" }, { children: ["$", earnTokenPrice(bond)] })), _jsxs(Flex, __assign({ className: "bond-price discounted" }, { children: ["$", discountEarnTokenPrice(bond)] }))] }))] })), _jsx(Flex, __assign({ className: "modal-container description-container" }, { children: bond === null || bond === void 0 ? void 0 : bond.shortDescription })), _jsxs(Flex, __assign({ className: "modal-container blocks-container" }, { children: [_jsxs(Flex, __assign({ className: "modal-block column-discount ".concat(getDiscountColor(bond === null || bond === void 0 ? void 0 : bond.discount)) }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Discount", _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionFill", width: "15px" }) }))] })), "".concat((_a = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _a === void 0 ? void 0 : _a.toFixed(2), "%")] })), _jsxs(Flex, __assign({ className: "modal-block column-arr" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["ARR", _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionFill", width: "15px" }) }))] })), "".concat(((((_b = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _b !== void 0 ? _b : 0) * 365) / vestingTime((_c = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _c !== void 0 ? _c : 0).days).toFixed(2), "%")] })), _jsxs(Flex, __assign({ className: "modal-block column-term" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Terms", _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionFill", width: "15px" }) }))] })), vestingTime((_d = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _d !== void 0 ? _d : 0).days ? "".concat(vestingTime((_e = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _e !== void 0 ? _e : 0).days, " D") : '-'] })), _jsxs(Flex, __assign({ className: "modal-block column-maxbuy" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Max Buy", _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionFill", width: "15px" }) }))] })), (_f = parseFloat(maxBuy(bond).toFixed(0))) === null || _f === void 0 ? void 0 : _f.toLocaleString('en-US')] }))] })), _jsxs(Flex, __assign({ className: "modal-container text-container" }, { children: [_jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsx("div", { children: "You spend:" }), _jsxs("div", { children: ["0 ", bond === null || bond === void 0 ? void 0 : bond.principalTokenName, " = $ 0"] })] })), _jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsxs("div", { children: ["Premium: ", _jsx(Svg, { icon: "questionFill", width: "15px" })] }), _jsx("div", { children: "$ 0" })] })), _jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsx("div", { children: "You get (over 90 days):" }), _jsxs("div", { children: ["0 ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName, " = $ 0"] })] }))] })), _jsxs(Flex, __assign({ className: "modal-container input-container" }, { children: [_jsx(Flex, __assign({ className: "input-container input" }, { children: _jsx(Input, { type: "number", className: "number-input", placeholder: "0.0" }) })), _jsx(Flex, __assign({ className: "input-container token" }, { children: bond === null || bond === void 0 ? void 0 : bond.principalTokenName }))] })), _jsxs(Flex, __assign({ className: "modal-container button-container" }, { children: [_jsx(Flex, __assign({ className: "button-container get" }, { children: _jsxs(Button, { children: ["Get ", bond === null || bond === void 0 ? void 0 : bond.principalTokenName] }) })), _jsx(Flex, __assign({ className: "button-container buy" }, { children: _jsxs(Button, { children: ["Buy ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName] }) }))] }))] }))] })) })) }, bond.billAddress));
|
|
59
64
|
}) })));
|
|
60
65
|
};
|
|
61
66
|
export default BondModal;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rounds a number to precision amount of signifant numbers
|
|
3
|
+
* @param n the number
|
|
4
|
+
* @param precision how many significant numbers to show
|
|
5
|
+
* @returns @number
|
|
6
|
+
*/
|
|
7
|
+
export declare const getFirstNonZeroDigits: (numberToParse: number, precision?: number) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rounds a number to precision amount of signifant numbers
|
|
3
|
+
* @param n the number
|
|
4
|
+
* @param precision how many significant numbers to show
|
|
5
|
+
* @returns @number
|
|
6
|
+
*/
|
|
7
|
+
export var getFirstNonZeroDigits = function (numberToParse, precision) {
|
|
8
|
+
if (precision === void 0) { precision = 3; }
|
|
9
|
+
var n = parseFloat(numberToParse.toFixed(18));
|
|
10
|
+
var amountToShow = precision - 1;
|
|
11
|
+
if (n !== 0)
|
|
12
|
+
amountToShow -= Math.floor(Math.log(n) / Math.log(10));
|
|
13
|
+
return n.toFixed(amountToShow < 0 ? 0 : amountToShow);
|
|
14
|
+
};
|