@ape.swap/bonds-sdk 1.0.148 → 1.0.149
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/Bonds/Bonds.js +25 -10
- package/package.json +1 -1
|
@@ -47,7 +47,7 @@ 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 { useEffect, useState } from 'react';
|
|
50
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
51
51
|
import { Flex, ThemeUIProvider } from 'theme-ui';
|
|
52
52
|
import axios from 'axios';
|
|
53
53
|
import { ethers } from 'ethers';
|
|
@@ -57,6 +57,8 @@ import getTimePeriods from '../../utils/getTimePeriods';
|
|
|
57
57
|
import { defaultTheme } from '../../theme';
|
|
58
58
|
import Svg from '../uikit/Svg';
|
|
59
59
|
import '../../scss/Bonds.scss';
|
|
60
|
+
import { BigNumber } from 'bignumber.js';
|
|
61
|
+
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
60
62
|
var Bonds = function (_a) {
|
|
61
63
|
var connectionString = _a.connectionString;
|
|
62
64
|
var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
|
|
@@ -108,10 +110,14 @@ var Bonds = function (_a) {
|
|
|
108
110
|
};
|
|
109
111
|
useEffect(function () {
|
|
110
112
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
111
|
-
var bonds = response.data.bonds
|
|
113
|
+
var bonds = response.data.bonds;
|
|
112
114
|
setBondData(bonds);
|
|
113
115
|
});
|
|
114
116
|
}, []);
|
|
117
|
+
useEffect(function () {
|
|
118
|
+
var bondsToRender = bondData.filter(function (bond) { return !isSoldOut(bond); });
|
|
119
|
+
setBondData(bondsToRender);
|
|
120
|
+
}, []);
|
|
115
121
|
useEffect(function () {
|
|
116
122
|
axios.get('https://apeswap-strapi.herokuapp.com/hot-bonds').then(function (response) {
|
|
117
123
|
var hotBondAddresses = response.data.map(function (bond) {
|
|
@@ -120,6 +126,23 @@ var Bonds = function (_a) {
|
|
|
120
126
|
setHotBonds(hotBondAddresses);
|
|
121
127
|
});
|
|
122
128
|
}, []);
|
|
129
|
+
var isSoldOut = useCallback(function (bond) {
|
|
130
|
+
var _a, _b;
|
|
131
|
+
var thresholdToHide = new BigNumber(100).div((_a = bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : 0);
|
|
132
|
+
if (bond.soldOut)
|
|
133
|
+
return true;
|
|
134
|
+
if (!bond.tokensRemaining)
|
|
135
|
+
return false;
|
|
136
|
+
if (bond.discount && bond.discount > 25 && bond.chainId === ChainId.BASE)
|
|
137
|
+
return true;
|
|
138
|
+
return ((_b = new BigNumber(bond.tokensRemaining)) === null || _b === void 0 ? void 0 : _b.lte(thresholdToHide)) || bond.discount === 100;
|
|
139
|
+
}, []);
|
|
140
|
+
var bondsToRender = [];
|
|
141
|
+
bondData.forEach(function (bond) {
|
|
142
|
+
if (!isSoldOut(bond)) {
|
|
143
|
+
bondsToRender.push(bond);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
123
146
|
var sortedBonds = bondData.sort(function (a, b) {
|
|
124
147
|
var _a, _b;
|
|
125
148
|
var aIsHot = hotBonds.includes(a.billAddress.toLowerCase()) && ((_a = a.discount) !== null && _a !== void 0 ? _a : 0) > 0;
|
|
@@ -134,14 +157,6 @@ var Bonds = function (_a) {
|
|
|
134
157
|
return b.discount - a.discount;
|
|
135
158
|
}
|
|
136
159
|
});
|
|
137
|
-
// const isSoldOut = useCallback((bond: BondsDataResponse) => {
|
|
138
|
-
// const { tokensRemaining, discount, payoutTokenPrice } = bond
|
|
139
|
-
// if (bond.soldOut) return true
|
|
140
|
-
// if (!tokensRemaining) return false
|
|
141
|
-
// const thresholdToHide = new BigNumber(100).div(payoutTokenPrice ?? 0)
|
|
142
|
-
// if (discount && discount > 25 && bond.chainId === ChainId.BASE) return true
|
|
143
|
-
// return new BigNumber(tokensRemaining)?.lte(thresholdToHide) || discount === 100
|
|
144
|
-
// }, []);
|
|
145
160
|
var _f = useState(false), isModalOpen = _f[0], setIsModalOpen = _f[1];
|
|
146
161
|
var _g = useState(null), selectedBond = _g[0], setSelectedBond = _g[1];
|
|
147
162
|
var rowClick = function (bond) {
|