@ape.swap/bonds-sdk 1.0.637 → 1.0.638
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/BondRows/BondRowsWithTitle.js +1 -1
- package/dist/components/Modals/BondModal/BondModal.js +29 -38
- package/dist/components/Modals/YourBondsModal/YourBondsModal.js +43 -34
- package/dist/pages/Bonds/Bonds.js +19 -91
- package/dist/pages/YourBonds/YourBonds.js +52 -41
- package/dist/scss/BondModal.scss +25 -0
- package/dist/scss/YourBonds.scss +8 -6
- package/dist/scss/YourBondsModal.scss +25 -0
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ var BondRowsWithTitle = function (_a) {
|
|
|
9
9
|
var billsFilteredByChain = bonds.filter(function (bill) { return bill.chainId === chain; });
|
|
10
10
|
var key = chain;
|
|
11
11
|
var _b = useState(true), isOpen = _b[0], setIsOpen = _b[1];
|
|
12
|
-
return (_jsx(Flex, { className: "container bondRowsWithTitle", sx: { width: '100%', flexDirection: 'column' }, children: _jsxs(AnimatePresence, { initial: false, children: [_jsx(Flex, { onClick: function () { return setIsOpen(!isOpen); }, children: _jsx(ChainTitle, { chain: chain, pt: '5px', hideTitles:
|
|
12
|
+
return (_jsx(Flex, { className: "container bondRowsWithTitle", sx: { width: '100%', flexDirection: 'column' }, children: _jsxs(AnimatePresence, { initial: false, children: [_jsx(Flex, { onClick: function () { return setIsOpen(!isOpen); }, children: _jsx(ChainTitle, { chain: chain, pt: '5px', hideTitles: billsFilteredByChain.length > 0 ? false : true, isOpen: isOpen }) }), billsFilteredByChain.length > 0 && isOpen && (_jsx(motion.div, { initial: { height: 0, overflow: 'hidden' }, animate: { height: 'fit-content', overflow: 'hidden', transitionEnd: { overflow: 'visible' } }, exit: { height: 0, overflow: 'hidden' }, sx: {
|
|
13
13
|
position: 'relative',
|
|
14
14
|
overflow: 'hidden',
|
|
15
15
|
width: '100%',
|
|
@@ -54,21 +54,28 @@ import ERC_20_ABI from '../../../config/abi/erc20.json';
|
|
|
54
54
|
import { NETWORK_ICONS } from '../../../config/constants/chains';
|
|
55
55
|
import { formatUSDNumber, getPremiumColor, premium, youGet, youGetUSD, youSpend, youSpendUSD } from './helper';
|
|
56
56
|
import '../../../scss/BondModal.scss';
|
|
57
|
-
import { useWriteContract } from "wagmi";
|
|
57
|
+
import { useWaitForTransactionReceipt, useWriteContract } from "wagmi";
|
|
58
58
|
import { PUBLIC_RPC_URLS } from "../../../config/constants/networks";
|
|
59
59
|
var BondModal = function (_a) {
|
|
60
60
|
var account = _a.account, isActive = _a.isActive, isOpen = _a.isOpen, accountChainId = _a.accountChainId, onClose = _a.onClose, bondAddress = _a.bondAddress;
|
|
61
61
|
if (!isOpen)
|
|
62
62
|
return null;
|
|
63
|
-
var _b =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var
|
|
63
|
+
var _b = useState([]), bondData = _b[0], setBondData = _b[1];
|
|
64
|
+
var _c = useWriteContract(), hash = _c.data, isPending = _c.isPending, writeContract = _c.writeContract, writeContractAsync = _c.writeContractAsync;
|
|
65
|
+
var _d = useWaitForTransactionReceipt({
|
|
66
|
+
confirmations: 4,
|
|
67
|
+
chainId: accountChainId !== null && accountChainId !== void 0 ? accountChainId : bondData[0].chainId,
|
|
68
|
+
hash: hash,
|
|
69
|
+
}), isConfirming = _d.isLoading, isConfirmed = _d.isSuccess;
|
|
70
|
+
var _e = useState(null), approveTx = _e[0], setApproveTx = _e[1];
|
|
71
|
+
var _f = useState(null), toastMessage = _f[0], setToastMessage = _f[1];
|
|
72
|
+
var _g = useState(null), buyTx = _g[0], setBuyTx = _g[1];
|
|
73
|
+
var _h = useState(null), tokenBalance = _h[0], setTokenBalance = _h[1];
|
|
74
|
+
var _j = useState(null), tokenDecimals = _j[0], setTokenDecimals = _j[1];
|
|
75
|
+
var _k = useState(''), inputValue = _k[0], setInputValue = _k[1];
|
|
76
|
+
var handleInputChange = function (event) {
|
|
77
|
+
setInputValue(event.target.value);
|
|
78
|
+
};
|
|
72
79
|
//This is a temp solution, but we will force approval each time, and then once set we will set status here and allow
|
|
73
80
|
//user to buy
|
|
74
81
|
//Check with Fede if this needs to be temp, if we force approval everytime, isn't this fine?
|
|
@@ -113,7 +120,6 @@ var BondModal = function (_a) {
|
|
|
113
120
|
}
|
|
114
121
|
});
|
|
115
122
|
}); };
|
|
116
|
-
var _d = useState(null), buyTx = _d[0], setBuyTx = _d[1];
|
|
117
123
|
//You approve the token, not the contract (this code will have to be updated for zap)
|
|
118
124
|
var handleApprove = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
119
125
|
var tokenAddress, decimals, amount, tx, error_2;
|
|
@@ -126,29 +132,16 @@ var BondModal = function (_a) {
|
|
|
126
132
|
case 1:
|
|
127
133
|
_a.trys.push([1, 3, , 4]);
|
|
128
134
|
amount = convertToTokenValue(inputValue, decimals);
|
|
129
|
-
console.log('Amount:', amount);
|
|
130
135
|
return [4 /*yield*/, writeContractAsync({
|
|
131
136
|
address: tokenAddress,
|
|
132
137
|
abi: ERC_20_ABI,
|
|
133
138
|
functionName: 'approve',
|
|
134
|
-
args: [
|
|
139
|
+
args: [bondData[0].billAddress, amount]
|
|
135
140
|
})];
|
|
136
141
|
case 2:
|
|
137
142
|
tx = _a.sent();
|
|
138
|
-
// const receipt = useWaitForTransactionReceipt({
|
|
139
|
-
// confirmations: 4,
|
|
140
|
-
// chainId: accountChainId,
|
|
141
|
-
// hash: tx,
|
|
142
|
-
// pollingInterval: 1_000
|
|
143
|
-
// });
|
|
144
|
-
// console.log('Receipt',receipt);
|
|
145
|
-
// if(receipt.isSuccess) {
|
|
146
|
-
// setReceiptTx(receipt.data.transactionHash);
|
|
147
|
-
// console.log('Receipt:', receipt);
|
|
148
|
-
// }
|
|
149
143
|
if (tx) {
|
|
150
144
|
setApproveTx(tx);
|
|
151
|
-
console.log('setApproveTx:', tx);
|
|
152
145
|
}
|
|
153
146
|
return [3 /*break*/, 4];
|
|
154
147
|
case 3:
|
|
@@ -160,10 +153,13 @@ var BondModal = function (_a) {
|
|
|
160
153
|
}
|
|
161
154
|
});
|
|
162
155
|
}); };
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
156
|
+
// Confirmation message
|
|
157
|
+
useEffect(function () {
|
|
158
|
+
if (isConfirmed) {
|
|
159
|
+
setToastMessage("Transaction Complete.");
|
|
160
|
+
setTimeout(function () { return setToastMessage(null); }, 10000);
|
|
161
|
+
}
|
|
162
|
+
}, [approveTx, buyTx, isConfirmed]);
|
|
167
163
|
useEffect(function () {
|
|
168
164
|
if (isActive && account && bondData.length > 0) {
|
|
169
165
|
getTokenBalance(bondData[0].chainId, bondData[0].principalToken, account).then(function (_a) {
|
|
@@ -194,7 +190,6 @@ var BondModal = function (_a) {
|
|
|
194
190
|
case 2:
|
|
195
191
|
balance = _a.sent();
|
|
196
192
|
balanceInEther = ethers.utils.formatUnits(balance, decimals);
|
|
197
|
-
console.log("Token Balance: ".concat(balanceInEther));
|
|
198
193
|
return [2 /*return*/, { balanceInEther: balanceInEther, decimals: decimals }];
|
|
199
194
|
case 3:
|
|
200
195
|
error_3 = _a.sent();
|
|
@@ -236,13 +231,9 @@ var BondModal = function (_a) {
|
|
|
236
231
|
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));
|
|
237
232
|
return !available ? 0 : (singlePurchaseLimit.lt(safeAvailable) ? singlePurchaseLimit : safeAvailable);
|
|
238
233
|
};
|
|
239
|
-
var _j = useState(''), inputValue = _j[0], setInputValue = _j[1];
|
|
240
|
-
var handleInputChange = function (event) {
|
|
241
|
-
setInputValue(event.target.value);
|
|
242
|
-
};
|
|
243
234
|
return (_jsx(ThemeUIProvider, { theme: defaultTheme, children: bondData.map(function (bond) {
|
|
244
235
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
245
|
-
return (_jsx(React.Fragment, { children: _jsx(Flex, { className: "modal modal-backdrop", children: _jsxs(Flex, { className: "modal modal-content", children: [_jsx(Flex, { className: "modal modal-header", children: _jsx(Flex, { className: "svg-close", onClick: onClose, children: _jsx(Svg, { icon: "close" }) }) }), _jsxs(Flex, { className: "modal-container table-container", children: [_jsxs(Flex, { className: "modal-container title-container", children: [_jsx(Flex, { className: "title-container bondicon", children: _jsxs("div", { 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, { className: "title-container bondname", children: bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName }), _jsxs(Flex, { className: "title-container price-container", children: [_jsxs(Flex, { className: "price-container price", children: ["$", earnTokenPrice(bond)] }), _jsxs(Flex, { className: "price-container discounted", children: ["$", discountEarnTokenPrice(bond)] })] }), _jsx(Flex, { 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, { className: "modal-container description-container", children: bond === null || bond === void 0 ? void 0 : bond.shortDescription }), _jsxs(Flex, { className: "modal-container blocks-container", children: [_jsxs(Flex, { className: "modal-block column-discount ".concat(getDiscountColor(bond === null || bond === void 0 ? void 0 : bond.discount)), children: [_jsxs(Flex, { className: "block-header header", children: ["Discount", _jsx(TooltipBubble, { body: _jsx(Flex, { children: TooltipText.Discount }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { 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, { className: "modal-block column-arr", children: [_jsxs(Flex, { className: "block-header header", children: ["ARR", _jsx(TooltipBubble, { body: _jsx(Flex, { children: TooltipText.ARR }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { 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, { className: "modal-block column-term", children: [_jsxs(Flex, { className: "block-header header", children: ["Terms", _jsx(TooltipBubble, { body: _jsx(Flex, { children: TooltipText.Terms }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { 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, { className: "modal-block column-maxbuy", children: [_jsxs(Flex, { className: "block-header header", children: ["Max Buy", _jsx(TooltipBubble, { body: _jsx(Flex, { children: TooltipText.MaxBuy(bond.payoutTokenName) }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { 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, { className: "modal-container text-container", children: [_jsxs(Flex, { className: "text-container row", children: [_jsx(Flex, { className: "row-container spend", children: "You spend:" }), _jsxs(Flex, { className: "row-container spend-val", children: [youSpend(inputValue), " ", bond.principalTokenName, " = $ ", formatUSDNumber(youSpendUSD(bond, inputValue))] })] }), _jsxs(Flex, { className: "text-container row", children: [_jsxs(Flex, { className: "row-container premium", children: ["Premium:", _jsx(TooltipBubble, { body: _jsx(Flex, { children: TooltipText.Premium }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { className: "row-container premium-icon", children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), _jsxs(Flex, { className: "row-container premium-val ".concat(getPremiumColor(bond, inputValue)), children: ["$ ", premium(bond, inputValue)] })] }), _jsxs(Flex, { className: "text-container row", children: [_jsxs(Flex, { 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, { className: "row-container get-val", children: [youGet(bond, inputValue), " ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName, " = $ ", formatUSDNumber(youGetUSD(bond, inputValue))] })] })] }), _jsxs(Flex, { className: "modal-container input-container", children: [_jsxs(Flex, { className: "input-container inputrow", children: [_jsx(Flex, { className: "input-container input", children: _jsx(Input, { placeholder: "0.0", value: inputValue, pattern: "^[0-9]*[.,]?[0-9]*$", onChange: handleInputChange, onInput: function (v) {
|
|
236
|
+
return (_jsx(React.Fragment, { children: _jsx(Flex, { className: "modal modal-backdrop", children: _jsxs(Flex, { className: "modal modal-content", children: [toastMessage && (_jsx(Flex, { className: "toast", children: toastMessage })), _jsx(Flex, { className: "modal modal-header", children: _jsx(Flex, { className: "svg-close", onClick: onClose, children: _jsx(Svg, { icon: "close" }) }) }), _jsxs(Flex, { className: "modal-container table-container", children: [_jsxs(Flex, { className: "modal-container title-container", children: [_jsx(Flex, { className: "title-container bondicon", children: _jsxs("div", { 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, { className: "title-container bondname", children: bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName }), _jsxs(Flex, { className: "title-container price-container", children: [_jsxs(Flex, { className: "price-container price", children: ["$", earnTokenPrice(bond)] }), _jsxs(Flex, { className: "price-container discounted", children: ["$", discountEarnTokenPrice(bond)] })] }), _jsx(Flex, { 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, { className: "modal-container description-container", children: bond === null || bond === void 0 ? void 0 : bond.shortDescription }), _jsxs(Flex, { className: "modal-container blocks-container", children: [_jsxs(Flex, { className: "modal-block column-discount ".concat(getDiscountColor(bond === null || bond === void 0 ? void 0 : bond.discount)), children: [_jsxs(Flex, { className: "block-header header", children: ["Discount", _jsx(TooltipBubble, { body: _jsx(Flex, { children: TooltipText.Discount }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { 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, { className: "modal-block column-arr", children: [_jsxs(Flex, { className: "block-header header", children: ["ARR", _jsx(TooltipBubble, { body: _jsx(Flex, { children: TooltipText.ARR }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { 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, { className: "modal-block column-term", children: [_jsxs(Flex, { className: "block-header header", children: ["Terms", _jsx(TooltipBubble, { body: _jsx(Flex, { children: TooltipText.Terms }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { 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, { className: "modal-block column-maxbuy", children: [_jsxs(Flex, { className: "block-header header", children: ["Max Buy", _jsx(TooltipBubble, { body: _jsx(Flex, { children: TooltipText.MaxBuy(bond.payoutTokenName) }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { 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, { className: "modal-container text-container", children: [_jsxs(Flex, { className: "text-container row", children: [_jsx(Flex, { className: "row-container spend", children: "You spend:" }), _jsxs(Flex, { className: "row-container spend-val", children: [youSpend(inputValue), " ", bond.principalTokenName, " = $ ", formatUSDNumber(youSpendUSD(bond, inputValue))] })] }), _jsxs(Flex, { className: "text-container row", children: [_jsxs(Flex, { className: "row-container premium", children: ["Premium:", _jsx(TooltipBubble, { body: _jsx(Flex, { children: TooltipText.Premium }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { className: "row-container premium-icon", children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }) })] }), _jsxs(Flex, { className: "row-container premium-val ".concat(getPremiumColor(bond, inputValue)), children: ["$ ", premium(bond, inputValue)] })] }), _jsxs(Flex, { className: "text-container row", children: [_jsxs(Flex, { 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, { className: "row-container get-val", children: [youGet(bond, inputValue), " ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName, " = $ ", formatUSDNumber(youGetUSD(bond, inputValue))] })] })] }), _jsxs(Flex, { className: "modal-container input-container", children: [_jsxs(Flex, { className: "input-container inputrow", children: [_jsx(Flex, { className: "input-container input", children: _jsx(Input, { placeholder: "0.0", value: inputValue, pattern: "^[0-9]*[.,]?[0-9]*$", onChange: handleInputChange, onInput: function (v) {
|
|
246
237
|
if (v.currentTarget.value.includes(',')) {
|
|
247
238
|
v.currentTarget.value = v.currentTarget.value.replace(/,/g, '.');
|
|
248
239
|
}
|
|
@@ -256,10 +247,10 @@ var BondModal = function (_a) {
|
|
|
256
247
|
!!v.currentTarget.value && isNumber(v.currentTarget.value) && parseFloat(v.currentTarget.value) >= 0
|
|
257
248
|
? v.currentTarget.value
|
|
258
249
|
: v.currentTarget.value.slice(0, v.currentTarget.value.length - 1);
|
|
259
|
-
} }) }), _jsxs(Flex, { className: "input-container token", children: [_jsx(Flex, { className: "input-container bondicon", children: _jsxs("div", { className: "icon-container-small", children: [_jsx(Svg, { width: 12, height: 12, icon: (_m = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[bond.chainId]) !== null && _m !== void 0 ? _m : 'question' }), _jsx(TokenImage, { symbol: (_o = bond.principalTokenName) !== null && _o !== void 0 ? _o : bond.payoutTokenName, size: 30 })] }) }), _jsx(Flex, { className: "title-container tokenname-small", children: bond === null || bond === void 0 ? void 0 : bond.principalTokenName })] })] }), isActive && account && (_jsxs(Flex, { className: "input-container balancerow", children: [_jsxs(Flex, { className: "balancerow text", children: ["Balance: ", tokenBalance] }), _jsx(Flex, { className: "balancerow max", children: _jsx(Button, { onClick: function () { setInputValue(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0'); }, children: "Max" }) })] }))] }), _jsxs(Flex, { className: "modal-container button-container", children: [_jsx(Flex, { className: "button-container get", children: _jsxs(Button, { onClick: function () { window.open('https://ape.bond/swap', '_blank'); }, children: ["Get ", bond === null || bond === void 0 ? void 0 : bond.principalTokenName] }) }), _jsx(Flex, { className: "button-container buy", children: approveTx != null ?
|
|
260
|
-
|
|
250
|
+
} }) }), _jsxs(Flex, { className: "input-container token", children: [_jsx(Flex, { className: "input-container bondicon", children: _jsxs("div", { className: "icon-container-small", children: [_jsx(Svg, { width: 12, height: 12, icon: (_m = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[bond.chainId]) !== null && _m !== void 0 ? _m : 'question' }), _jsx(TokenImage, { symbol: (_o = bond.principalTokenName) !== null && _o !== void 0 ? _o : bond.payoutTokenName, size: 30 })] }) }), _jsx(Flex, { className: "title-container tokenname-small", children: bond === null || bond === void 0 ? void 0 : bond.principalTokenName })] })] }), isActive && account && (_jsxs(Flex, { className: "input-container balancerow", children: [_jsxs(Flex, { className: "balancerow text", children: ["Balance: ", tokenBalance] }), _jsx(Flex, { className: "balancerow max", children: _jsx(Button, { onClick: function () { setInputValue(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0'); }, children: "Max" }) })] }))] }), _jsxs(Flex, { className: "modal-container button-container", children: [_jsx(Flex, { className: "button-container get", children: _jsxs(Button, { onClick: function () { window.open('https://ape.bond/swap', '_blank'); }, children: ["Get ", bond === null || bond === void 0 ? void 0 : bond.principalTokenName] }) }), _jsx(Flex, { className: "button-container buy", children: approveTx != null && isConfirmed ?
|
|
251
|
+
_jsx(Button, { disabled: isPending || isConfirming || (bond === null || bond === void 0 ? void 0 : bond.soldOut), onClick: handleBuy, children: isConfirming ? 'Confirming...' : "Buy ".concat(bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName) })
|
|
261
252
|
:
|
|
262
|
-
_jsx(Button, { disabled: isPending, onClick: handleApprove, children:
|
|
253
|
+
_jsx(Button, { disabled: isPending || isConfirming || (bond === null || bond === void 0 ? void 0 : bond.soldOut), onClick: handleApprove, children: isConfirming ? 'Confirming...' : 'Approve' }) })] })] })] }) }) }, bond.billAddress));
|
|
263
254
|
}) }));
|
|
264
255
|
};
|
|
265
256
|
export default BondModal;
|
|
@@ -38,7 +38,6 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "theme-ui/jsx-
|
|
|
38
38
|
/** @jsxImportSource theme-ui */
|
|
39
39
|
import React, { useEffect, useState } from 'react';
|
|
40
40
|
import { Flex } from 'theme-ui';
|
|
41
|
-
import { useWeb3React } from '@web3-react/core';
|
|
42
41
|
import { BigNumber } from 'bignumber.js';
|
|
43
42
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
44
43
|
import { NETWORK_ICONS } from '../../../config/constants/chains';
|
|
@@ -51,48 +50,58 @@ import { getPendingVesting } from '../../../hooks/usePendingVesting';
|
|
|
51
50
|
import { formatNumberSI } from '../../../utils/formatNumber';
|
|
52
51
|
import { StyledHeadingText, TraitsContentContainer } from './styles';
|
|
53
52
|
import '../../../scss/YourBondsModal.scss';
|
|
54
|
-
import { useWriteContract } from 'wagmi';
|
|
53
|
+
import { useChainId, useWaitForTransactionReceipt, useWriteContract } from 'wagmi';
|
|
55
54
|
import BOND_ABI from '../../../config/abi/bond.json';
|
|
56
55
|
var YourBondsModal = function (_a) {
|
|
57
56
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
58
57
|
var isOpen = _a.isOpen, onClose = _a.onClose, userBill = _a.userBill;
|
|
59
58
|
if (!isOpen)
|
|
60
59
|
return null;
|
|
61
|
-
var
|
|
62
|
-
var
|
|
60
|
+
var chainId = useChainId();
|
|
61
|
+
var _s = useWriteContract(), hash = _s.data, isPending = _s.isPending, writeContract = _s.writeContract, writeContractAsync = _s.writeContractAsync;
|
|
62
|
+
var _t = useWaitForTransactionReceipt({
|
|
63
|
+
confirmations: 4,
|
|
64
|
+
chainId: userBill === null || userBill === void 0 ? void 0 : userBill.bond.chainId,
|
|
65
|
+
hash: hash,
|
|
66
|
+
}), isConfirming = _t.isLoading, isConfirmed = _t.isSuccess;
|
|
67
|
+
var _u = useState(null), claimTx = _u[0], setClaimTx = _u[1];
|
|
68
|
+
var _v = useState(null), toastMessage = _v[0], setToastMessage = _v[1];
|
|
63
69
|
var handleClaim = function (billId, billAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
-
var address;
|
|
70
|
+
var address, tx, error_1;
|
|
65
71
|
return __generator(this, function (_a) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
switch (_a.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
address = billAddress;
|
|
75
|
+
_a.label = 1;
|
|
76
|
+
case 1:
|
|
77
|
+
_a.trys.push([1, 3, , 4]);
|
|
78
|
+
return [4 /*yield*/, writeContractAsync({
|
|
79
|
+
address: address,
|
|
80
|
+
abi: BOND_ABI,
|
|
81
|
+
functionName: 'redeem',
|
|
82
|
+
args: [billId],
|
|
83
|
+
})];
|
|
84
|
+
case 2:
|
|
85
|
+
tx = _a.sent();
|
|
86
|
+
if (tx) {
|
|
87
|
+
setClaimTx(tx);
|
|
88
|
+
}
|
|
89
|
+
return [3 /*break*/, 4];
|
|
90
|
+
case 3:
|
|
91
|
+
error_1 = _a.sent();
|
|
92
|
+
console.error('Approval failed:', error_1);
|
|
93
|
+
return [3 /*break*/, 4];
|
|
94
|
+
case 4: return [2 /*return*/];
|
|
81
95
|
}
|
|
82
|
-
return [2 /*return*/];
|
|
83
96
|
});
|
|
84
97
|
}); };
|
|
85
|
-
|
|
86
|
-
var _v = useState(null), toastMessage = _v[0], setToastMessage = _v[1];
|
|
98
|
+
// Confirmation message
|
|
87
99
|
useEffect(function () {
|
|
88
|
-
if (
|
|
89
|
-
setToastMessage("Transaction
|
|
90
|
-
setTimeout(function () { return setToastMessage(null); },
|
|
100
|
+
if (isConfirmed) {
|
|
101
|
+
setToastMessage("Transaction Complete.");
|
|
102
|
+
setTimeout(function () { return setToastMessage(null); }, 10000);
|
|
91
103
|
}
|
|
92
|
-
}, [claimTx]);
|
|
93
|
-
// Fetch data for user owned bill
|
|
94
|
-
var _w = useState([]), bondData = _w[0], setBondData = _w[1];
|
|
95
|
-
var _x = useState([]), userOwnedBillsData = _x[0], setUserOwnedBillsData = _x[1];
|
|
104
|
+
}, [claimTx, isConfirmed]);
|
|
96
105
|
// Functions to calculate display values for modal
|
|
97
106
|
var totalPending = function (userBill) {
|
|
98
107
|
var _a, _b, _c, _d;
|
|
@@ -107,10 +116,10 @@ var YourBondsModal = function (_a) {
|
|
|
107
116
|
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
108
117
|
};
|
|
109
118
|
var BILL_ATTRIBUTES = ['The Legend', 'The Location', 'The Moment', 'The Trend', 'The Innovation'];
|
|
110
|
-
var
|
|
111
|
-
var
|
|
119
|
+
var _w = useState(false), isOpenTraits = _w[0], setIsOpenTraits = _w[1];
|
|
120
|
+
var _x = useState(false), billRendered = _x[0], setBillRendered = _x[1];
|
|
112
121
|
var attributes = (_c = (_b = userBill.nftData) === null || _b === void 0 ? void 0 : _b.data.attributes) === null || _c === void 0 ? void 0 : _c.filter(function (attrib) { return BILL_ATTRIBUTES.includes(attrib.trait_type); });
|
|
113
|
-
return (_jsx(_Fragment, { children: _jsx(React.Fragment, { children: _jsx(Flex, { className: "yourbondsmodal backdrop", children: _jsxs(Flex, { className: "yourbondsmodal content", children: [_jsx(Flex, { className: "yourbondsmodal header", children: _jsx(Flex, { className: "svg-close", onClick: onClose, children: _jsx(Svg, { icon: "close" }) }) }), _jsxs(Flex, { className: "yourbondsmodal table-container", children: [_jsx(Flex, { className: "yourbondsmodal bondimage", children: _jsx("img", { src: (_d = userBill.nftData) === null || _d === void 0 ? void 0 : _d.data.image }) }), _jsxs(Flex, { className: "yourbondsmodal yourbondinfo", children: [_jsxs(Flex, { className: "yourbondinfo title-container", children: [_jsx(Flex, { className: "title-container bondicon", children: _jsxs("div", { className: "icon-container", children: [_jsx(Svg, { width: 18, height: 18, icon: (_e = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[userBill.bond.chainId]) !== null && _e !== void 0 ? _e : 'question' }), _jsx(TokenImage, { symbol: (_f = userBill.bond.showcaseTokenName) !== null && _f !== void 0 ? _f : userBill.bond.payoutTokenName, size: 40 })] }) }), _jsx(Flex, { className: "title-container tokenname", children: _jsx(StyledHeadingText, { children: (_g = userBill.bond) === null || _g === void 0 ? void 0 : _g.showcaseTokenName }) }), _jsx(Flex, { className: "title-container tokentags", children: (_h = userBill.bond.tags) === null || _h === void 0 ? void 0 : _h.slice(0, 1).map(function (tag) {
|
|
122
|
+
return (_jsx(_Fragment, { children: _jsx(React.Fragment, { children: _jsx(Flex, { className: "yourbondsmodal backdrop", children: _jsxs(Flex, { className: "yourbondsmodal content", children: [toastMessage && (_jsx(Flex, { className: "toast", children: toastMessage })), _jsx(Flex, { className: "yourbondsmodal header", children: _jsx(Flex, { className: "svg-close", onClick: onClose, children: _jsx(Svg, { icon: "close" }) }) }), _jsxs(Flex, { className: "yourbondsmodal table-container", children: [_jsx(Flex, { className: "yourbondsmodal bondimage", children: _jsx("img", { src: (_d = userBill.nftData) === null || _d === void 0 ? void 0 : _d.data.image }) }), _jsxs(Flex, { className: "yourbondsmodal yourbondinfo", children: [_jsxs(Flex, { className: "yourbondinfo title-container", children: [_jsx(Flex, { className: "title-container bondicon", children: _jsxs("div", { className: "icon-container", children: [_jsx(Svg, { width: 18, height: 18, icon: (_e = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[userBill.bond.chainId]) !== null && _e !== void 0 ? _e : 'question' }), _jsx(TokenImage, { symbol: (_f = userBill.bond.showcaseTokenName) !== null && _f !== void 0 ? _f : userBill.bond.payoutTokenName, size: 40 })] }) }), _jsx(Flex, { className: "title-container tokenname", children: _jsx(StyledHeadingText, { children: (_g = userBill.bond) === null || _g === void 0 ? void 0 : _g.showcaseTokenName }) }), _jsx(Flex, { className: "title-container tokentags", children: (_h = userBill.bond.tags) === null || _h === void 0 ? void 0 : _h.slice(0, 1).map(function (tag) {
|
|
114
123
|
return (_jsx(Flex, { sx: { marginRight: '10px' }, children: _jsx(ListTag, { variant: tag === 'Cex Fund' ? 'cex_fund' : 'liquidity', text: tag === null || tag === void 0 ? void 0 : tag.toUpperCase() }) }, tag));
|
|
115
124
|
}) }), _jsxs(Text, { sx: { color: 'text', opacity: '0.6', fontSize: ['12px', '12px', '12px', '16px'] }, children: ["#", userBill.id] })] }), _jsxs(Flex, { className: "yourbondinfo blocks-container", children: [_jsx(Flex, { className: "yourbondinfo-block attributes", children: _jsxs(Flex, { sx: { flexDirection: 'column', width: '100%' }, children: [_jsxs(Flex, { sx: {
|
|
116
125
|
justifyContent: 'space-between',
|
|
@@ -123,6 +132,6 @@ var YourBondsModal = function (_a) {
|
|
|
123
132
|
? attributes.map(function (a) { return (_jsxs(TraitsContentContainer, { children: [_jsx(Text, { sx: { fontSize: '10px', fontWeight: 500 }, children: a === null || a === void 0 ? void 0 : a.trait_type }), _jsx(Text, { sx: { fontSize: '10px', fontWeight: 500 }, children: a === null || a === void 0 ? void 0 : a.value })] }, a.value)); })
|
|
124
133
|
: BILL_ATTRIBUTES.map(function (attrib) {
|
|
125
134
|
return (_jsxs(TraitsContentContainer, { children: [_jsx(Text, { sx: { fontSize: '10px', fontWeight: 500 }, children: attrib }), _jsx(Skeleton, { width: "150px" })] }, attrib));
|
|
126
|
-
}) }) })) })] }) }), _jsxs(Flex, { className: "yourbondinfo-block row-vested", children: [_jsxs(Flex, { className: "yourbondinfo-block header", children: [_jsx(Flex, { className: "yourbondinfo-block header-title", children: "Fully Vested" }), _jsx(Flex, { className: "yourbondinfo-block header-tooltip", children: _jsx(TooltipBubble, { body: _jsx(Flex, { children: UserBillTooltipText.FullyVested }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { className: "block-header icon", children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), _jsxs(Flex, { className: "yourbondinfo-block info", children: [_jsx(Flex, { className: "block-info icon" }), _jsx(Flex, { className: "block-info text", children: _jsx(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: getPendingVesting((_j = userBill.lastBlockTimestamp) !== null && _j !== void 0 ? _j : '', (_k = userBill.vesting) !== null && _k !== void 0 ? _k : '') }) })] })] }), _jsxs(Flex, { className: "yourbondinfo-block row-pending", children: [_jsxs(Flex, { className: "yourbondinfo-block header", children: [_jsx(Flex, { className: "yourbondinfo-block header-title", children: "Pending" }), _jsx(Flex, { className: "yourbondinfo-block header-tooltip", children: _jsx(TooltipBubble, { body: _jsx(Flex, { children: UserBillTooltipText.Pending }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { className: "block-header icon", children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), _jsxs(Flex, { className: "yourbondinfo-block info", children: [_jsx(Flex, { className: "block-info icon", children: _jsxs("div", { className: "icon-container-small", children: [_jsx(Svg, { width: 10, height: 10, icon: (_l = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[userBill.bond.chainId]) !== null && _l !== void 0 ? _l : 'question' }), _jsx(TokenImage, { symbol: (_m = userBill.bond.showcaseTokenName) !== null && _m !== void 0 ? _m : userBill.bond.payoutTokenName, size: 25 })] }) }), _jsxs(Flex, { className: "block-info text", children: [_jsx(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(parseFloat(totalPending(userBill).toFixed(4)), 4) }), _jsx(Text, { sx: { fontSize: ['10px', '10px', '10px', '12px'], fontWeight: [500, 500, 500, 400], paddingLeft: '10px' }, children: "($".concat((totalPending(userBill) * ((_o = parseFloat(earnTokenPrice(userBill.bond))) !== null && _o !== void 0 ? _o : 0)).toFixed(2), ")") })] })] })] }), _jsxs(Flex, { className: "yourbondinfo-block row-claimable", children: [_jsxs(Flex, { className: "yourbondinfo-block header", children: [_jsx(Flex, { className: "yourbondinfo-block header-title", children: "Claimable" }), _jsx(Flex, { className: "yourbondinfo-block header-tooltip", children: _jsx(TooltipBubble, { body: _jsx(Flex, { children: UserBillTooltipText.Claimable }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { className: "block-header icon", children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), _jsxs(Flex, { className: "yourbondinfo-block info", children: [_jsx(Flex, { className: "block-info icon", children: _jsxs("div", { className: "icon-container-small", children: [_jsx(Svg, { width: 10, height: 10, icon: (_p = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[userBill.bond.chainId]) !== null && _p !== void 0 ? _p : 'question' }), _jsx(TokenImage, { symbol: (_q = userBill.bond.showcaseTokenName) !== null && _q !== void 0 ? _q : userBill.bond.payoutTokenName, size: 25 })] }) }), _jsxs(Flex, { className: "block-info text", children: [_jsx(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(parseFloat(claimable(userBill).toFixed(4)), 4) }), _jsx(Text, { sx: { fontSize: ['10px', '10px', '10px', '12px'], fontWeight: [500, 500, 500, 400], paddingLeft: '10px' }, children: "($".concat((claimable(userBill) * ((_r = parseFloat(earnTokenPrice(userBill.bond))) !== null && _r !== void 0 ? _r : 0)).toFixed(2), ")") })] })] })] })] }), _jsxs(Flex, { className: "yourbondinfo button-container", children: [_jsx(Flex, { className: "button-container claim", children: _jsx(Button, { disabled: claimable(userBill) === 0 || isPending, onClick: function () { return handleClaim(userBill.id, userBill.address); }, children: "CLAIM" }) }), _jsx(Flex, { className: "button-container transfer", children: _jsx(Button, { variant: "secondary", onClick: function () { window.open('https://ape.bond/swap', '_blank'); }, children: "TRANSFER" }) })] })] })] })] }) }) }, userBill.address) }));
|
|
135
|
+
}) }) })) })] }) }), _jsxs(Flex, { className: "yourbondinfo-block row-vested", children: [_jsxs(Flex, { className: "yourbondinfo-block header", children: [_jsx(Flex, { className: "yourbondinfo-block header-title", children: "Fully Vested" }), _jsx(Flex, { className: "yourbondinfo-block header-tooltip", children: _jsx(TooltipBubble, { body: _jsx(Flex, { children: UserBillTooltipText.FullyVested }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { className: "block-header icon", children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), _jsxs(Flex, { className: "yourbondinfo-block info", children: [_jsx(Flex, { className: "block-info icon" }), _jsx(Flex, { className: "block-info text", children: _jsx(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: getPendingVesting((_j = userBill.lastBlockTimestamp) !== null && _j !== void 0 ? _j : '', (_k = userBill.vesting) !== null && _k !== void 0 ? _k : '') }) })] })] }), _jsxs(Flex, { className: "yourbondinfo-block row-pending", children: [_jsxs(Flex, { className: "yourbondinfo-block header", children: [_jsx(Flex, { className: "yourbondinfo-block header-title", children: "Pending" }), _jsx(Flex, { className: "yourbondinfo-block header-tooltip", children: _jsx(TooltipBubble, { body: _jsx(Flex, { children: UserBillTooltipText.Pending }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { className: "block-header icon", children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), _jsxs(Flex, { className: "yourbondinfo-block info", children: [_jsx(Flex, { className: "block-info icon", children: _jsxs("div", { className: "icon-container-small", children: [_jsx(Svg, { width: 10, height: 10, icon: (_l = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[userBill.bond.chainId]) !== null && _l !== void 0 ? _l : 'question' }), _jsx(TokenImage, { symbol: (_m = userBill.bond.showcaseTokenName) !== null && _m !== void 0 ? _m : userBill.bond.payoutTokenName, size: 25 })] }) }), _jsxs(Flex, { className: "block-info text", children: [_jsx(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(parseFloat(totalPending(userBill).toFixed(4)), 4) }), _jsx(Text, { sx: { fontSize: ['10px', '10px', '10px', '12px'], fontWeight: [500, 500, 500, 400], paddingLeft: '10px' }, children: "($".concat((totalPending(userBill) * ((_o = parseFloat(earnTokenPrice(userBill.bond))) !== null && _o !== void 0 ? _o : 0)).toFixed(2), ")") })] })] })] }), _jsxs(Flex, { className: "yourbondinfo-block row-claimable", children: [_jsxs(Flex, { className: "yourbondinfo-block header", children: [_jsx(Flex, { className: "yourbondinfo-block header-title", children: "Claimable" }), _jsx(Flex, { className: "yourbondinfo-block header-tooltip", children: _jsx(TooltipBubble, { body: _jsx(Flex, { children: UserBillTooltipText.Claimable }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: _jsx(Flex, { className: "block-header icon", children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), _jsxs(Flex, { className: "yourbondinfo-block info", children: [_jsx(Flex, { className: "block-info icon", children: _jsxs("div", { className: "icon-container-small", children: [_jsx(Svg, { width: 10, height: 10, icon: (_p = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[userBill.bond.chainId]) !== null && _p !== void 0 ? _p : 'question' }), _jsx(TokenImage, { symbol: (_q = userBill.bond.showcaseTokenName) !== null && _q !== void 0 ? _q : userBill.bond.payoutTokenName, size: 25 })] }) }), _jsxs(Flex, { className: "block-info text", children: [_jsx(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(parseFloat(claimable(userBill).toFixed(4)), 4) }), _jsx(Text, { sx: { fontSize: ['10px', '10px', '10px', '12px'], fontWeight: [500, 500, 500, 400], paddingLeft: '10px' }, children: "($".concat((claimable(userBill) * ((_r = parseFloat(earnTokenPrice(userBill.bond))) !== null && _r !== void 0 ? _r : 0)).toFixed(2), ")") })] })] })] })] }), _jsxs(Flex, { className: "yourbondinfo button-container", children: [_jsx(Flex, { className: "button-container claim", children: _jsx(Button, { disabled: claimable(userBill) === 0 || isPending, onClick: function () { return handleClaim(userBill.id, userBill.address); }, children: "CLAIM" }) }), _jsx(Flex, { className: "button-container transfer", children: _jsx(Button, { variant: "secondary", disabled: true, onClick: function () { window.open('https://ape.bond/swap', '_blank'); }, children: "TRANSFER" }) })] })] })] })] }) }) }, userBill.address) }));
|
|
127
136
|
};
|
|
128
137
|
export default YourBondsModal;
|
|
@@ -1,39 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
1
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
38
2
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
39
3
|
if (ar || !(i in from)) {
|
|
@@ -48,8 +12,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
|
48
12
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
49
13
|
import { Flex, ThemeUIProvider } from 'theme-ui';
|
|
50
14
|
import axios from 'axios';
|
|
51
|
-
import {
|
|
52
|
-
import { useSearchParams, useNavigate } from 'react-router-dom';
|
|
15
|
+
import { useNavigate } from 'react-router-dom';
|
|
53
16
|
import getTimePeriods from '../../utils/getTimePeriods';
|
|
54
17
|
import { defaultTheme } from '../../theme';
|
|
55
18
|
import { BigNumber } from 'bignumber.js';
|
|
@@ -61,51 +24,10 @@ import { useTopTags } from '../../hooks/useTopThreeTags';
|
|
|
61
24
|
import useChainFilterOption from '../../components/BondMenu/useChainFilterOption';
|
|
62
25
|
var Bonds = function (_a) {
|
|
63
26
|
var account = _a.account, accountChainId = _a.accountChainId, isActive = _a.isActive;
|
|
64
|
-
//const { account, isActive } = useWeb3React();
|
|
65
|
-
var _b = useSearchParams(), searchParams = _b[0], setSearchParams = _b[1];
|
|
66
27
|
var navigate = useNavigate();
|
|
67
|
-
var USDT_ABI = [
|
|
68
|
-
// The ERC-20 approve function ABI
|
|
69
|
-
'function approve(address spender, uint256 amount) public returns (bool)',
|
|
70
|
-
];
|
|
71
|
-
var USDT_ADDRESS = '0xdAC17F958D2ee523a2206206994597C13D831ec7'; // USDT contract address on Ethereum mainnet
|
|
72
|
-
var handleApprove = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
-
var provider, signer, usdtContract, tx, error_1;
|
|
74
|
-
return __generator(this, function (_a) {
|
|
75
|
-
switch (_a.label) {
|
|
76
|
-
case 0:
|
|
77
|
-
if (!window.ethereum) {
|
|
78
|
-
console.error('No Ethereum provider found');
|
|
79
|
-
alert('No Ethereum provider found');
|
|
80
|
-
return [2 /*return*/];
|
|
81
|
-
}
|
|
82
|
-
provider = new ethers.providers.Web3Provider(window.ethereum);
|
|
83
|
-
signer = provider.getSigner();
|
|
84
|
-
usdtContract = new ethers.Contract(USDT_ADDRESS, USDT_ABI, signer);
|
|
85
|
-
_a.label = 1;
|
|
86
|
-
case 1:
|
|
87
|
-
_a.trys.push([1, 4, , 5]);
|
|
88
|
-
return [4 /*yield*/, usdtContract.approve(account, // Replace with the actual spender address
|
|
89
|
-
ethers.utils.parseUnits('1000.0', 6))];
|
|
90
|
-
case 2:
|
|
91
|
-
tx = _a.sent();
|
|
92
|
-
return [4 /*yield*/, tx.wait()];
|
|
93
|
-
case 3:
|
|
94
|
-
_a.sent();
|
|
95
|
-
alert('Approval Successful');
|
|
96
|
-
return [3 /*break*/, 5];
|
|
97
|
-
case 4:
|
|
98
|
-
error_1 = _a.sent();
|
|
99
|
-
console.error('Approval error', error_1);
|
|
100
|
-
alert('Approval Failed');
|
|
101
|
-
return [3 /*break*/, 5];
|
|
102
|
-
case 5: return [2 /*return*/];
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
}); };
|
|
106
28
|
// Fetch data
|
|
107
|
-
var
|
|
108
|
-
var
|
|
29
|
+
var _b = useState([]), bondData = _b[0], setBondData = _b[1];
|
|
30
|
+
var _c = useState([]), hotBonds = _c[0], setHotBonds = _c[1];
|
|
109
31
|
var isSoldOut = useCallback(function (bond) {
|
|
110
32
|
var _a, _b;
|
|
111
33
|
var thresholdToHide = new BigNumber(100).div((_a = bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : 0);
|
|
@@ -121,7 +43,7 @@ var Bonds = function (_a) {
|
|
|
121
43
|
}, []);
|
|
122
44
|
useEffect(function () {
|
|
123
45
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
124
|
-
var bonds = response.data.bonds
|
|
46
|
+
var bonds = response.data.bonds;
|
|
125
47
|
setBondData(bonds);
|
|
126
48
|
});
|
|
127
49
|
}, []);
|
|
@@ -132,7 +54,7 @@ var Bonds = function (_a) {
|
|
|
132
54
|
});
|
|
133
55
|
setHotBonds(hotBondAddresses);
|
|
134
56
|
});
|
|
135
|
-
}, []);
|
|
57
|
+
}, [bondData]);
|
|
136
58
|
// Sort functions
|
|
137
59
|
var sortedHotBonds = bondData.sort(function (a, b) {
|
|
138
60
|
var _a, _b;
|
|
@@ -148,8 +70,8 @@ var Bonds = function (_a) {
|
|
|
148
70
|
return b.discount - a.discount;
|
|
149
71
|
}
|
|
150
72
|
});
|
|
151
|
-
var
|
|
152
|
-
var
|
|
73
|
+
var _d = useState(null), sortConfig = _d[0], setSortConfig = _d[1];
|
|
74
|
+
var _e = useState(sortedHotBonds), sortedBonds = _e[0], setSortedBonds = _e[1];
|
|
153
75
|
var handleSort = function (key) {
|
|
154
76
|
var direction = 'asc';
|
|
155
77
|
if ((sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.key) === key && (sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.direction) === 'asc') {
|
|
@@ -191,8 +113,8 @@ var Bonds = function (_a) {
|
|
|
191
113
|
setSortedBonds(sorted);
|
|
192
114
|
}, [sortConfig, bondData]);
|
|
193
115
|
// Modal
|
|
194
|
-
var
|
|
195
|
-
var
|
|
116
|
+
var _f = useState(false), isModalOpen = _f[0], setIsModalOpen = _f[1];
|
|
117
|
+
var _g = useState(null), selectedBond = _g[0], setSelectedBond = _g[1];
|
|
196
118
|
var rowClick = function (bond) {
|
|
197
119
|
setSelectedBond(bond);
|
|
198
120
|
setIsModalOpen(true);
|
|
@@ -215,11 +137,11 @@ var Bonds = function (_a) {
|
|
|
215
137
|
return parseFloat((((discount * 365) / vestingDays).toFixed(2)));
|
|
216
138
|
};
|
|
217
139
|
// Search logic
|
|
218
|
-
var
|
|
140
|
+
var _h = useState(''), inputValue = _h[0], setInputValue = _h[1];
|
|
219
141
|
var topTags = useTopTags(sortedBonds);
|
|
220
142
|
var filterOptions = __spreadArray(__spreadArray(['ALL'], topTags, true), ['SOLD OUT'], false);
|
|
221
|
-
var
|
|
222
|
-
var
|
|
143
|
+
var _j = useState(filterOptions[0]), filterOption = _j[0], setFilterOption = _j[1];
|
|
144
|
+
var _k = useChainFilterOption(), chainFilterOption = _k.data, setChainFilterOption = _k.setChainFilterOption;
|
|
223
145
|
var billstoRender = useMemo(function () {
|
|
224
146
|
var billsToReturn = sortedBonds !== null && sortedBonds !== void 0 ? sortedBonds : [];
|
|
225
147
|
if (inputValue) {
|
|
@@ -234,6 +156,12 @@ var Bonds = function (_a) {
|
|
|
234
156
|
if (!(chainFilterOption === null || chainFilterOption === void 0 ? void 0 : chainFilterOption.includes('All Chains'))) {
|
|
235
157
|
billsToReturn = billsToReturn === null || billsToReturn === void 0 ? void 0 : billsToReturn.filter(function (bill) { return chainFilterOption === null || chainFilterOption === void 0 ? void 0 : chainFilterOption.includes(bill.chainId.toString()); });
|
|
236
158
|
}
|
|
159
|
+
if (filterOption !== 'SOLD OUT') {
|
|
160
|
+
billsToReturn = billsToReturn === null || billsToReturn === void 0 ? void 0 : billsToReturn.filter(function (bond) { return !isSoldOut(bond); });
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
billsToReturn = billsToReturn === null || billsToReturn === void 0 ? void 0 : billsToReturn.filter(function (bond) { return bond.soldOut; });
|
|
164
|
+
}
|
|
237
165
|
// if (filterOption === 'FAVORITES') {
|
|
238
166
|
// billsToReturn = billsToReturn?.filter((bill) => favTokens.includes(bill.payoutTokenName.toLowerCase()))
|
|
239
167
|
// }
|
|
@@ -247,7 +175,7 @@ var Bonds = function (_a) {
|
|
|
247
175
|
setInputValue(event.target.value);
|
|
248
176
|
};
|
|
249
177
|
// Page render logic
|
|
250
|
-
var
|
|
178
|
+
var _l = useState(false), bondsRendered = _l[0], setBondsRendered = _l[1];
|
|
251
179
|
useEffect(function () {
|
|
252
180
|
if (billstoRender.length > 0) {
|
|
253
181
|
setBondsRendered(true);
|
|
@@ -47,7 +47,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
|
47
47
|
/** @jsxImportSource theme-ui */
|
|
48
48
|
import { useEffect, useState } from 'react';
|
|
49
49
|
import { Flex, ThemeUIProvider } from 'theme-ui';
|
|
50
|
-
import { useWeb3React } from '@web3-react/core';
|
|
51
50
|
import getTimePeriods from '../../utils/getTimePeriods';
|
|
52
51
|
import { defaultTheme } from '../../theme';
|
|
53
52
|
import '../../scss/YourBonds.scss';
|
|
@@ -65,43 +64,55 @@ import { fetchUserOwnedBillsDataAsync } from './fetchBillsUser';
|
|
|
65
64
|
import { Input } from '../../components/uikit-sdk/Input';
|
|
66
65
|
import { YourBondsModal } from "../../index";
|
|
67
66
|
import BOND_ABI from '../../config/abi/bond.json';
|
|
68
|
-
import { useWriteContract } from 'wagmi';
|
|
67
|
+
import { useChainId, useWaitForTransactionReceipt, useWriteContract } from 'wagmi';
|
|
69
68
|
var YourBonds = function (_a) {
|
|
70
|
-
var account = _a.account;
|
|
71
|
-
var _b = useWriteContract(), hash = _b.data, isPending = _b.isPending, writeContract = _b.writeContract;
|
|
69
|
+
var account = _a.account, accountChainId = _a.accountChainId;
|
|
70
|
+
var _b = useWriteContract(), hash = _b.data, isPending = _b.isPending, writeContract = _b.writeContract, writeContractAsync = _b.writeContractAsync;
|
|
71
|
+
var _c = useWaitForTransactionReceipt({
|
|
72
|
+
confirmations: 4,
|
|
73
|
+
chainId: accountChainId,
|
|
74
|
+
hash: hash,
|
|
75
|
+
}), isConfirming = _c.isLoading, isConfirmed = _c.isSuccess;
|
|
72
76
|
var handleClaim = function (billId, billAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
-
var address;
|
|
77
|
+
var address, tx, error_1;
|
|
74
78
|
return __generator(this, function (_a) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
switch (_a.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
address = billAddress;
|
|
82
|
+
_a.label = 1;
|
|
83
|
+
case 1:
|
|
84
|
+
_a.trys.push([1, 3, , 4]);
|
|
85
|
+
return [4 /*yield*/, writeContractAsync({
|
|
86
|
+
address: address,
|
|
87
|
+
abi: BOND_ABI,
|
|
88
|
+
functionName: 'redeem',
|
|
89
|
+
args: [billId],
|
|
90
|
+
})];
|
|
91
|
+
case 2:
|
|
92
|
+
tx = _a.sent();
|
|
93
|
+
if (tx) {
|
|
94
|
+
setClaimTx(tx);
|
|
95
|
+
}
|
|
96
|
+
return [3 /*break*/, 4];
|
|
97
|
+
case 3:
|
|
98
|
+
error_1 = _a.sent();
|
|
99
|
+
console.error('Approval failed:', error_1);
|
|
100
|
+
return [3 /*break*/, 4];
|
|
101
|
+
case 4: return [2 /*return*/];
|
|
90
102
|
}
|
|
91
|
-
return [2 /*return*/];
|
|
92
103
|
});
|
|
93
104
|
}); };
|
|
94
|
-
var
|
|
95
|
-
var
|
|
105
|
+
var _d = useState(null), claimTx = _d[0], setClaimTx = _d[1];
|
|
106
|
+
var _e = useState(null), toastMessage = _e[0], setToastMessage = _e[1];
|
|
96
107
|
useEffect(function () {
|
|
97
|
-
if (
|
|
98
|
-
setToastMessage("Transaction
|
|
99
|
-
setTimeout(function () { return setToastMessage(null); },
|
|
108
|
+
if (isConfirmed) {
|
|
109
|
+
setToastMessage("Transaction Complete.");
|
|
110
|
+
setTimeout(function () { return setToastMessage(null); }, 10000);
|
|
100
111
|
}
|
|
101
|
-
}, [claimTx]);
|
|
112
|
+
}, [claimTx, isConfirmed]);
|
|
102
113
|
// Fetch data
|
|
103
|
-
var
|
|
104
|
-
var
|
|
114
|
+
var _f = useState([]), bondData = _f[0], setBondData = _f[1];
|
|
115
|
+
var _g = useState([]), mappedUserBills = _g[0], setMappedUserBills = _g[1];
|
|
105
116
|
useEffect(function () {
|
|
106
117
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
107
118
|
var bonds = response.data.bonds;
|
|
@@ -110,7 +121,7 @@ var YourBonds = function (_a) {
|
|
|
110
121
|
}, []);
|
|
111
122
|
useEffect(function () {
|
|
112
123
|
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
|
-
var results, mappedBills,
|
|
124
|
+
var results, mappedBills, error_2;
|
|
114
125
|
return __generator(this, function (_a) {
|
|
115
126
|
switch (_a.label) {
|
|
116
127
|
case 0:
|
|
@@ -126,8 +137,8 @@ var YourBonds = function (_a) {
|
|
|
126
137
|
console.log('User owned bills data:', mappedBills);
|
|
127
138
|
return [3 /*break*/, 4];
|
|
128
139
|
case 3:
|
|
129
|
-
|
|
130
|
-
console.error('Error fetching user owned bills data:',
|
|
140
|
+
error_2 = _a.sent();
|
|
141
|
+
console.error('Error fetching user owned bills data:', error_2);
|
|
131
142
|
return [3 /*break*/, 4];
|
|
132
143
|
case 4: return [2 /*return*/];
|
|
133
144
|
}
|
|
@@ -135,8 +146,8 @@ var YourBonds = function (_a) {
|
|
|
135
146
|
}); };
|
|
136
147
|
fetchData();
|
|
137
148
|
}, [account, bondData, claimTx]);
|
|
138
|
-
var
|
|
139
|
-
var
|
|
149
|
+
var _h = useState(null), sortConfig = _h[0], setSortConfig = _h[1];
|
|
150
|
+
var _j = useState(mappedUserBills), sortedBonds = _j[0], setSortedBonds = _j[1];
|
|
140
151
|
var handleSort = function (key) {
|
|
141
152
|
var direction = 'asc';
|
|
142
153
|
if ((sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.key) === key && (sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.direction) === 'asc') {
|
|
@@ -191,7 +202,7 @@ var YourBonds = function (_a) {
|
|
|
191
202
|
setSortedBonds(sorted);
|
|
192
203
|
}, [sortConfig, mappedUserBills]);
|
|
193
204
|
// Functions for calculations
|
|
194
|
-
var chainId =
|
|
205
|
+
var chainId = useChainId();
|
|
195
206
|
var currentTime = useCurrentTime() / 1000;
|
|
196
207
|
var vestingTimeRemaining = function (userBill) {
|
|
197
208
|
return getTimePeriods(parseInt(userBill.lastBlockTimestamp) + parseInt(userBill.vesting) - currentTime, true);
|
|
@@ -212,16 +223,16 @@ var YourBonds = function (_a) {
|
|
|
212
223
|
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
213
224
|
};
|
|
214
225
|
// Modal
|
|
215
|
-
var
|
|
216
|
-
var
|
|
226
|
+
var _k = useState(false), isModalOpen = _k[0], setIsModalOpen = _k[1];
|
|
227
|
+
var _l = useState(undefined), selectedBill = _l[0], setSelectedBill = _l[1];
|
|
217
228
|
var rowClick = function (bill) {
|
|
218
229
|
console.log(bill);
|
|
219
230
|
setSelectedBill(bill);
|
|
220
231
|
setIsModalOpen(true);
|
|
221
232
|
};
|
|
222
233
|
// Search logic
|
|
223
|
-
var
|
|
224
|
-
var
|
|
234
|
+
var _m = useState(''), inputValue = _m[0], setInputValue = _m[1];
|
|
235
|
+
var _o = useState(sortedBonds), filteredBonds = _o[0], setFilteredBonds = _o[1];
|
|
225
236
|
useEffect(function () {
|
|
226
237
|
if (inputValue === '') {
|
|
227
238
|
setFilteredBonds(sortedBonds);
|
|
@@ -236,7 +247,7 @@ var YourBonds = function (_a) {
|
|
|
236
247
|
setInputValue(event.target.value);
|
|
237
248
|
};
|
|
238
249
|
// Page render logic
|
|
239
|
-
var
|
|
250
|
+
var _p = useState(false), bondsRendered = _p[0], setBondsRendered = _p[1];
|
|
240
251
|
useEffect(function () {
|
|
241
252
|
if (filteredBonds.length > 0) {
|
|
242
253
|
setBondsRendered(true);
|
|
@@ -248,7 +259,7 @@ var YourBonds = function (_a) {
|
|
|
248
259
|
return (_jsxs(ThemeUIProvider, { theme: defaultTheme, children: [isModalOpen &&
|
|
249
260
|
_jsx(YourBondsModal, { isOpen: true, onClose: closeModal, userBill: selectedBill }), toastMessage && (_jsx(Flex, { className: "toast", children: toastMessage })), bondsRendered && (_jsxs(Flex, { className: "container table-container", children: [_jsxs(Flex, { className: "container header-container", children: [_jsx(Flex, { className: "column column-tokens", children: _jsx(Flex, { 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', color: 'white' }, width: '100%', placeholder: 'Search...' }) }) }), _jsxs(Flex, { className: "column column-bondinfo", children: [_jsxs(Flex, { className: "column header-claimable", children: [_jsx(Text, { sx: { fontSize: '11px', color: 'textDisabledButton' }, children: "CLAIMABLE" }), _jsx(Flex, { className: "column header-icon", onClick: function () { return handleSort('claimable'); }, children: _jsx(Svg, { icon: "sort", width: "12px", color: "textDisabledButton" }) })] }), _jsxs(Flex, { className: "column header-pending", children: [_jsx(Text, { sx: { fontSize: '11px', color: 'textDisabledButton' }, children: "PENDING" }), _jsx(Flex, { className: "column header-icon", onClick: function () { return handleSort('pending'); }, children: _jsx(Svg, { icon: "sort", width: "12px", color: "textDisabledButton" }) })] }), _jsxs(Flex, { className: "column header-terms", children: [_jsx(Text, { sx: { fontSize: '11px', color: 'textDisabledButton' }, children: "TERMS" }), _jsx(Flex, { className: "column header-icon", onClick: function () { return handleSort('terms'); }, children: _jsx(Svg, { icon: "sort", width: "12px", color: "textDisabledButton" }) })] }), _jsx(Flex, { className: "column header-claimall" })] })] }), filteredBonds.map(function (bill) {
|
|
250
261
|
var _a, _b;
|
|
251
|
-
return (_jsxs(Flex, { className: "container bondrow-container", onClick: function () { return rowClick(bill); }, children: [_jsx(Flex, { className: "column column-tokens", children: _jsx(Flex, { className: "column column-tokeninfoname", children: _jsx(TokenInfoAndName, { bill: bill.bond, vestEnds: "Ends in ".concat(getPendingVesting(bill.lastBlockTimestamp, bill.vesting)) }) }) }), _jsxs(Flex, { className: "column column-bondinfo", children: [_jsxs(Flex, { className: "column column-claimable", children: [formatNumberSI(parseFloat(claimable(bill).toFixed(
|
|
262
|
+
return (_jsxs(Flex, { className: "container bondrow-container", onClick: function () { return rowClick(bill); }, children: [_jsx(Flex, { className: "column column-tokens", children: _jsx(Flex, { className: "column column-tokeninfoname", children: _jsx(TokenInfoAndName, { bill: bill.bond, vestEnds: "Ends in ".concat(getPendingVesting(bill.lastBlockTimestamp, bill.vesting)) }) }) }), _jsxs(Flex, { className: "column column-bondinfo", children: [_jsxs(Flex, { className: "column column-claimable", children: [formatNumberSI(parseFloat(claimable(bill).toFixed(4)), 4), _jsx(Text, { sx: { opacity: '0.6', fontSize: '12px', paddingLeft: '5px' }, children: "($".concat((claimable(bill) * ((_a = parseFloat(earnTokenPrice(bill.bond))) !== null && _a !== void 0 ? _a : 0)).toFixed(2), ")") })] }), _jsxs(Flex, { className: "column column-pending", children: [formatNumberSI(parseFloat(totalPending(bill).toFixed(0)), 0), _jsx(Text, { sx: { opacity: '0.6', fontSize: '12px', paddingLeft: '5px' }, children: "($".concat((totalPending(bill) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")") })] }), _jsx(Flex, { className: "column column-terms", children: "".concat(vestingTimeRemaining(bill).days, "d, ").concat(vestingTimeRemaining(bill).hours, "h, ").concat(vestingTimeRemaining(bill).minutes, "m") }), _jsx(Flex, { className: "column column-claimall", children: _jsx(Button, { disabled: claimable(bill) === 0 || isPending, onClick: function (event) {
|
|
252
263
|
event.stopPropagation();
|
|
253
264
|
// Add your claim logic here
|
|
254
265
|
handleClaim(bill.id, bill.address);
|
package/dist/scss/BondModal.scss
CHANGED
|
@@ -405,4 +405,29 @@
|
|
|
405
405
|
Button {
|
|
406
406
|
width: 375px;
|
|
407
407
|
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.toast {
|
|
411
|
+
position: fixed;
|
|
412
|
+
bottom: 50px;
|
|
413
|
+
right: 20px;
|
|
414
|
+
background-color: var(--theme-ui-colors-white2);
|
|
415
|
+
color: white;
|
|
416
|
+
font-size: 24px;
|
|
417
|
+
padding: 10px 20px;
|
|
418
|
+
border-radius: 5px;
|
|
419
|
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
420
|
+
z-index: 9999;
|
|
421
|
+
animation: fadein 0.5s, fadeout 0.5s 4.5s;
|
|
422
|
+
cursor: pointer;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
@keyframes fadein {
|
|
426
|
+
from { bottom: 0; opacity: 0; }
|
|
427
|
+
to { bottom: 50px; opacity: 1; }
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
@keyframes fadeout {
|
|
431
|
+
from { bottom: 50px; opacity: 1; }
|
|
432
|
+
to { bottom: 0; opacity: 0; }
|
|
408
433
|
}
|
package/dist/scss/YourBonds.scss
CHANGED
|
@@ -132,23 +132,25 @@
|
|
|
132
132
|
|
|
133
133
|
.toast {
|
|
134
134
|
position: fixed;
|
|
135
|
-
bottom:
|
|
135
|
+
bottom: 50px;
|
|
136
136
|
right: 20px;
|
|
137
|
-
background-color:
|
|
138
|
-
color:
|
|
137
|
+
background-color: var(--theme-ui-colors-white2);
|
|
138
|
+
color: white;
|
|
139
|
+
font-size: 24px;
|
|
139
140
|
padding: 10px 20px;
|
|
140
141
|
border-radius: 5px;
|
|
141
142
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
142
|
-
z-index:
|
|
143
|
+
z-index: 9999;
|
|
143
144
|
animation: fadein 0.5s, fadeout 0.5s 4.5s;
|
|
145
|
+
cursor: pointer;
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
@keyframes fadein {
|
|
147
149
|
from { bottom: 0; opacity: 0; }
|
|
148
|
-
to { bottom:
|
|
150
|
+
to { bottom: 50px; opacity: 1; }
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
@keyframes fadeout {
|
|
152
|
-
from { bottom:
|
|
154
|
+
from { bottom: 50px; opacity: 1; }
|
|
153
155
|
to { bottom: 0; opacity: 0; }
|
|
154
156
|
}
|
|
@@ -263,4 +263,29 @@
|
|
|
263
263
|
Button {
|
|
264
264
|
width: 125px;
|
|
265
265
|
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.toast {
|
|
269
|
+
position: fixed;
|
|
270
|
+
bottom: 50px;
|
|
271
|
+
right: 20px;
|
|
272
|
+
background-color: var(--theme-ui-colors-white2);
|
|
273
|
+
color: white;
|
|
274
|
+
font-size: 24px;
|
|
275
|
+
padding: 10px 20px;
|
|
276
|
+
border-radius: 5px;
|
|
277
|
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
278
|
+
z-index: 9999;
|
|
279
|
+
animation: fadein 0.5s, fadeout 0.5s 4.5s;
|
|
280
|
+
cursor: pointer;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
@keyframes fadein {
|
|
284
|
+
from { bottom: 0; opacity: 0; }
|
|
285
|
+
to { bottom: 50px; opacity: 1; }
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@keyframes fadeout {
|
|
289
|
+
from { bottom: 50px; opacity: 1; }
|
|
290
|
+
to { bottom: 0; opacity: 0; }
|
|
266
291
|
}
|