@ape.swap/bonds-sdk 1.0.423 → 1.0.424
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.
|
@@ -123,6 +123,19 @@ var Bonds = function (_a) {
|
|
|
123
123
|
// Fetch data
|
|
124
124
|
var _d = useState([]), bondData = _d[0], setBondData = _d[1];
|
|
125
125
|
var _e = useState([]), hotBonds = _e[0], setHotBonds = _e[1];
|
|
126
|
+
var isSoldOut = useCallback(function (bond) {
|
|
127
|
+
var _a, _b;
|
|
128
|
+
var thresholdToHide = new BigNumber(100).div((_a = bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : 0);
|
|
129
|
+
if (bond.soldOut)
|
|
130
|
+
return true;
|
|
131
|
+
if (bond.discount == null)
|
|
132
|
+
return true;
|
|
133
|
+
if (!bond.tokensRemaining)
|
|
134
|
+
return false;
|
|
135
|
+
if (bond.discount && bond.discount > 25 && bond.chainId === ChainId.BASE /*BASE*/)
|
|
136
|
+
return true;
|
|
137
|
+
return ((_b = new BigNumber(bond.tokensRemaining)) === null || _b === void 0 ? void 0 : _b.lte(thresholdToHide)) || bond.discount === 100;
|
|
138
|
+
}, []);
|
|
126
139
|
useEffect(function () {
|
|
127
140
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
128
141
|
var bonds = response.data.bonds.filter(function (bond) { return !isSoldOut(bond); });
|
|
@@ -137,19 +150,7 @@ var Bonds = function (_a) {
|
|
|
137
150
|
setHotBonds(hotBondAddresses);
|
|
138
151
|
});
|
|
139
152
|
}, []);
|
|
140
|
-
|
|
141
|
-
var _a, _b;
|
|
142
|
-
var thresholdToHide = new BigNumber(100).div((_a = bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : 0);
|
|
143
|
-
if (bond.soldOut)
|
|
144
|
-
return true;
|
|
145
|
-
if (bond.discount == null)
|
|
146
|
-
return true;
|
|
147
|
-
if (!bond.tokensRemaining)
|
|
148
|
-
return false;
|
|
149
|
-
if (bond.discount && bond.discount > 25 && bond.chainId === ChainId.BASE /*BASE*/)
|
|
150
|
-
return true;
|
|
151
|
-
return ((_b = new BigNumber(bond.tokensRemaining)) === null || _b === void 0 ? void 0 : _b.lte(thresholdToHide)) || bond.discount === 100;
|
|
152
|
-
}, []);
|
|
153
|
+
// Sort functions
|
|
153
154
|
var sortedHotBonds = bondData.sort(function (a, b) {
|
|
154
155
|
var _a, _b;
|
|
155
156
|
var aIsHot = hotBonds.includes(a.billAddress.toLowerCase()) && ((_a = a.discount) !== null && _a !== void 0 ? _a : 0) > 0;
|
|
@@ -248,6 +249,7 @@ var Bonds = function (_a) {
|
|
|
248
249
|
var vestingDays = vestingTime(bond.vestingTerm).days;
|
|
249
250
|
return parseFloat((((discount * 365) / vestingDays).toFixed(2)));
|
|
250
251
|
};
|
|
252
|
+
// Search logic
|
|
251
253
|
var _k = useState(''), inputValue = _k[0], setInputValue = _k[1];
|
|
252
254
|
var _l = useState(sortedBonds), filteredBonds = _l[0], setFilteredBonds = _l[1];
|
|
253
255
|
useEffect(function () {
|
|
@@ -263,13 +265,14 @@ var Bonds = function (_a) {
|
|
|
263
265
|
var handleInputChange = function (event) {
|
|
264
266
|
setInputValue(event.target.value);
|
|
265
267
|
};
|
|
268
|
+
// Page render logic
|
|
266
269
|
var _m = useState(false), bondsRendered = _m[0], setBondsRendered = _m[1];
|
|
267
270
|
useEffect(function () {
|
|
268
271
|
if (filteredBonds.length > 0) {
|
|
269
272
|
setBondsRendered(true);
|
|
270
273
|
}
|
|
271
274
|
}, [filteredBonds]);
|
|
272
|
-
return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && _jsx("p", { children: account }), isActive && account && _jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" })), bondsRendered && (_jsxs(Flex, __assign({ className: "container table-container" }, { children: [_jsxs(Flex, __assign({ className: "container header-container" }, { children: [_jsxs(Flex, __assign({ className: "column column-tokens" }, { children: [_jsx(Flex, __assign({ className: "column column-
|
|
275
|
+
return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && _jsx("p", { children: account }), isActive && account && _jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" })), bondsRendered && (_jsxs(Flex, __assign({ className: "container table-container" }, { children: [_jsxs(Flex, __assign({ className: "container header-container" }, { children: [_jsxs(Flex, __assign({ className: "column column-tokens" }, { children: [_jsx(Flex, __assign({ className: "column column-search", sx: { width: '100%', maxWidth: ['200px', '200px', '200px', '340px'] } }, { children: _jsx(Input, { value: inputValue, onChange: handleInputChange, variant: "search", sx: { fontWeight: 400, background: 'white2', height: '30px', fontSize: '14px' }, width: '100%', placeholder: 'Search...' }) })), _jsx(Flex, { className: "column column-tokenicons" })] })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-discount" }, { children: [_jsx(Flex, __assign({ className: "column tooltip" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Discount }), width: "230px", placement: "bottomLeft", transformTip: "translate(18%, -4%)" }, { children: ["Discount", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('discount'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column column-arr" }, { children: [_jsx(Flex, __assign({ className: "column tooltip" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.ARR }), width: "230px", placement: "bottomLeft", transformTip: "translate(8%, -5%)" }, { children: ["ARR", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('arr'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column column-terms" }, { children: [_jsx(Flex, __assign({ className: "column tooltip" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Terms }), width: "230px", placement: "bottomRight", transformTip: "translate(11%, -5%)" }, { children: ["Terms", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('terms'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column column-tokensremaining" }, { children: [_jsx(Flex, __assign({ className: "column tooltip" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.TokensRemaining }), width: "230px", placement: "bottomRight", transformTip: "translate(12%, -4%)" }, { children: ["Tokens Remaining", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('tokensRemaining'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsx(Flex, { className: "column column-hotbond" })] }))] })), filteredBonds.map(function (bond) {
|
|
273
276
|
var _a, _b, _c;
|
|
274
277
|
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bond); } }, { children: [_jsxs(Flex, __assign({ className: "column column-tokens" }, { children: [_jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bill: bond }) })), _jsx(Flex, __assign({ className: "column column-tokenicons" }, { children: _jsx(TooltipBubble, __assign({ body: _jsx(Tooltip, { tokenContract: (bond === null || bond === void 0 ? void 0 : bond.payoutToken) || '', secondURL: getBillContractURL(bond), secondURLTitle: 'View Bond Contract', thirdURL: "https://dashboard.ape.bond/bond/".concat((_a = bond === null || bond === void 0 ? void 0 : bond.billAddress) === null || _a === void 0 ? void 0 : _a.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: (_b = bond.chainId) !== null && _b !== void 0 ? _b : ChainId.BSC }), width: "205px", placement: "bottomRight", transformTip: "translate(11%, 0%)" }, { children: _jsx(Svg, { icon: "more", width: "20px" }) })) }))] })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsx(Flex, __assign({ 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, __assign({ className: "column column-arr" }, { children: calculateARR(bond) !== undefined ? "".concat(calculateARR(bond), "%") : '-' })), _jsx(Flex, __assign({ className: "column column-terms" }, { children: vestingTime(bond.vestingTerm).days ? "".concat(vestingTime(bond.vestingTerm).days, " D") : '-' })), _jsx(Flex, __assign({ className: "column column-tokensremaining" }, { children: _jsx(ProgressBarWrapper, { title: '', value: _jsx(ProgressBar, { value: remainingPercentage(bond) }), style: {
|
|
275
278
|
width: '127px',
|
|
@@ -22,7 +22,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
24
24
|
import { Input as ThemeInput, Spinner } from 'theme-ui';
|
|
25
|
-
import
|
|
25
|
+
import Flex from '../Flex';
|
|
26
|
+
import Svg from '../Svg';
|
|
27
|
+
import Text from '../Text';
|
|
26
28
|
var colorScheme = {
|
|
27
29
|
default: 'gray',
|
|
28
30
|
error: 'red',
|
|
@@ -38,7 +40,7 @@ var Input = function (_a) {
|
|
|
38
40
|
pl: '10px',
|
|
39
41
|
borderRadius: '10px',
|
|
40
42
|
':focus': { outline: 'none' },
|
|
41
|
-
} })), _jsx(Flex, __assign({ sx: { position: 'absolute', right: 5, justifyContent: 'center', height: '100%' } }, { children: _jsx(Svg, { icon: "search" }) }))] })));
|
|
43
|
+
} })), _jsx(Flex, __assign({ sx: { position: 'absolute', right: 5, justifyContent: 'center', height: '100%' } }, { children: _jsx(Svg, { icon: "search", color: "grey" }) }))] })));
|
|
42
44
|
case 'password':
|
|
43
45
|
var statusColor = colorScheme[status];
|
|
44
46
|
return (_jsxs(Flex, __assign({ sx: {
|