@ape.swap/bonds-sdk 1.0.393 → 1.0.394
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -45,6 +45,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
48
57
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
49
58
|
/** @jsxImportSource theme-ui */
|
|
50
59
|
import { useEffect, useState } from 'react';
|
|
@@ -56,7 +65,7 @@ import getTimePeriods from '../../utils/getTimePeriods';
|
|
|
56
65
|
import { defaultTheme } from '../../theme';
|
|
57
66
|
import '../../scss/YourBonds.scss';
|
|
58
67
|
import { BigNumber } from 'bignumber.js';
|
|
59
|
-
import { Text, Button } from '../uikit-sdk';
|
|
68
|
+
import { Text, Button, Svg } from '../uikit-sdk';
|
|
60
69
|
import { MAINNET_CHAINS } from '../../config/constants/chains';
|
|
61
70
|
import TokenInfoAndName from '../TokenInfoAndName';
|
|
62
71
|
import { getBalanceNumber } from '../../utils/getBalanceNumber';
|
|
@@ -113,8 +122,9 @@ var YourBonds = function (_a) {
|
|
|
113
122
|
// Fetch data for user owned bill
|
|
114
123
|
var _d = useState([]), bondData = _d[0], setBondData = _d[1];
|
|
115
124
|
var _e = useState([]), userOwnedBillsData = _e[0], setUserOwnedBillsData = _e[1];
|
|
116
|
-
var _f = useState(
|
|
117
|
-
var _g = useState(
|
|
125
|
+
var _f = useState([]), mappedUserBills = _f[0], setMappedUserBills = _f[1];
|
|
126
|
+
var _g = useState(false), isModalOpen = _g[0], setIsModalOpen = _g[1];
|
|
127
|
+
var _h = useState(null), selectedBill = _h[0], setSelectedBill = _h[1];
|
|
118
128
|
useEffect(function () {
|
|
119
129
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
120
130
|
var bonds = response.data.bonds;
|
|
@@ -145,7 +155,60 @@ var YourBonds = function (_a) {
|
|
|
145
155
|
});
|
|
146
156
|
}); };
|
|
147
157
|
fetchData();
|
|
158
|
+
var mappedBills = userOwnedBillsData.flat().flatMap(function (data) {
|
|
159
|
+
return data.userOwnedBills.map(function (bill) { return bill; });
|
|
160
|
+
});
|
|
161
|
+
setMappedUserBills(mappedBills);
|
|
148
162
|
}, [account]);
|
|
163
|
+
var _j = useState(null), sortConfig = _j[0], setSortConfig = _j[1];
|
|
164
|
+
var _k = useState(mappedUserBills), sortedBonds = _k[0], setSortedBonds = _k[1];
|
|
165
|
+
var handleSort = function (key) {
|
|
166
|
+
var direction = 'asc';
|
|
167
|
+
if ((sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.key) === key && (sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.direction) === 'asc') {
|
|
168
|
+
direction = 'desc';
|
|
169
|
+
}
|
|
170
|
+
setSortConfig({ key: key, direction: direction });
|
|
171
|
+
};
|
|
172
|
+
useEffect(function () {
|
|
173
|
+
if (sortConfig === null) {
|
|
174
|
+
var sortedBills = mappedUserBills.sort(function (a, b) {
|
|
175
|
+
var claimableDifference = parseFloat(claimable(b).toFixed(3)) - parseFloat(claimable(a).toFixed(3));
|
|
176
|
+
if (claimableDifference !== 0) {
|
|
177
|
+
return claimableDifference;
|
|
178
|
+
}
|
|
179
|
+
return 0;
|
|
180
|
+
});
|
|
181
|
+
setSortedBonds(sortedBills);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
var sorted = __spreadArray([], sortedBonds, true).sort(function (a, b) {
|
|
185
|
+
var aValue, bValue;
|
|
186
|
+
if (sortConfig.key === 'claimable') {
|
|
187
|
+
aValue = parseFloat(claimable(a).toFixed(3));
|
|
188
|
+
bValue = parseFloat(claimable(b).toFixed(3));
|
|
189
|
+
}
|
|
190
|
+
else if (sortConfig.key === 'pending') {
|
|
191
|
+
aValue = parseFloat(totalPending(a).toFixed(0));
|
|
192
|
+
bValue = parseFloat(totalPending(b).toFixed(0));
|
|
193
|
+
}
|
|
194
|
+
else if (sortConfig.key === 'terms') {
|
|
195
|
+
aValue = vestingTimeRemaining(a).days;
|
|
196
|
+
bValue = vestingTimeRemaining(b).days;
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
aValue = a[sortConfig.key];
|
|
200
|
+
bValue = b[sortConfig.key];
|
|
201
|
+
}
|
|
202
|
+
if (aValue < bValue) {
|
|
203
|
+
return sortConfig.direction === 'asc' ? -1 : 1;
|
|
204
|
+
}
|
|
205
|
+
if (aValue > bValue) {
|
|
206
|
+
return sortConfig.direction === 'asc' ? 1 : -1;
|
|
207
|
+
}
|
|
208
|
+
return 0;
|
|
209
|
+
});
|
|
210
|
+
setSortedBonds(sorted);
|
|
211
|
+
}, [sortConfig, sortedBonds]);
|
|
149
212
|
var rowClick = function (bill) {
|
|
150
213
|
setSelectedBill(bill);
|
|
151
214
|
setIsModalOpen(true);
|
|
@@ -169,30 +232,21 @@ var YourBonds = function (_a) {
|
|
|
169
232
|
var _a;
|
|
170
233
|
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
171
234
|
};
|
|
172
|
-
return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && _jsx("p", { children: account }), isActive && account && _jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" })), _jsxs(Flex, __assign({ className: "container table-container" }, { children: [_jsxs(Flex, __assign({ className: "container header-container" }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, { className: "column column-tokeninfoname" }) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [
|
|
235
|
+
return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && _jsx("p", { children: account }), isActive && account && _jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" })), _jsxs(Flex, __assign({ className: "container table-container" }, { children: [_jsxs(Flex, __assign({ className: "container header-container" }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, { className: "column column-tokeninfoname" }) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-claimable" }, { children: [_jsx(Text, { children: "Claimable" }), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('claimable'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [_jsx(Text, { children: "Pending" }), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('pending'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsxs(Flex, __assign({ className: "column column-term" }, { children: [_jsx(Text, { children: "Terms" }), _jsx(Flex, __assign({ className: "column header-icon", onClick: function () { return handleSort('terms'); } }, { children: _jsx(Svg, { icon: "sort", width: "12px" }) }))] })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
|
|
173
236
|
height: ['36px', '36px', '36px', '26px'],
|
|
174
237
|
lineHeight: '12px',
|
|
175
238
|
fontSize: '14px',
|
|
176
239
|
fontWeight: 600,
|
|
177
240
|
width: '100%',
|
|
178
|
-
} }, { children: "Claim All" })) }))] }))] })),
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
var _a, _b;
|
|
188
|
-
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bill: bill.bond, vestEnds: "Ends in ".concat(getPendingVesting(bill.lastBlockTimestamp, bill.vesting)) }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-claimable" }, { children: [formatNumberSI(parseFloat(claimable(bill).toFixed(3)), 0), "($".concat((claimable(bill) * ((_a = parseFloat(earnTokenPrice(bill.bond))) !== null && _a !== void 0 ? _a : 0)).toFixed(2), ")")] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [formatNumberSI(parseFloat(totalPending(bill).toFixed(0)), 0), "($".concat((totalPending(bill) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")")] })), _jsx(Flex, __assign({ className: "column column-term" }, { children: "".concat(vestingTimeRemaining(bill).days, "d, ").concat(vestingTimeRemaining(bill).hours, "h, ").concat(vestingTimeRemaining(bill).minutes, "m") })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Flex, __assign({ className: "column-claimall button" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
|
|
189
|
-
height: ['36px', '36px', '36px', '26px'],
|
|
190
|
-
lineHeight: '12px',
|
|
191
|
-
fontSize: '14px',
|
|
192
|
-
fontWeight: 600,
|
|
193
|
-
width: '100%',
|
|
194
|
-
} }, { children: "Claim" })) })) }))] }))] }), bill.bond.billAddress));
|
|
195
|
-
});
|
|
241
|
+
} }, { children: "Claim All" })) }))] }))] })), sortedBonds.map(function (bill) {
|
|
242
|
+
var _a, _b;
|
|
243
|
+
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bill: bill.bond, vestEnds: "Ends in ".concat(getPendingVesting(bill.lastBlockTimestamp, bill.vesting)) }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-claimable" }, { children: [formatNumberSI(parseFloat(claimable(bill).toFixed(3)), 0), "($".concat((claimable(bill) * ((_a = parseFloat(earnTokenPrice(bill.bond))) !== null && _a !== void 0 ? _a : 0)).toFixed(2), ")")] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [formatNumberSI(parseFloat(totalPending(bill).toFixed(0)), 0), "($".concat((totalPending(bill) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")")] })), _jsx(Flex, __assign({ className: "column column-term" }, { children: "".concat(vestingTimeRemaining(bill).days, "d, ").concat(vestingTimeRemaining(bill).hours, "h, ").concat(vestingTimeRemaining(bill).minutes, "m") })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Flex, __assign({ className: "column-claimall button" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
|
|
244
|
+
height: ['36px', '36px', '36px', '26px'],
|
|
245
|
+
lineHeight: '12px',
|
|
246
|
+
fontSize: '14px',
|
|
247
|
+
fontWeight: 600,
|
|
248
|
+
width: '100%',
|
|
249
|
+
} }, { children: "Claim" })) })) }))] }))] }), bill.bond.billAddress));
|
|
196
250
|
})] }))] })));
|
|
197
251
|
};
|
|
198
252
|
export default YourBonds;
|
|
@@ -41,7 +41,7 @@ import { PRICE_GETTER_ADDRESSES } from '../../config/constants/addresses';
|
|
|
41
41
|
import PRICE_GETTER_ABI from '../../config/abi/price-getter.json';
|
|
42
42
|
import PRICE_GETTER_ABI_LINEA from '../../config/abi/price-getter-linea.json';
|
|
43
43
|
import { ChainId, Protocols } from '../../enum/apeswaplists';
|
|
44
|
-
import { defaultDexFactories, dexFactories } from '
|
|
44
|
+
import { defaultDexFactories, dexFactories } from './dexFactories';
|
|
45
45
|
export function getTokenPricesV2FromPriceGetter(tokensToCall, chain, lpTokens) {
|
|
46
46
|
if (lpTokens === void 0) { lpTokens = false; }
|
|
47
47
|
return __awaiter(this, void 0, void 0, function () {
|
package/package.json
CHANGED
|
File without changes
|