@ape.swap/bonds-sdk 1.0.385 → 1.0.387
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.
|
@@ -45,6 +45,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
48
57
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
49
58
|
/** @jsxImportSource theme-ui */
|
|
50
59
|
import { useCallback, useEffect, useState } from 'react';
|
|
@@ -142,7 +151,7 @@ var Bonds = function (_a) {
|
|
|
142
151
|
return true;
|
|
143
152
|
return ((_b = new BigNumber(bond.tokensRemaining)) === null || _b === void 0 ? void 0 : _b.lte(thresholdToHide)) || bond.discount === 100;
|
|
144
153
|
}, []);
|
|
145
|
-
var
|
|
154
|
+
var sortedHotBonds = bondData.sort(function (a, b) {
|
|
146
155
|
var _a, _b;
|
|
147
156
|
var aIsHot = hotBonds.includes(a.billAddress.toLowerCase()) && ((_a = a.discount) !== null && _a !== void 0 ? _a : 0) > 0;
|
|
148
157
|
var bIsHot = hotBonds.includes(b.billAddress.toLowerCase()) && ((_b = b.discount) !== null && _b !== void 0 ? _b : 0) > 0;
|
|
@@ -187,7 +196,43 @@ var Bonds = function (_a) {
|
|
|
187
196
|
var explorerLink = BLOCK_EXPLORER[selectedChain];
|
|
188
197
|
return "".concat(explorerLink, "/address/").concat(bond === null || bond === void 0 ? void 0 : bond.billAddress);
|
|
189
198
|
};
|
|
190
|
-
|
|
199
|
+
var calculateARR = function (bond) {
|
|
200
|
+
var _a;
|
|
201
|
+
var discount = (_a = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _a !== void 0 ? _a : 0;
|
|
202
|
+
var vestingDays = vestingTime(bond.vestingTerm).days;
|
|
203
|
+
return parseFloat((((discount * 365) / vestingDays).toFixed(2)));
|
|
204
|
+
};
|
|
205
|
+
var _h = useState({ key: 'discount', direction: 'asc' }), sortConfig = _h[0], setSortConfig = _h[1];
|
|
206
|
+
var _j = useState(bondData), sortedBonds = _j[0], setSortedBonds = _j[1];
|
|
207
|
+
var handleSort = function (key) {
|
|
208
|
+
var direction = 'asc';
|
|
209
|
+
if (sortConfig.key === key && sortConfig.direction === 'asc') {
|
|
210
|
+
direction = 'desc';
|
|
211
|
+
}
|
|
212
|
+
setSortConfig({ key: key, direction: direction });
|
|
213
|
+
};
|
|
214
|
+
useEffect(function () {
|
|
215
|
+
var sorted = __spreadArray([], bondData, true).sort(function (a, b) {
|
|
216
|
+
var aValue, bValue;
|
|
217
|
+
if (sortConfig.key === 'ARR') {
|
|
218
|
+
aValue = calculateARR(a);
|
|
219
|
+
bValue = calculateARR(b);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
aValue = a[sortConfig.key];
|
|
223
|
+
bValue = b[sortConfig.key];
|
|
224
|
+
}
|
|
225
|
+
if (aValue < bValue) {
|
|
226
|
+
return sortConfig.direction === 'asc' ? -1 : 1;
|
|
227
|
+
}
|
|
228
|
+
if (aValue > bValue) {
|
|
229
|
+
return sortConfig.direction === 'asc' ? 1 : -1;
|
|
230
|
+
}
|
|
231
|
+
return 0;
|
|
232
|
+
});
|
|
233
|
+
setSortedBonds(sorted);
|
|
234
|
+
}, [sortConfig, sortedHotBonds]);
|
|
235
|
+
return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && _jsx("p", { children: account }), isActive && account && _jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" })), _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-tokeninfoname" }, { children: "Tokens" })), _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('vestingTerm'); } }, { 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" })] }))] })), sortedBonds.map(function (bond) {
|
|
191
236
|
var _a, _b, _c, _d, _e;
|
|
192
237
|
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: "".concat((_c = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _c === void 0 ? void 0 : _c.toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-arr" }, { children: "".concat(((((_d = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _d !== void 0 ? _d : 0) * 365) / vestingTime(bond.vestingTerm).days).toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-term" }, { 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: {
|
|
193
238
|
width: '127px',
|
package/dist/scss/Bonds.scss
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
flex-direction: row;
|
|
78
78
|
align-items: center;
|
|
79
79
|
justify-content: end;
|
|
80
|
-
width:
|
|
80
|
+
width: 70%;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
.column.column-discount {
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
width: 20%;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
.column.column-
|
|
107
|
+
.column.column-terms {
|
|
108
108
|
flex-direction: row;
|
|
109
109
|
justify-content: center;
|
|
110
110
|
align-items: center;
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
.column.column-hotbond {
|
|
122
|
-
flex-direction:
|
|
122
|
+
flex-direction: row;
|
|
123
123
|
justify-content: center;
|
|
124
124
|
align-items: center;
|
|
125
125
|
width: 10%;
|