@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 BondsProps {
9
+ interface YourBondsProps {
11
10
  connectionString?: string;
12
11
  }
13
- export interface UserBill {
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 { useCallback, useEffect, useState } from 'react';
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, ChainId } from '../../enum/apeswaplists';
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
- var _d = useState([]), bondData = _d[0], setBondData = _d[1];
117
- var _e = useState([]), hotBonds = _e[0], setHotBonds = _e[1];
118
- var vestingTime = function (vestingTerm) {
119
- return getTimePeriods(vestingTerm !== null && vestingTerm !== void 0 ? vestingTerm : 0, true);
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.filter(function (bond) { return !isSoldOut(bond); });
122
+ var bonds = response.data.bonds;
128
123
  setBondData(bonds);
129
124
  });
130
125
  }, []);
131
- useEffect(function () {
132
- axios.get('https://apeswap-strapi.herokuapp.com/hot-bonds').then(function (response) {
133
- var hotBondAddresses = response.data.map(function (bond) {
134
- return bond.BondAddress.toLowerCase();
135
- });
136
- setHotBonds(hotBondAddresses);
137
- });
138
- }, []);
139
- var isSoldOut = useCallback(function (bond) {
140
- var _a, _b;
141
- var thresholdToHide = new BigNumber(100).div((_a = bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : 0);
142
- if (bond.soldOut)
143
- return true;
144
- if (bond.discount == null)
145
- return true;
146
- if (!bond.tokensRemaining)
147
- return false;
148
- if (bond.discount && bond.discount > 25 && bond.chainId === ChainId.BASE /*BASE*/)
149
- return true;
150
- return ((_b = new BigNumber(bond.tokensRemaining)) === null || _b === void 0 ? void 0 : _b.lte(thresholdToHide)) || bond.discount === 100;
151
- }, []);
152
- var sortedBonds = bondData.sort(function (a, b) {
153
- var _a, _b;
154
- var aIsHot = hotBonds.includes(a.billAddress.toLowerCase()) && ((_a = a.discount) !== null && _a !== void 0 ? _a : 0) > 0;
155
- var bIsHot = hotBonds.includes(b.billAddress.toLowerCase()) && ((_b = b.discount) !== null && _b !== void 0 ? _b : 0) > 0;
156
- if (aIsHot && !bIsHot) {
157
- return -1;
158
- }
159
- else if (!aIsHot && bIsHot) {
160
- return 1;
161
- }
162
- else {
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 _h = useState([]), userOwnedBillsData = _h[0], setUserOwnedBillsData = _h[1];
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, _e, _f;
320
- console.log(userBill);
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 {};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "1.0.309",
6
+ "version": "1.0.311",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",