@ape.swap/bonds-sdk 1.0.309 → 1.0.311
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.
|
@@ -1,35 +1,13 @@
|
|
|
1
1
|
/** @jsxImportSource theme-ui */
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { BondsDataResponse } from '../../types/bonds';
|
|
4
3
|
import '../../scss/YourBonds.scss';
|
|
5
4
|
declare global {
|
|
6
5
|
interface Window {
|
|
7
6
|
ethereum?: any;
|
|
8
7
|
}
|
|
9
8
|
}
|
|
10
|
-
interface
|
|
9
|
+
interface YourBondsProps {
|
|
11
10
|
connectionString?: string;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
address: string;
|
|
15
|
-
id: string;
|
|
16
|
-
vesting: string;
|
|
17
|
-
payout: string;
|
|
18
|
-
totalPayout?: string;
|
|
19
|
-
truePricePaid: string;
|
|
20
|
-
lastBlockTimestamp: string;
|
|
21
|
-
pendingRewards: string;
|
|
22
|
-
billNftAddress: string;
|
|
23
|
-
nftData?: UserBillNft;
|
|
24
|
-
bond: BondsDataResponse;
|
|
25
|
-
}
|
|
26
|
-
export interface UserBillNft {
|
|
27
|
-
image: string;
|
|
28
|
-
tokenId: string;
|
|
29
|
-
attributes: {
|
|
30
|
-
trait_type: string;
|
|
31
|
-
value: string;
|
|
32
|
-
}[];
|
|
33
|
-
}
|
|
34
|
-
declare const YourBonds: React.FC<BondsProps>;
|
|
12
|
+
declare const YourBonds: React.FC<YourBondsProps>;
|
|
35
13
|
export default YourBonds;
|
|
@@ -47,9 +47,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
};
|
|
48
48
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
49
49
|
/** @jsxImportSource theme-ui */
|
|
50
|
-
import {
|
|
50
|
+
import { useEffect, useState } from 'react';
|
|
51
51
|
import { Flex, ThemeUIProvider } from 'theme-ui';
|
|
52
|
-
import axios from 'axios';
|
|
53
52
|
import { ethers } from 'ethers';
|
|
54
53
|
import { useWeb3React } from '@web3-react/core';
|
|
55
54
|
import { useSearchParams, useNavigate } from 'react-router-dom';
|
|
@@ -57,7 +56,7 @@ import getTimePeriods from '../../utils/getTimePeriods';
|
|
|
57
56
|
import { defaultTheme } from '../../theme';
|
|
58
57
|
import '../../scss/YourBonds.scss';
|
|
59
58
|
import { BigNumber } from 'bignumber.js';
|
|
60
|
-
import { BillVersion
|
|
59
|
+
import { BillVersion } from '../../enum/apeswaplists';
|
|
61
60
|
import { Text, Button } from '../uikit-sdk';
|
|
62
61
|
import { MAINNET_CHAINS } from '../../config/constants/chains';
|
|
63
62
|
import TokenInfoAndName from '../TokenInfoAndName';
|
|
@@ -69,6 +68,7 @@ import { getFirstNonZeroDigits } from '../../utils/roundNumber';
|
|
|
69
68
|
import { formatNumberSI } from '../../utils/formatNumber';
|
|
70
69
|
import useCurrentTime from '../../hooks/useTimer';
|
|
71
70
|
import { getPendingVesting } from '../../hooks/usePendingVesting';
|
|
71
|
+
import axios from 'axios';
|
|
72
72
|
var YourBonds = function (_a) {
|
|
73
73
|
var connectionString = _a.connectionString;
|
|
74
74
|
var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
|
|
@@ -113,58 +113,48 @@ var YourBonds = function (_a) {
|
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
}); };
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
};
|
|
121
|
-
var currentTime = useCurrentTime() / 1000;
|
|
122
|
-
var vestingTimeRemaining = function (userBill) {
|
|
123
|
-
return getTimePeriods(parseInt(userBill.lastBlockTimestamp) + parseInt(userBill.vesting) - currentTime, true);
|
|
124
|
-
};
|
|
116
|
+
// const [hotBonds, setHotBonds] = useState<string[]>([]);
|
|
117
|
+
// const vestingTime = (vestingTerm: number) => {
|
|
118
|
+
// return getTimePeriods(vestingTerm ?? 0, true);
|
|
119
|
+
// }
|
|
125
120
|
useEffect(function () {
|
|
126
121
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
127
|
-
var bonds = response.data.bonds
|
|
122
|
+
var bonds = response.data.bonds;
|
|
128
123
|
setBondData(bonds);
|
|
129
124
|
});
|
|
130
125
|
}, []);
|
|
131
|
-
useEffect(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}, []);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return b.discount - a.discount;
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
var _f = useState(false), isModalOpen = _f[0], setIsModalOpen = _f[1];
|
|
167
|
-
var _g = useState(null), selectedBond = _g[0], setSelectedBond = _g[1];
|
|
126
|
+
// useEffect(() => {
|
|
127
|
+
// axios.get('https://apeswap-strapi.herokuapp.com/hot-bonds').then((response) => {
|
|
128
|
+
// const hotBondAddresses = response.data.map((bond: { BondAddress: string }) =>
|
|
129
|
+
// bond.BondAddress.toLowerCase(),
|
|
130
|
+
// );
|
|
131
|
+
// setHotBonds(hotBondAddresses);
|
|
132
|
+
// })
|
|
133
|
+
// }, []);
|
|
134
|
+
// const isSoldOut = useCallback((bond: BondsDataResponse) => {
|
|
135
|
+
// const thresholdToHide = new BigNumber(100).div(bond.payoutTokenPrice ?? 0);
|
|
136
|
+
// if (bond.soldOut) return true;
|
|
137
|
+
// if (bond.discount == null) return true;
|
|
138
|
+
// if (!bond.tokensRemaining) return false;
|
|
139
|
+
// if (bond.discount && bond.discount > 25 && bond.chainId === ChainId.BASE /*BASE*/) return true;
|
|
140
|
+
// return new BigNumber(bond.tokensRemaining)?.lte(thresholdToHide) || bond.discount === 100;
|
|
141
|
+
// }, []);
|
|
142
|
+
// const sortedBonds = bondData.sort((a, b) => {
|
|
143
|
+
// const aIsHot = hotBonds.includes(a.billAddress.toLowerCase()) && (a.discount ?? 0) > 0;
|
|
144
|
+
// const bIsHot = hotBonds.includes(b.billAddress.toLowerCase()) && (b.discount ?? 0) > 0;
|
|
145
|
+
// if (aIsHot && !bIsHot) {
|
|
146
|
+
// return -1;
|
|
147
|
+
// }
|
|
148
|
+
// else if (!aIsHot && bIsHot) {
|
|
149
|
+
// return 1;
|
|
150
|
+
// }
|
|
151
|
+
// else {
|
|
152
|
+
// return b.discount - a.discount;
|
|
153
|
+
// }
|
|
154
|
+
// });
|
|
155
|
+
var _d = useState(false), isModalOpen = _d[0], setIsModalOpen = _d[1];
|
|
156
|
+
var _e = useState(null), selectedBond = _e[0], setSelectedBond = _e[1];
|
|
157
|
+
var _f = useState([]), bondData = _f[0], setBondData = _f[1];
|
|
168
158
|
var rowClick = function (bond) {
|
|
169
159
|
setSelectedBond(bond);
|
|
170
160
|
setIsModalOpen(true);
|
|
@@ -180,6 +170,10 @@ var YourBonds = function (_a) {
|
|
|
180
170
|
// }
|
|
181
171
|
// }, [account, slowRefresh])
|
|
182
172
|
// }
|
|
173
|
+
var currentTime = useCurrentTime() / 1000;
|
|
174
|
+
var vestingTimeRemaining = function (userBill) {
|
|
175
|
+
return getTimePeriods(parseInt(userBill.lastBlockTimestamp) + parseInt(userBill.vesting) - currentTime, true);
|
|
176
|
+
};
|
|
183
177
|
var fetchUserOwnedBillsDataAsync = function (chainId, account) { return __awaiter(void 0, void 0, void 0, function () {
|
|
184
178
|
var bonds, userOwnedBills_1, mapUserOwnedBills_1, userOwnedBillsData_1, error_2;
|
|
185
179
|
return __generator(this, function (_a) {
|
|
@@ -211,7 +205,7 @@ var YourBonds = function (_a) {
|
|
|
211
205
|
}
|
|
212
206
|
});
|
|
213
207
|
}); };
|
|
214
|
-
var
|
|
208
|
+
var _g = useState([]), userOwnedBillsData = _g[0], setUserOwnedBillsData = _g[1];
|
|
215
209
|
useEffect(function () {
|
|
216
210
|
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
217
211
|
var results, error_3;
|
|
@@ -226,7 +220,6 @@ var YourBonds = function (_a) {
|
|
|
226
220
|
case 2:
|
|
227
221
|
results = _a.sent();
|
|
228
222
|
setUserOwnedBillsData(results);
|
|
229
|
-
console.log('User owned bills data:', results);
|
|
230
223
|
return [3 /*break*/, 4];
|
|
231
224
|
case 3:
|
|
232
225
|
error_3 = _a.sent();
|
|
@@ -316,12 +309,8 @@ var YourBonds = function (_a) {
|
|
|
316
309
|
}); };
|
|
317
310
|
var chainId = useWeb3React().chainId;
|
|
318
311
|
var totalPending = function (userBill) {
|
|
319
|
-
var _a, _b, _c, _d
|
|
320
|
-
|
|
321
|
-
console.log('CHAINID)');
|
|
322
|
-
console.log((_b = (_a = userBill.bond.earnToken) === null || _a === void 0 ? void 0 : _a.decimals) === null || _b === void 0 ? void 0 : _b[chainId]);
|
|
323
|
-
console.log(userBill.payout);
|
|
324
|
-
return getBalanceNumber(new BigNumber((_c = userBill === null || userBill === void 0 ? void 0 : userBill.payout) !== null && _c !== void 0 ? _c : 0), (_f = (_e = (_d = userBill.bond.earnToken) === null || _d === void 0 ? void 0 : _d.decimals) === null || _e === void 0 ? void 0 : _e[chainId]) !== null && _f !== void 0 ? _f : 18);
|
|
312
|
+
var _a, _b, _c, _d;
|
|
313
|
+
return getBalanceNumber(new BigNumber((_a = userBill === null || userBill === void 0 ? void 0 : userBill.payout) !== null && _a !== void 0 ? _a : 0), (_d = (_c = (_b = userBill.bond.earnToken) === null || _b === void 0 ? void 0 : _b.decimals) === null || _c === void 0 ? void 0 : _c[chainId]) !== null && _d !== void 0 ? _d : 18);
|
|
325
314
|
};
|
|
326
315
|
var claimable = function (userBill) {
|
|
327
316
|
var _a, _b, _c;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BondsDataResponse } from "./bonds";
|
|
2
|
+
export interface UserOwnedBillsData {
|
|
3
|
+
index: number;
|
|
4
|
+
userOwnedBills: UserBill[];
|
|
5
|
+
}
|
|
6
|
+
export interface UserBill {
|
|
7
|
+
address: string;
|
|
8
|
+
id: string;
|
|
9
|
+
vesting: string;
|
|
10
|
+
payout: string;
|
|
11
|
+
totalPayout?: string;
|
|
12
|
+
truePricePaid: string;
|
|
13
|
+
lastBlockTimestamp: string;
|
|
14
|
+
pendingRewards: string;
|
|
15
|
+
billNftAddress: string;
|
|
16
|
+
nftData?: UserBillNft;
|
|
17
|
+
bond: BondsDataResponse;
|
|
18
|
+
}
|
|
19
|
+
export interface UserBillNft {
|
|
20
|
+
image: string;
|
|
21
|
+
tokenId: string;
|
|
22
|
+
attributes: {
|
|
23
|
+
trait_type: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|