@ape.swap/bonds-sdk 1.0.582 → 1.0.584
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.
|
@@ -70,7 +70,7 @@ var BondModal = function (_a) {
|
|
|
70
70
|
//user to buy
|
|
71
71
|
//Check with Fede if this needs to be temp, if we force approval everytime, isn't this fine?
|
|
72
72
|
var handleBuy = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
-
var billAddress, decimals, maxPrice, amount
|
|
73
|
+
var billAddress, decimals, maxPrice, amount;
|
|
74
74
|
return __generator(this, function (_a) {
|
|
75
75
|
billAddress = bondData[0].billAddress;
|
|
76
76
|
decimals = 18;
|
|
@@ -78,7 +78,6 @@ var BondModal = function (_a) {
|
|
|
78
78
|
console.log('HANDLEBUY CLICKED');
|
|
79
79
|
maxPrice = new BigNumber(bondData[0].trueBillPrice).times(102).div(100);
|
|
80
80
|
amount = convertToTokenValue(inputValue, decimals);
|
|
81
|
-
maxPriceBigNumber = ethers.BigNumber.from(maxPrice.toFixed(0));
|
|
82
81
|
console.log('BillAddress:', billAddress);
|
|
83
82
|
console.log('Amount:', amount);
|
|
84
83
|
console.log('MaxPrice:', maxPrice);
|
|
@@ -86,7 +85,7 @@ var BondModal = function (_a) {
|
|
|
86
85
|
address: billAddress,
|
|
87
86
|
abi: BOND_ABI,
|
|
88
87
|
functionName: 'deposit',
|
|
89
|
-
args: [amount,
|
|
88
|
+
args: [amount, maxPrice, account],
|
|
90
89
|
});
|
|
91
90
|
console.log('BuyTransaction:', hash);
|
|
92
91
|
if (hash) {
|
|
@@ -68,45 +68,46 @@ import BOND_ABI from '../../config/abi/bond.json';
|
|
|
68
68
|
import { useWriteContract } from 'wagmi';
|
|
69
69
|
var YourBonds = function (_a) {
|
|
70
70
|
var account = _a.account;
|
|
71
|
-
var
|
|
71
|
+
var _b = useWriteContract(), hash = _b.data, isPending = _b.isPending, writeContract = _b.writeContract;
|
|
72
72
|
var handleClaim = function (billId, billAddress) { return __awaiter(void 0, void 0, void 0, function () {
|
|
73
|
-
var address
|
|
73
|
+
var address;
|
|
74
74
|
return __generator(this, function (_a) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
return [3 /*break*/, 4];
|
|
98
|
-
case 3:
|
|
99
|
-
error_1 = _a.sent();
|
|
100
|
-
console.error('Approval failed:', error_1);
|
|
101
|
-
return [3 /*break*/, 4];
|
|
102
|
-
case 4: return [2 /*return*/];
|
|
75
|
+
address = billAddress;
|
|
76
|
+
try {
|
|
77
|
+
//const uint256BillId = ethers.BigNumber.from(billId);
|
|
78
|
+
console.log('claimClicked');
|
|
79
|
+
// console.log('billId:', uint256BillId);
|
|
80
|
+
console.log('billAddress:', billAddress);
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
writeContract({
|
|
83
|
+
address: address,
|
|
84
|
+
abi: BOND_ABI,
|
|
85
|
+
functionName: 'redeem',
|
|
86
|
+
args: [billId],
|
|
87
|
+
});
|
|
88
|
+
console.log('ClaimTransaction:', hash);
|
|
89
|
+
if (hash) {
|
|
90
|
+
setClaimTx(hash);
|
|
91
|
+
console.log('SetClaimTx:', hash);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.error('Approval failed:', error);
|
|
103
96
|
}
|
|
97
|
+
return [2 /*return*/];
|
|
104
98
|
});
|
|
105
99
|
}); };
|
|
106
|
-
var
|
|
100
|
+
var _c = useState(null), claimTx = _c[0], setClaimTx = _c[1];
|
|
101
|
+
var _d = useState(null), toastMessage = _d[0], setToastMessage = _d[1];
|
|
102
|
+
useEffect(function () {
|
|
103
|
+
if (hash) {
|
|
104
|
+
setToastMessage("Transaction complete: ".concat(hash));
|
|
105
|
+
setTimeout(function () { return setToastMessage(null); }, 5000); // Hide toast after 5 seconds
|
|
106
|
+
}
|
|
107
|
+
}, [hash]);
|
|
107
108
|
// Fetch data
|
|
108
|
-
var
|
|
109
|
-
var
|
|
109
|
+
var _e = useState([]), bondData = _e[0], setBondData = _e[1];
|
|
110
|
+
var _f = useState([]), mappedUserBills = _f[0], setMappedUserBills = _f[1];
|
|
110
111
|
useEffect(function () {
|
|
111
112
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
112
113
|
var bonds = response.data.bonds;
|
|
@@ -115,7 +116,7 @@ var YourBonds = function (_a) {
|
|
|
115
116
|
}, []);
|
|
116
117
|
useEffect(function () {
|
|
117
118
|
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
118
|
-
var results, mappedBills,
|
|
119
|
+
var results, mappedBills, error_1;
|
|
119
120
|
return __generator(this, function (_a) {
|
|
120
121
|
switch (_a.label) {
|
|
121
122
|
case 0:
|
|
@@ -131,8 +132,8 @@ var YourBonds = function (_a) {
|
|
|
131
132
|
console.log('User owned bills data:', mappedBills);
|
|
132
133
|
return [3 /*break*/, 4];
|
|
133
134
|
case 3:
|
|
134
|
-
|
|
135
|
-
console.error('Error fetching user owned bills data:',
|
|
135
|
+
error_1 = _a.sent();
|
|
136
|
+
console.error('Error fetching user owned bills data:', error_1);
|
|
136
137
|
return [3 /*break*/, 4];
|
|
137
138
|
case 4: return [2 /*return*/];
|
|
138
139
|
}
|
|
@@ -140,8 +141,8 @@ var YourBonds = function (_a) {
|
|
|
140
141
|
}); };
|
|
141
142
|
fetchData();
|
|
142
143
|
}, [account, bondData, claimTx]);
|
|
143
|
-
var
|
|
144
|
-
var
|
|
144
|
+
var _g = useState(null), sortConfig = _g[0], setSortConfig = _g[1];
|
|
145
|
+
var _h = useState(mappedUserBills), sortedBonds = _h[0], setSortedBonds = _h[1];
|
|
145
146
|
var handleSort = function (key) {
|
|
146
147
|
var direction = 'asc';
|
|
147
148
|
if ((sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.key) === key && (sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.direction) === 'asc') {
|
|
@@ -222,8 +223,8 @@ var YourBonds = function (_a) {
|
|
|
222
223
|
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
223
224
|
};
|
|
224
225
|
// Modal
|
|
225
|
-
var
|
|
226
|
-
var
|
|
226
|
+
var _j = useState(false), isModalOpen = _j[0], setIsModalOpen = _j[1];
|
|
227
|
+
var _k = useState(undefined), selectedBill = _k[0], setSelectedBill = _k[1];
|
|
227
228
|
var rowClick = function (bill) {
|
|
228
229
|
console.log(bill);
|
|
229
230
|
setSelectedBill(bill);
|
|
@@ -231,8 +232,8 @@ var YourBonds = function (_a) {
|
|
|
231
232
|
// navigate(`/yourBonds/?bondAddress=${bill.address}&bondChain=${bill.bond.chainId}`, { replace: true });
|
|
232
233
|
};
|
|
233
234
|
// Search logic
|
|
234
|
-
var
|
|
235
|
-
var
|
|
235
|
+
var _l = useState(''), inputValue = _l[0], setInputValue = _l[1];
|
|
236
|
+
var _m = useState(sortedBonds), filteredBonds = _m[0], setFilteredBonds = _m[1];
|
|
236
237
|
useEffect(function () {
|
|
237
238
|
if (inputValue === '') {
|
|
238
239
|
setFilteredBonds(sortedBonds);
|
|
@@ -247,7 +248,7 @@ var YourBonds = function (_a) {
|
|
|
247
248
|
setInputValue(event.target.value);
|
|
248
249
|
};
|
|
249
250
|
// Page render logic
|
|
250
|
-
var
|
|
251
|
+
var _o = useState(false), bondsRendered = _o[0], setBondsRendered = _o[1];
|
|
251
252
|
useEffect(function () {
|
|
252
253
|
if (filteredBonds.length > 0) {
|
|
253
254
|
setBondsRendered(true);
|
|
@@ -257,7 +258,7 @@ var YourBonds = function (_a) {
|
|
|
257
258
|
setIsModalOpen(false);
|
|
258
259
|
};
|
|
259
260
|
return (_jsxs(ThemeUIProvider, { theme: defaultTheme, children: [isModalOpen &&
|
|
260
|
-
_jsx(YourBondsModal, { isOpen: true, onClose: closeModal, userBill: selectedBill }), 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) {
|
|
261
|
+
_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) {
|
|
261
262
|
var _a, _b;
|
|
262
263
|
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(3)), 0), _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: !account && (claimableNumber(bill) === 0), onClick: function (event) {
|
|
263
264
|
event.stopPropagation();
|
package/dist/scss/YourBonds.scss
CHANGED
|
@@ -128,4 +128,27 @@
|
|
|
128
128
|
justify-content: center;
|
|
129
129
|
align-items: center;
|
|
130
130
|
width: 100%;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.toast {
|
|
134
|
+
position: fixed;
|
|
135
|
+
bottom: 20px;
|
|
136
|
+
right: 20px;
|
|
137
|
+
background-color: #333;
|
|
138
|
+
color: #fff;
|
|
139
|
+
padding: 10px 20px;
|
|
140
|
+
border-radius: 5px;
|
|
141
|
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
142
|
+
z-index: 1000;
|
|
143
|
+
animation: fadein 0.5s, fadeout 0.5s 4.5s;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@keyframes fadein {
|
|
147
|
+
from { bottom: 0; opacity: 0; }
|
|
148
|
+
to { bottom: 20px; opacity: 1; }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@keyframes fadeout {
|
|
152
|
+
from { bottom: 20px; opacity: 1; }
|
|
153
|
+
to { bottom: 0; opacity: 0; }
|
|
131
154
|
}
|