@ape.swap/bonds-sdk 1.0.392 → 1.0.394
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/BondModal/BondModal.js +2 -2
- package/dist/components/BondModal/helper.d.ts +8 -8
- package/dist/components/BondModal/helper.js +9 -8
- package/dist/components/YourBonds/YourBonds.js +76 -22
- package/dist/{types → hooks/PriceGetter}/dexFactories.d.ts +1 -1
- package/dist/hooks/PriceGetter/usePricesFromPriceGetter.js +1 -1
- package/package.json +1 -1
- /package/dist/{types → hooks/PriceGetter}/dexFactories.js +0 -0
|
@@ -65,8 +65,8 @@ import TokenImage from '../uikit-sdk/TokenImage';
|
|
|
65
65
|
import '../../scss/BondModal.scss';
|
|
66
66
|
import BOND_ABI from '../../config/abi/bond.json';
|
|
67
67
|
import ERC_20_ABI from '../../config/abi/bond.json';
|
|
68
|
-
import { formatUSDNumber, getPremiumColor, premium, youGet, youGetUSD, youSpend, youSpendUSD } from './helper';
|
|
69
68
|
import { NETWORK_ICONS } from '../../config/constants/chains';
|
|
69
|
+
import { formatUSDNumber, getPremiumColor, premium, youGet, youSpend, youSpendUSD } from './helper';
|
|
70
70
|
var BondModal = function (_a) {
|
|
71
71
|
var isOpen = _a.isOpen, onClose = _a.onClose, bondAddress = _a.bondAddress;
|
|
72
72
|
if (!isOpen)
|
|
@@ -194,7 +194,7 @@ var BondModal = function (_a) {
|
|
|
194
194
|
}); };
|
|
195
195
|
return (_jsx(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: bondData.map(function (bond) {
|
|
196
196
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
197
|
-
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] })), _jsx(Flex, __assign({ className: "modal modal-header" }, { children: _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 bondicon" }, { children: _jsxs("div", __assign({ className: "icon-container" }, { children: [_jsx(Svg, { width: 20, height: 20, icon: (_a = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[bond.chainId]) !== null && _a !== void 0 ? _a : 'question' }), _jsx(TokenImage, { symbol: (_b = bond.showcaseTokenName) !== null && _b !== void 0 ? _b : bond.payoutTokenName, size: 50 })] })) })), _jsx(Flex, __assign({ className: "title-container bondname" }, { children: bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName })), _jsxs(Flex, __assign({ className: "title-container price-container" }, { children: [_jsxs(Flex, __assign({ className: "price-container price" }, { children: ["$", earnTokenPrice(bond)] })), _jsxs(Flex, __assign({ className: "price-container discounted" }, { children: ["$", discountEarnTokenPrice(bond)] }))] })), _jsx(Flex, __assign({ className: "title-container tokentags" }, { children: _jsx(ListTag, { text: (_c = bond === null || bond === void 0 ? void 0 : bond.tags) === null || _c === void 0 ? void 0 : _c[0], variant: ((_d = bond === null || bond === void 0 ? void 0 : bond.tags) === null || _d === void 0 ? void 0 : _d[0]) === 'Cex Fund' ? 'cex_fund' : 'liquidity' }) }))] })), _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(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Discount }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), "".concat((_e = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _e === void 0 ? void 0 : _e.toFixed(2), "%")] })), _jsxs(Flex, __assign({ className: "modal-block column-arr" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["ARR", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.ARR }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), "".concat(((((_f = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _f !== void 0 ? _f : 0) * 365) / vestingTime((_g = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _g !== void 0 ? _g : 0).days).toFixed(2), "%")] })), _jsxs(Flex, __assign({ className: "modal-block column-term" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Terms", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Terms }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), vestingTime((_h = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _h !== void 0 ? _h : 0).days ? "".concat(vestingTime((_j = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _j !== void 0 ? _j : 0).days, " D") : '-'] })), _jsxs(Flex, __assign({ className: "modal-block column-maxbuy" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Max Buy", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.MaxBuy(bond.payoutTokenName) }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), (_k = parseFloat(maxBuy(bond).toFixed(0))) === null || _k === void 0 ? void 0 : _k.toLocaleString('en-US')] }))] })), _jsxs(Flex, __assign({ className: "modal-container text-container" }, { children: [_jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsx(Flex, __assign({ className: "row-container spend" }, { children: "You spend:" })), _jsxs(Flex, __assign({ className: "row-container spend-val" }, { children: [youSpend(inputValue), " ", bond.principalTokenName, " = $ ", formatUSDNumber(youSpendUSD(bond, inputValue))] }))] })), _jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsxs(Flex, __assign({ className: "row-container premium" }, { children: ["Premium:", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Premium }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "row-container premium-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), _jsxs(Flex, __assign({ className: "row-container premium-val ".concat(getPremiumColor(bond, inputValue)) }, { children: ["$ ", premium(bond, inputValue)] }))] })), _jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsxs(Flex, __assign({ className: "row-container get" }, { children: ["You get (over ", vestingTime((_l = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _l !== void 0 ? _l : 0).days, " days):"] })), _jsxs(Flex, __assign({ className: "row-container get-val" }, { children: [youGet(bond, inputValue), " ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName, " = $ ", formatUSDNumber(
|
|
197
|
+
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] })), _jsx(Flex, __assign({ className: "modal modal-header" }, { children: _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 bondicon" }, { children: _jsxs("div", __assign({ className: "icon-container" }, { children: [_jsx(Svg, { width: 20, height: 20, icon: (_a = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[bond.chainId]) !== null && _a !== void 0 ? _a : 'question' }), _jsx(TokenImage, { symbol: (_b = bond.showcaseTokenName) !== null && _b !== void 0 ? _b : bond.payoutTokenName, size: 50 })] })) })), _jsx(Flex, __assign({ className: "title-container bondname" }, { children: bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName })), _jsxs(Flex, __assign({ className: "title-container price-container" }, { children: [_jsxs(Flex, __assign({ className: "price-container price" }, { children: ["$", earnTokenPrice(bond)] })), _jsxs(Flex, __assign({ className: "price-container discounted" }, { children: ["$", discountEarnTokenPrice(bond)] }))] })), _jsx(Flex, __assign({ className: "title-container tokentags" }, { children: _jsx(ListTag, { text: (_c = bond === null || bond === void 0 ? void 0 : bond.tags) === null || _c === void 0 ? void 0 : _c[0], variant: ((_d = bond === null || bond === void 0 ? void 0 : bond.tags) === null || _d === void 0 ? void 0 : _d[0]) === 'Cex Fund' ? 'cex_fund' : 'liquidity' }) }))] })), _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(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Discount }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), "".concat((_e = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _e === void 0 ? void 0 : _e.toFixed(2), "%")] })), _jsxs(Flex, __assign({ className: "modal-block column-arr" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["ARR", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.ARR }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), "".concat(((((_f = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _f !== void 0 ? _f : 0) * 365) / vestingTime((_g = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _g !== void 0 ? _g : 0).days).toFixed(2), "%")] })), _jsxs(Flex, __assign({ className: "modal-block column-term" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Terms", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Terms }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), vestingTime((_h = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _h !== void 0 ? _h : 0).days ? "".concat(vestingTime((_j = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _j !== void 0 ? _j : 0).days, " D") : '-'] })), _jsxs(Flex, __assign({ className: "modal-block column-maxbuy" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Max Buy", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.MaxBuy(bond.payoutTokenName) }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), (_k = parseFloat(maxBuy(bond).toFixed(0))) === null || _k === void 0 ? void 0 : _k.toLocaleString('en-US')] }))] })), _jsxs(Flex, __assign({ className: "modal-container text-container" }, { children: [_jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsx(Flex, __assign({ className: "row-container spend" }, { children: "You spend:" })), _jsxs(Flex, __assign({ className: "row-container spend-val" }, { children: [youSpend(inputValue), " ", bond.principalTokenName, " = $ ", formatUSDNumber(youSpendUSD(bond, inputValue))] }))] })), _jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsxs(Flex, __assign({ className: "row-container premium" }, { children: ["Premium:", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Premium }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "row-container premium-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), _jsxs(Flex, __assign({ className: "row-container premium-val ".concat(getPremiumColor(bond, inputValue)) }, { children: ["$ ", premium(bond, inputValue)] }))] })), _jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsxs(Flex, __assign({ className: "row-container get" }, { children: ["You get (over ", vestingTime((_l = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _l !== void 0 ? _l : 0).days, " days):"] })), _jsxs(Flex, __assign({ className: "row-container get-val" }, { children: [youGet(bond, inputValue), " ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName, " = $ ", formatUSDNumber(youGet(bond, inputValue))] }))] }))] })), _jsxs(Flex, __assign({ className: "modal-container input-container" }, { children: [_jsxs(Flex, __assign({ className: "input-container inputrow" }, { children: [_jsx(Flex, __assign({ className: "input-container input" }, { children: _jsx(Input, { placeholder: "0.0", value: inputValue, pattern: "^[0-9]*[.,]?[0-9]*$", onChange: handleInputChange, onInput: function (v) {
|
|
198
198
|
if (v.currentTarget.value.includes(',')) {
|
|
199
199
|
v.currentTarget.value = v.currentTarget.value.replace(/,/g, '.');
|
|
200
200
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BondsDataResponse } from "../../types/bonds";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
2
|
+
declare function formatNumber(input: string): string;
|
|
3
|
+
declare function formatUSDNumber(input: string): string;
|
|
4
|
+
declare const youSpend: (inputValue: string) => string;
|
|
5
|
+
declare const youSpendUSD: (bond: BondsDataResponse, inputValue: string) => string;
|
|
6
|
+
declare const youGet: (bond: BondsDataResponse, inputValue: string) => string;
|
|
7
|
+
declare const premium: (bond: BondsDataResponse, inputValue: string) => string;
|
|
8
|
+
declare const getPremiumColor: (bond: BondsDataResponse, inputValue: string) => string;
|
|
9
|
+
export { formatNumber, formatUSDNumber, youSpend, youSpendUSD, youGet, premium, getPremiumColor };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
2
|
import { formatNumberSI } from "../../utils/formatNumber";
|
|
3
|
-
|
|
3
|
+
function formatNumber(input) {
|
|
4
4
|
var number = new BigNumber(input);
|
|
5
5
|
if (number.isNaN())
|
|
6
6
|
return '0';
|
|
@@ -12,7 +12,7 @@ export function formatNumber(input) {
|
|
|
12
12
|
? parseFloat(number.toFixed(2)).toLocaleString(undefined)
|
|
13
13
|
: parseFloat(number.toPrecision(5)).toLocaleString(undefined);
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
function formatUSDNumber(input) {
|
|
16
16
|
var number = new BigNumber(input);
|
|
17
17
|
if (number.isNaN())
|
|
18
18
|
return '0';
|
|
@@ -27,27 +27,28 @@ export function formatUSDNumber(input) {
|
|
|
27
27
|
// Note: Between 1k and 0.01 show 2 decimals
|
|
28
28
|
return parseFloat(number.toFixed(2)).toLocaleString(undefined);
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
var youSpend = function (inputValue) { return formatNumber(inputValue); };
|
|
31
|
+
var youSpendUSD = function (bond, inputValue) {
|
|
32
32
|
return (parseFloat(inputValue) * parseFloat(bond.principalTokenPrice)).toString();
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
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
38
|
return formatNumber(billValue.toString());
|
|
39
39
|
};
|
|
40
|
-
|
|
40
|
+
var youGetUSD = function (bond, inputValue) {
|
|
41
41
|
var _a;
|
|
42
42
|
var bigValue = new BigNumber(inputValue).times(new BigNumber(10).pow(18));
|
|
43
43
|
var billValue = bigValue.div(new BigNumber((_a = bond.trueBillPrice) !== null && _a !== void 0 ? _a : 0));
|
|
44
44
|
return (billValue.toNumber() * parseFloat(bond.payoutTokenPrice)).toString();
|
|
45
45
|
};
|
|
46
|
-
|
|
46
|
+
var premium = function (bond, inputValue) {
|
|
47
47
|
var premiumUSD = parseFloat(youGetUSD(bond, inputValue)) - parseFloat(youSpendUSD(bond, inputValue));
|
|
48
48
|
return formatUSDNumber(premiumUSD.toString());
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
var getPremiumColor = function (bond, inputValue) {
|
|
51
51
|
var getPremium = premium(bond, inputValue);
|
|
52
52
|
return parseFloat(getPremium) < 0 ? 'premium-negative' : 'premium-positive';
|
|
53
53
|
};
|
|
54
|
+
export { formatNumber, formatUSDNumber, youSpend, youSpendUSD, youGet, premium, getPremiumColor };
|
|
@@ -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 { useEffect, useState } from 'react';
|
|
@@ -56,7 +65,7 @@ import getTimePeriods from '../../utils/getTimePeriods';
|
|
|
56
65
|
import { defaultTheme } from '../../theme';
|
|
57
66
|
import '../../scss/YourBonds.scss';
|
|
58
67
|
import { BigNumber } from 'bignumber.js';
|
|
59
|
-
import { Text, Button } from '../uikit-sdk';
|
|
68
|
+
import { Text, Button, Svg } from '../uikit-sdk';
|
|
60
69
|
import { MAINNET_CHAINS } from '../../config/constants/chains';
|
|
61
70
|
import TokenInfoAndName from '../TokenInfoAndName';
|
|
62
71
|
import { getBalanceNumber } from '../../utils/getBalanceNumber';
|
|
@@ -113,8 +122,9 @@ var YourBonds = function (_a) {
|
|
|
113
122
|
// Fetch data for user owned bill
|
|
114
123
|
var _d = useState([]), bondData = _d[0], setBondData = _d[1];
|
|
115
124
|
var _e = useState([]), userOwnedBillsData = _e[0], setUserOwnedBillsData = _e[1];
|
|
116
|
-
var _f = useState(
|
|
117
|
-
var _g = useState(
|
|
125
|
+
var _f = useState([]), mappedUserBills = _f[0], setMappedUserBills = _f[1];
|
|
126
|
+
var _g = useState(false), isModalOpen = _g[0], setIsModalOpen = _g[1];
|
|
127
|
+
var _h = useState(null), selectedBill = _h[0], setSelectedBill = _h[1];
|
|
118
128
|
useEffect(function () {
|
|
119
129
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
120
130
|
var bonds = response.data.bonds;
|
|
@@ -145,7 +155,60 @@ var YourBonds = function (_a) {
|
|
|
145
155
|
});
|
|
146
156
|
}); };
|
|
147
157
|
fetchData();
|
|
158
|
+
var mappedBills = userOwnedBillsData.flat().flatMap(function (data) {
|
|
159
|
+
return data.userOwnedBills.map(function (bill) { return bill; });
|
|
160
|
+
});
|
|
161
|
+
setMappedUserBills(mappedBills);
|
|
148
162
|
}, [account]);
|
|
163
|
+
var _j = useState(null), sortConfig = _j[0], setSortConfig = _j[1];
|
|
164
|
+
var _k = useState(mappedUserBills), sortedBonds = _k[0], setSortedBonds = _k[1];
|
|
165
|
+
var handleSort = function (key) {
|
|
166
|
+
var direction = 'asc';
|
|
167
|
+
if ((sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.key) === key && (sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.direction) === 'asc') {
|
|
168
|
+
direction = 'desc';
|
|
169
|
+
}
|
|
170
|
+
setSortConfig({ key: key, direction: direction });
|
|
171
|
+
};
|
|
172
|
+
useEffect(function () {
|
|
173
|
+
if (sortConfig === null) {
|
|
174
|
+
var sortedBills = mappedUserBills.sort(function (a, b) {
|
|
175
|
+
var claimableDifference = parseFloat(claimable(b).toFixed(3)) - parseFloat(claimable(a).toFixed(3));
|
|
176
|
+
if (claimableDifference !== 0) {
|
|
177
|
+
return claimableDifference;
|
|
178
|
+
}
|
|
179
|
+
return 0;
|
|
180
|
+
});
|
|
181
|
+
setSortedBonds(sortedBills);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
var sorted = __spreadArray([], sortedBonds, true).sort(function (a, b) {
|
|
185
|
+
var aValue, bValue;
|
|
186
|
+
if (sortConfig.key === 'claimable') {
|
|
187
|
+
aValue = parseFloat(claimable(a).toFixed(3));
|
|
188
|
+
bValue = parseFloat(claimable(b).toFixed(3));
|
|
189
|
+
}
|
|
190
|
+
else if (sortConfig.key === 'pending') {
|
|
191
|
+
aValue = parseFloat(totalPending(a).toFixed(0));
|
|
192
|
+
bValue = parseFloat(totalPending(b).toFixed(0));
|
|
193
|
+
}
|
|
194
|
+
else if (sortConfig.key === 'terms') {
|
|
195
|
+
aValue = vestingTimeRemaining(a).days;
|
|
196
|
+
bValue = vestingTimeRemaining(b).days;
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
aValue = a[sortConfig.key];
|
|
200
|
+
bValue = b[sortConfig.key];
|
|
201
|
+
}
|
|
202
|
+
if (aValue < bValue) {
|
|
203
|
+
return sortConfig.direction === 'asc' ? -1 : 1;
|
|
204
|
+
}
|
|
205
|
+
if (aValue > bValue) {
|
|
206
|
+
return sortConfig.direction === 'asc' ? 1 : -1;
|
|
207
|
+
}
|
|
208
|
+
return 0;
|
|
209
|
+
});
|
|
210
|
+
setSortedBonds(sorted);
|
|
211
|
+
}, [sortConfig, sortedBonds]);
|
|
149
212
|
var rowClick = function (bill) {
|
|
150
213
|
setSelectedBill(bill);
|
|
151
214
|
setIsModalOpen(true);
|
|
@@ -169,30 +232,21 @@ var YourBonds = function (_a) {
|
|
|
169
232
|
var _a;
|
|
170
233
|
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
171
234
|
};
|
|
172
|
-
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: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, { className: "column column-tokeninfoname" }) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [
|
|
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: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, { className: "column column-tokeninfoname" }) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-claimable" }, { children: [_jsx(Text, { children: "Claimable" }), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('claimable'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [_jsx(Text, { children: "Pending" }), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('pending'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column column-term" }, { children: [_jsx(Text, { children: "Terms" }), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('terms'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
|
|
173
236
|
height: ['36px', '36px', '36px', '26px'],
|
|
174
237
|
lineHeight: '12px',
|
|
175
238
|
fontSize: '14px',
|
|
176
239
|
fontWeight: 600,
|
|
177
240
|
width: '100%',
|
|
178
|
-
} }, { children: "Claim All" })) }))] }))] })),
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
var _a, _b;
|
|
188
|
-
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bill: bill.bond, vestEnds: "Ends in ".concat(getPendingVesting(bill.lastBlockTimestamp, bill.vesting)) }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-claimable" }, { children: [formatNumberSI(parseFloat(claimable(bill).toFixed(3)), 0), "($".concat((claimable(bill) * ((_a = parseFloat(earnTokenPrice(bill.bond))) !== null && _a !== void 0 ? _a : 0)).toFixed(2), ")")] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [formatNumberSI(parseFloat(totalPending(bill).toFixed(0)), 0), "($".concat((totalPending(bill) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")")] })), _jsx(Flex, __assign({ className: "column column-term" }, { children: "".concat(vestingTimeRemaining(bill).days, "d, ").concat(vestingTimeRemaining(bill).hours, "h, ").concat(vestingTimeRemaining(bill).minutes, "m") })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Flex, __assign({ className: "column-claimall button" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
|
|
189
|
-
height: ['36px', '36px', '36px', '26px'],
|
|
190
|
-
lineHeight: '12px',
|
|
191
|
-
fontSize: '14px',
|
|
192
|
-
fontWeight: 600,
|
|
193
|
-
width: '100%',
|
|
194
|
-
} }, { children: "Claim" })) })) }))] }))] }), bill.bond.billAddress));
|
|
195
|
-
});
|
|
241
|
+
} }, { children: "Claim All" })) }))] }))] })), sortedBonds.map(function (bill) {
|
|
242
|
+
var _a, _b;
|
|
243
|
+
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bill: bill.bond, vestEnds: "Ends in ".concat(getPendingVesting(bill.lastBlockTimestamp, bill.vesting)) }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-claimable" }, { children: [formatNumberSI(parseFloat(claimable(bill).toFixed(3)), 0), "($".concat((claimable(bill) * ((_a = parseFloat(earnTokenPrice(bill.bond))) !== null && _a !== void 0 ? _a : 0)).toFixed(2), ")")] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [formatNumberSI(parseFloat(totalPending(bill).toFixed(0)), 0), "($".concat((totalPending(bill) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")")] })), _jsx(Flex, __assign({ className: "column column-term" }, { children: "".concat(vestingTimeRemaining(bill).days, "d, ").concat(vestingTimeRemaining(bill).hours, "h, ").concat(vestingTimeRemaining(bill).minutes, "m") })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Flex, __assign({ className: "column-claimall button" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
|
|
244
|
+
height: ['36px', '36px', '36px', '26px'],
|
|
245
|
+
lineHeight: '12px',
|
|
246
|
+
fontSize: '14px',
|
|
247
|
+
fontWeight: 600,
|
|
248
|
+
width: '100%',
|
|
249
|
+
} }, { children: "Claim" })) })) }))] }))] }), bill.bond.billAddress));
|
|
196
250
|
})] }))] })));
|
|
197
251
|
};
|
|
198
252
|
export default YourBonds;
|
|
@@ -41,7 +41,7 @@ import { PRICE_GETTER_ADDRESSES } from '../../config/constants/addresses';
|
|
|
41
41
|
import PRICE_GETTER_ABI from '../../config/abi/price-getter.json';
|
|
42
42
|
import PRICE_GETTER_ABI_LINEA from '../../config/abi/price-getter-linea.json';
|
|
43
43
|
import { ChainId, Protocols } from '../../enum/apeswaplists';
|
|
44
|
-
import { defaultDexFactories, dexFactories } from '
|
|
44
|
+
import { defaultDexFactories, dexFactories } from './dexFactories';
|
|
45
45
|
export function getTokenPricesV2FromPriceGetter(tokensToCall, chain, lpTokens) {
|
|
46
46
|
if (lpTokens === void 0) { lpTokens = false; }
|
|
47
47
|
return __awaiter(this, void 0, void 0, function () {
|
package/package.json
CHANGED
|
File without changes
|