@ape.swap/bonds-sdk 1.0.417 → 1.0.418
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.
|
@@ -66,57 +66,17 @@ 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
68
|
import { NETWORK_ICONS } from '../../config/constants/chains';
|
|
69
|
-
import { formatUSDNumber, getPremiumColor, premium, youGet, youSpend, youSpendUSD } from './helper';
|
|
69
|
+
import { formatUSDNumber, getPremiumColor, premium, youGet, youGetUSD, 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)
|
|
73
73
|
return null;
|
|
74
74
|
var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
|
|
75
|
-
var vestingTime = function (vestingTerm) { return getTimePeriods(vestingTerm !== null && vestingTerm !== void 0 ? vestingTerm : 0, true); };
|
|
76
75
|
var _c = useState([]), bondData = _c[0], setBondData = _c[1];
|
|
77
76
|
var _d = useState(false), approvalStatus = _d[0], setApprovalStatus = _d[1];
|
|
78
77
|
//This is a temp solution, but we will force approval each time, and then once set we will set status here and allow
|
|
79
78
|
//user to buy
|
|
80
79
|
//Check with Fede if this needs to be temp, if we force approval everytime, isn't this fine?
|
|
81
|
-
useEffect(function () {
|
|
82
|
-
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
83
|
-
var bond = response.data.bonds.filter(function (x) {
|
|
84
|
-
return x.billAddress.toLowerCase() === (bondAddress === null || bondAddress === void 0 ? void 0 : bondAddress.toLowerCase());
|
|
85
|
-
});
|
|
86
|
-
setBondData(bond);
|
|
87
|
-
});
|
|
88
|
-
}, [bondAddress]);
|
|
89
|
-
var getDiscountColor = function (discount) {
|
|
90
|
-
return discount < 0 ? 'discount-negative' : 'discount-positive';
|
|
91
|
-
};
|
|
92
|
-
var discountEarnTokenPrice = function (bond) {
|
|
93
|
-
var _a, _b;
|
|
94
|
-
var earnTokenPrice = parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0');
|
|
95
|
-
return getFirstNonZeroDigits(earnTokenPrice - earnTokenPrice * (((_b = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _b !== void 0 ? _b : 0) / 100));
|
|
96
|
-
};
|
|
97
|
-
var earnTokenPrice = function (bond) {
|
|
98
|
-
var _a;
|
|
99
|
-
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
100
|
-
};
|
|
101
|
-
var maxBuy = function (bond) {
|
|
102
|
-
var _a, _b, _c, _d;
|
|
103
|
-
var available = new BigNumber((_a = bond === null || bond === void 0 ? void 0 : bond.tokensRemaining) !== null && _a !== void 0 ? _a : '0');
|
|
104
|
-
var threshold = 5;
|
|
105
|
-
var thresholdToShow = new BigNumber(threshold).div((_b = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _b !== void 0 ? _b : 0);
|
|
106
|
-
var safeAvailable = available.minus(thresholdToShow);
|
|
107
|
-
var singlePurchaseLimit = new BigNumber((_c = bond === null || bond === void 0 ? void 0 : bond.maxPayout) !== null && _c !== void 0 ? _c : 0).div(new BigNumber(10).pow((_d = bond === null || bond === void 0 ? void 0 : bond.payoutTokenDecimals) !== null && _d !== void 0 ? _d : 18));
|
|
108
|
-
return !available ? 0 : (singlePurchaseLimit.lt(safeAvailable) ? singlePurchaseLimit : safeAvailable);
|
|
109
|
-
};
|
|
110
|
-
var _e = useState(''), inputValue = _e[0], setInputValue = _e[1];
|
|
111
|
-
var handleInputChange = function (event) {
|
|
112
|
-
setInputValue(event.target.value);
|
|
113
|
-
};
|
|
114
|
-
var _f = useState(null), selectedBond = _f[0], setSelectedBond = _f[1];
|
|
115
|
-
var navigate = useNavigate();
|
|
116
|
-
var projectInfo = function (bond) {
|
|
117
|
-
setSelectedBond(bond);
|
|
118
|
-
navigate("/bondsingle/".concat(bond.billAddress));
|
|
119
|
-
};
|
|
120
80
|
var handleBuy = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
121
81
|
var provider, signer, bondContract, maxPrice, amount, tx, error_1;
|
|
122
82
|
return __generator(this, function (_a) {
|
|
@@ -192,9 +152,51 @@ var BondModal = function (_a) {
|
|
|
192
152
|
}
|
|
193
153
|
});
|
|
194
154
|
}); };
|
|
155
|
+
// Fetch data
|
|
156
|
+
useEffect(function () {
|
|
157
|
+
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
158
|
+
var bond = response.data.bonds.filter(function (x) {
|
|
159
|
+
return x.billAddress.toLowerCase() === (bondAddress === null || bondAddress === void 0 ? void 0 : bondAddress.toLowerCase());
|
|
160
|
+
});
|
|
161
|
+
setBondData(bond);
|
|
162
|
+
});
|
|
163
|
+
}, [bondAddress]);
|
|
164
|
+
// Functions for calculations
|
|
165
|
+
var getDiscountColor = function (discount) {
|
|
166
|
+
return discount < 0 ? 'discount-negative' : 'discount-positive';
|
|
167
|
+
};
|
|
168
|
+
var discountEarnTokenPrice = function (bond) {
|
|
169
|
+
var _a, _b;
|
|
170
|
+
var earnTokenPrice = parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0');
|
|
171
|
+
return getFirstNonZeroDigits(earnTokenPrice - earnTokenPrice * (((_b = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _b !== void 0 ? _b : 0) / 100));
|
|
172
|
+
};
|
|
173
|
+
var earnTokenPrice = function (bond) {
|
|
174
|
+
var _a;
|
|
175
|
+
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
176
|
+
};
|
|
177
|
+
var vestingTime = function (vestingTerm) { return getTimePeriods(vestingTerm !== null && vestingTerm !== void 0 ? vestingTerm : 0, true); };
|
|
178
|
+
var maxBuy = function (bond) {
|
|
179
|
+
var _a, _b, _c, _d;
|
|
180
|
+
var available = new BigNumber((_a = bond === null || bond === void 0 ? void 0 : bond.tokensRemaining) !== null && _a !== void 0 ? _a : '0');
|
|
181
|
+
var threshold = 5;
|
|
182
|
+
var thresholdToShow = new BigNumber(threshold).div((_b = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _b !== void 0 ? _b : 0);
|
|
183
|
+
var safeAvailable = available.minus(thresholdToShow);
|
|
184
|
+
var singlePurchaseLimit = new BigNumber((_c = bond === null || bond === void 0 ? void 0 : bond.maxPayout) !== null && _c !== void 0 ? _c : 0).div(new BigNumber(10).pow((_d = bond === null || bond === void 0 ? void 0 : bond.payoutTokenDecimals) !== null && _d !== void 0 ? _d : 18));
|
|
185
|
+
return !available ? 0 : (singlePurchaseLimit.lt(safeAvailable) ? singlePurchaseLimit : safeAvailable);
|
|
186
|
+
};
|
|
187
|
+
var _e = useState(''), inputValue = _e[0], setInputValue = _e[1];
|
|
188
|
+
var handleInputChange = function (event) {
|
|
189
|
+
setInputValue(event.target.value);
|
|
190
|
+
};
|
|
191
|
+
var _f = useState(null), selectedBond = _f[0], setSelectedBond = _f[1];
|
|
192
|
+
var navigate = useNavigate();
|
|
193
|
+
var projectInfo = function (bond) {
|
|
194
|
+
setSelectedBond(bond);
|
|
195
|
+
navigate("/bondsingle/".concat(bond.billAddress));
|
|
196
|
+
};
|
|
195
197
|
return (_jsx(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: bondData.map(function (bond) {
|
|
196
198
|
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(
|
|
199
|
+
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(youGetUSD(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
200
|
if (v.currentTarget.value.includes(',')) {
|
|
199
201
|
v.currentTarget.value = v.currentTarget.value.replace(/,/g, '.');
|
|
200
202
|
}
|
|
@@ -4,6 +4,7 @@ declare function formatUSDNumber(input: string): string;
|
|
|
4
4
|
declare const youSpend: (inputValue: string) => string;
|
|
5
5
|
declare const youSpendUSD: (bond: BondsDataResponse, inputValue: string) => string;
|
|
6
6
|
declare const youGet: (bond: BondsDataResponse, inputValue: string) => string;
|
|
7
|
+
declare const youGetUSD: (bond: BondsDataResponse, inputValue: string) => string;
|
|
7
8
|
declare const premium: (bond: BondsDataResponse, inputValue: string) => string;
|
|
8
9
|
declare const getPremiumColor: (bond: BondsDataResponse, inputValue: string) => string;
|
|
9
|
-
export { formatNumber, formatUSDNumber, youSpend, youSpendUSD, youGet, premium, getPremiumColor };
|
|
10
|
+
export { formatNumber, formatUSDNumber, youSpend, youSpendUSD, youGet, youGetUSD, premium, getPremiumColor };
|
|
@@ -51,4 +51,4 @@ 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 };
|
|
54
|
+
export { formatNumber, formatUSDNumber, youSpend, youSpendUSD, youGet, youGetUSD, premium, getPremiumColor };
|
|
@@ -119,11 +119,9 @@ var Bonds = function (_a) {
|
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
121
|
}); };
|
|
122
|
+
// Fetch data
|
|
122
123
|
var _d = useState([]), bondData = _d[0], setBondData = _d[1];
|
|
123
124
|
var _e = useState([]), hotBonds = _e[0], setHotBonds = _e[1];
|
|
124
|
-
var vestingTime = function (vestingTerm) {
|
|
125
|
-
return getTimePeriods(vestingTerm !== null && vestingTerm !== void 0 ? vestingTerm : 0, true);
|
|
126
|
-
};
|
|
127
125
|
useEffect(function () {
|
|
128
126
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
129
127
|
var bonds = response.data.bonds.filter(function (bond) { return !isSoldOut(bond); });
|
|
@@ -207,6 +205,7 @@ var Bonds = function (_a) {
|
|
|
207
205
|
});
|
|
208
206
|
setSortedBonds(sorted);
|
|
209
207
|
}, [sortConfig, bondData]);
|
|
208
|
+
// Modal
|
|
210
209
|
var _h = useState(false), isModalOpen = _h[0], setIsModalOpen = _h[1];
|
|
211
210
|
var _j = useState(null), selectedBond = _j[0], setSelectedBond = _j[1];
|
|
212
211
|
var rowClick = function (bond) {
|
|
@@ -214,6 +213,10 @@ var Bonds = function (_a) {
|
|
|
214
213
|
setIsModalOpen(true);
|
|
215
214
|
navigate("/?bondAddress=".concat(bond.billAddress, "&bondChain=").concat(bond.chainId), { replace: true });
|
|
216
215
|
};
|
|
216
|
+
// Functions for calcuations
|
|
217
|
+
var vestingTime = function (vestingTerm) {
|
|
218
|
+
return getTimePeriods(vestingTerm !== null && vestingTerm !== void 0 ? vestingTerm : 0, true);
|
|
219
|
+
};
|
|
217
220
|
var getDiscountColor = function (discount) {
|
|
218
221
|
return discount < 0 ? 'discount-negative' : 'discount-positive';
|
|
219
222
|
};
|
|
@@ -122,8 +122,6 @@ var YourBonds = function (_a) {
|
|
|
122
122
|
// Fetch data for user owned bill
|
|
123
123
|
var _d = useState([]), bondData = _d[0], setBondData = _d[1];
|
|
124
124
|
var _e = useState([]), mappedUserBills = _e[0], setMappedUserBills = _e[1];
|
|
125
|
-
var _f = useState(false), isModalOpen = _f[0], setIsModalOpen = _f[1];
|
|
126
|
-
var _g = useState(null), selectedBill = _g[0], setSelectedBill = _g[1];
|
|
127
125
|
useEffect(function () {
|
|
128
126
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
129
127
|
var bonds = response.data.bonds;
|
|
@@ -156,8 +154,8 @@ var YourBonds = function (_a) {
|
|
|
156
154
|
}); };
|
|
157
155
|
fetchData();
|
|
158
156
|
}, [account]);
|
|
159
|
-
var
|
|
160
|
-
var
|
|
157
|
+
var _f = useState(null), sortConfig = _f[0], setSortConfig = _f[1];
|
|
158
|
+
var _g = useState(mappedUserBills), sortedBonds = _g[0], setSortedBonds = _g[1];
|
|
161
159
|
var handleSort = function (key) {
|
|
162
160
|
var direction = 'asc';
|
|
163
161
|
if ((sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.key) === key && (sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.direction) === 'asc') {
|
|
@@ -174,9 +172,6 @@ var YourBonds = function (_a) {
|
|
|
174
172
|
}
|
|
175
173
|
return 0;
|
|
176
174
|
});
|
|
177
|
-
console.log('SORTEDBILLS');
|
|
178
|
-
console.log(sortedBills);
|
|
179
|
-
console.log('SORTEDBILLS');
|
|
180
175
|
setSortedBonds(sortedBills);
|
|
181
176
|
return;
|
|
182
177
|
}
|
|
@@ -232,6 +227,9 @@ var YourBonds = function (_a) {
|
|
|
232
227
|
var _a;
|
|
233
228
|
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
234
229
|
};
|
|
230
|
+
// Modal
|
|
231
|
+
var _h = useState(false), isModalOpen = _h[0], setIsModalOpen = _h[1];
|
|
232
|
+
var _j = useState(null), selectedBill = _j[0], setSelectedBill = _j[1];
|
|
235
233
|
var rowClick = function (bill) {
|
|
236
234
|
setSelectedBill(bill);
|
|
237
235
|
setIsModalOpen(true);
|