@ape.swap/bonds-sdk 1.0.393 → 1.0.395
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,66 @@ 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);
|
|
162
|
+
console.log('MAPPEDBILLS');
|
|
163
|
+
console.log(mappedBills);
|
|
164
|
+
console.log('MAPPEDBILLS');
|
|
148
165
|
}, [account]);
|
|
166
|
+
var _j = useState(null), sortConfig = _j[0], setSortConfig = _j[1];
|
|
167
|
+
var _k = useState(mappedUserBills), sortedBonds = _k[0], setSortedBonds = _k[1];
|
|
168
|
+
var handleSort = function (key) {
|
|
169
|
+
var direction = 'asc';
|
|
170
|
+
if ((sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.key) === key && (sortConfig === null || sortConfig === void 0 ? void 0 : sortConfig.direction) === 'asc') {
|
|
171
|
+
direction = 'desc';
|
|
172
|
+
}
|
|
173
|
+
setSortConfig({ key: key, direction: direction });
|
|
174
|
+
};
|
|
175
|
+
useEffect(function () {
|
|
176
|
+
if (sortConfig === null) {
|
|
177
|
+
var sortedBills = mappedUserBills.sort(function (a, b) {
|
|
178
|
+
var claimableDifference = parseFloat(claimable(b).toFixed(3)) - parseFloat(claimable(a).toFixed(3));
|
|
179
|
+
if (claimableDifference !== 0) {
|
|
180
|
+
return claimableDifference;
|
|
181
|
+
}
|
|
182
|
+
return 0;
|
|
183
|
+
});
|
|
184
|
+
console.log('SORTEDBILLS');
|
|
185
|
+
console.log(sortedBills);
|
|
186
|
+
console.log('SORTEDBILLS');
|
|
187
|
+
setSortedBonds(sortedBills);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
var sorted = __spreadArray([], mappedUserBills, true).sort(function (a, b) {
|
|
191
|
+
var aValue, bValue;
|
|
192
|
+
if (sortConfig.key === 'claimable') {
|
|
193
|
+
aValue = parseFloat(claimable(a).toFixed(3));
|
|
194
|
+
bValue = parseFloat(claimable(b).toFixed(3));
|
|
195
|
+
}
|
|
196
|
+
else if (sortConfig.key === 'pending') {
|
|
197
|
+
aValue = parseFloat(totalPending(a).toFixed(0));
|
|
198
|
+
bValue = parseFloat(totalPending(b).toFixed(0));
|
|
199
|
+
}
|
|
200
|
+
else if (sortConfig.key === 'terms') {
|
|
201
|
+
aValue = vestingTimeRemaining(a).days;
|
|
202
|
+
bValue = vestingTimeRemaining(b).days;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
aValue = a[sortConfig.key];
|
|
206
|
+
bValue = b[sortConfig.key];
|
|
207
|
+
}
|
|
208
|
+
if (aValue < bValue) {
|
|
209
|
+
return sortConfig.direction === 'asc' ? -1 : 1;
|
|
210
|
+
}
|
|
211
|
+
if (aValue > bValue) {
|
|
212
|
+
return sortConfig.direction === 'asc' ? 1 : -1;
|
|
213
|
+
}
|
|
214
|
+
return 0;
|
|
215
|
+
});
|
|
216
|
+
setSortedBonds(sorted);
|
|
217
|
+
}, [sortConfig, mappedUserBills]);
|
|
149
218
|
var rowClick = function (bill) {
|
|
150
219
|
setSelectedBill(bill);
|
|
151
220
|
setIsModalOpen(true);
|
|
@@ -169,30 +238,21 @@ var YourBonds = function (_a) {
|
|
|
169
238
|
var _a;
|
|
170
239
|
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
171
240
|
};
|
|
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: [
|
|
241
|
+
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
242
|
height: ['36px', '36px', '36px', '26px'],
|
|
174
243
|
lineHeight: '12px',
|
|
175
244
|
fontSize: '14px',
|
|
176
245
|
fontWeight: 600,
|
|
177
246
|
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
|
-
});
|
|
247
|
+
} }, { children: "Claim All" })) }))] }))] })), sortedBonds.map(function (bill) {
|
|
248
|
+
var _a, _b;
|
|
249
|
+
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: {
|
|
250
|
+
height: ['36px', '36px', '36px', '26px'],
|
|
251
|
+
lineHeight: '12px',
|
|
252
|
+
fontSize: '14px',
|
|
253
|
+
fontWeight: 600,
|
|
254
|
+
width: '100%',
|
|
255
|
+
} }, { children: "Claim" })) })) }))] }))] }), bill.bond.billAddress));
|
|
196
256
|
})] }))] })));
|
|
197
257
|
};
|
|
198
258
|
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
|