@ape.swap/bonds-sdk 1.0.274 → 1.0.275

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,5 +1,6 @@
1
1
  /** @jsxImportSource theme-ui */
2
2
  import React from 'react';
3
+ import { BondsDataResponse } from '../../types/bonds';
3
4
  import '../../scss/Bonds.scss';
4
5
  declare global {
5
6
  interface Window {
@@ -20,6 +21,7 @@ export interface UserBill {
20
21
  pendingRewards: string;
21
22
  billNftAddress: string;
22
23
  nftData?: UserBillNft;
24
+ bond: BondsDataResponse;
23
25
  }
24
26
  export interface UserBillNft {
25
27
  image: string;
@@ -66,7 +66,6 @@ import { TooltipBubble, Svg } from '../uikit-sdk';
66
66
  import Tooltip from '../Tooltip/Tooltip';
67
67
  import { BLOCK_EXPLORER, MAINNET_CHAINS } from '../../config/constants/chains';
68
68
  import TokenInfoAndName from '../TokenInfoAndName';
69
- import useRefresh from '../../hooks/useRefresh';
70
69
  import { ACF_TO_ABOND } from '../../config/constants/addresses';
71
70
  import multicall from '../../utils/multicall';
72
71
  import billAbi from '../../config/abi/bond.json';
@@ -191,18 +190,18 @@ var YourBonds = function (_a) {
191
190
  var explorerLink = BLOCK_EXPLORER[selectedChain];
192
191
  return "".concat(explorerLink, "/address/").concat(bond === null || bond === void 0 ? void 0 : bond.billAddress);
193
192
  };
194
- var usePollUserBills = function () {
195
- var slowRefresh = useRefresh().slowRefresh;
196
- // const dispatch = useAppDispatch()
197
- var _a = useWeb3React(), account = _a.account, isActive = _a.isActive;
198
- useEffect(function () {
199
- if (account) {
200
- MAINNET_CHAINS.map(function (chain) { return fetchUserOwnedBillsDataAsync(chain, account); });
201
- }
202
- }, [account, slowRefresh]);
203
- };
193
+ // const usePollUserBills = () => {
194
+ // const { slowRefresh } = useRefresh()
195
+ // // const dispatch = useAppDispatch()
196
+ // const { account, isActive } = useWeb3React();
197
+ // useEffect(() => {
198
+ // if (account) {
199
+ // MAINNET_CHAINS.map((chain) => fetchUserOwnedBillsDataAsync(chain as number, account))
200
+ // }
201
+ // }, [account, slowRefresh])
202
+ // }
204
203
  var fetchUserOwnedBillsDataAsync = function (chainId, account) { return __awaiter(void 0, void 0, void 0, function () {
205
- var bonds, userOwnedBills_1, mapUserOwnedBills_1, userOwnedBillsData, error_2;
204
+ var bonds, userOwnedBills_1, mapUserOwnedBills_1, userOwnedBillsData_1, error_2;
206
205
  return __generator(this, function (_a) {
207
206
  switch (_a.label) {
208
207
  case 0:
@@ -219,13 +218,11 @@ var YourBonds = function (_a) {
219
218
  mapUserOwnedBills_1 = bonds.map(function (bill) {
220
219
  return userOwnedBills_1.filter(function (b) { return b.address.toLowerCase() === bill.billAddress.toLowerCase(); });
221
220
  });
222
- userOwnedBillsData = bonds.map(function (bill, i) { return ({
221
+ userOwnedBillsData_1 = bonds.map(function (bill, i) { return ({
223
222
  index: bill.index,
224
223
  userOwnedBills: mapUserOwnedBills_1[i],
225
224
  }); });
226
- console.log('userOwnedBillsData');
227
- console.log(userOwnedBillsData);
228
- return [2 /*return*/, Promise.resolve(userOwnedBillsData)];
225
+ return [2 /*return*/, Promise.resolve(userOwnedBillsData_1)];
229
226
  case 2:
230
227
  error_2 = _a.sent();
231
228
  console.error('Error fetching user owned bills data:', error_2);
@@ -234,19 +231,28 @@ var YourBonds = function (_a) {
234
231
  }
235
232
  });
236
233
  }); };
234
+ var _h = useState([]), userOwnedBillsData = _h[0], setUserOwnedBillsData = _h[1];
237
235
  useEffect(function () {
238
236
  var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
239
- var results;
237
+ var results, error_3;
240
238
  return __generator(this, function (_a) {
241
239
  switch (_a.label) {
242
240
  case 0:
243
- if (!account) return [3 /*break*/, 2];
244
- return [4 /*yield*/, Promise.all(MAINNET_CHAINS.map(function (chain) { return fetchUserOwnedBillsDataAsync(chain, account); }))];
241
+ if (!account) return [3 /*break*/, 4];
242
+ _a.label = 1;
245
243
  case 1:
244
+ _a.trys.push([1, 3, , 4]);
245
+ return [4 /*yield*/, Promise.all(MAINNET_CHAINS.map(function (chain) { return fetchUserOwnedBillsDataAsync(chain, account); }))];
246
+ case 2:
246
247
  results = _a.sent();
248
+ setUserOwnedBillsData(results);
247
249
  console.log('User owned bills data:', results);
248
- _a.label = 2;
249
- case 2: return [2 /*return*/];
250
+ return [3 /*break*/, 4];
251
+ case 3:
252
+ error_3 = _a.sent();
253
+ console.error('Error fetching user owned bills data:', error_3);
254
+ return [3 /*break*/, 4];
255
+ case 4: return [2 /*return*/];
250
256
  }
251
257
  });
252
258
  }); };
@@ -276,12 +282,14 @@ var YourBonds = function (_a) {
276
282
  address: bonds[index].billAddress,
277
283
  name: bonds[index].billVersion !== BillVersion.V1 ? 'getBillInfo' : 'billInfo',
278
284
  params: [id],
285
+ bond: bonds[index]
279
286
  }),
280
287
  billDataCalls.push({ address: bonds[index].billAddress, name: 'billNft' }),
281
288
  billsPendingRewardCall.push({
282
289
  address: bonds[index].billAddress,
283
290
  name: bonds[index].billVersion !== BillVersion.V1 ? 'claimablePayout' : 'pendingPayoutFor',
284
291
  params: [id],
292
+ bond: bonds[index]
285
293
  }),
286
294
  billVersions.push(bonds[index].billVersion));
287
295
  });
@@ -307,6 +315,7 @@ var YourBonds = function (_a) {
307
315
  lastBlockTimestamp: (_d = billData[billDataPos][0]) === null || _d === void 0 ? void 0 : _d.lastClaimTimestamp.toString(),
308
316
  truePricePaid: (_e = billData[billDataPos][0]) === null || _e === void 0 ? void 0 : _e.truePricePaid.toString(),
309
317
  pendingRewards: pendingRewardsCall[i][0].toString(),
318
+ bond: billsPendingRewardCall[i].bond
310
319
  }
311
320
  : {
312
321
  address: billsPendingRewardCall[i].address,
@@ -317,6 +326,7 @@ var YourBonds = function (_a) {
317
326
  lastBlockTimestamp: billData[billDataPos][2].toString(),
318
327
  truePricePaid: billData[billDataPos][3].toString(),
319
328
  pendingRewards: pendingRewardsCall[i][0].toString(),
329
+ bond: billsPendingRewardCall[i].bond
320
330
  };
321
331
  result.push(data);
322
332
  }
@@ -324,18 +334,20 @@ var YourBonds = function (_a) {
324
334
  }
325
335
  });
326
336
  }); };
327
- 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: [_jsxs(Flex, __assign({ className: "column column-tokens" }, { children: [_jsx(Flex, __assign({ className: "column column-tokenname" }, { children: "Tokens" })), _jsx(Flex, { className: "column column-tokenicons" })] })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsx(Flex, __assign({ className: "column column-discount" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Discount }), width: "230px", placement: "bottomLeft", transformTip: "translate(18%, -4%)" }, { children: ["Discount", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, __assign({ className: "column column-arr" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.ARR }), width: "230px", placement: "bottomLeft", transformTip: "translate(8%, -5%)" }, { children: ["ARR", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, __assign({ className: "column column-term" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Terms }), width: "230px", placement: "bottomRight", transformTip: "translate(11%, -5%)" }, { children: ["Terms", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, __assign({ className: "column column-tokensremaining" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.TokensRemaining }), width: "230px", placement: "bottomRight", transformTip: "translate(12%, -4%)" }, { children: ["Tokens Remaining", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, { className: "column column-hotbond" })] }))] })), sortedBonds.map(function (bond) {
328
- var _a, _b, _c, _d, _e;
329
- return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bond); } }, { children: [_jsxs(Flex, __assign({ className: "column column-tokens" }, { children: [_jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bond: bond }) })), _jsx(Flex, __assign({ className: "column column-tokenicons" }, { children: _jsx(TooltipBubble, __assign({ body: _jsx(Tooltip, { tokenContract: (bond === null || bond === void 0 ? void 0 : bond.payoutToken) || '', secondURL: getBillContractURL(bond), secondURLTitle: 'View Bond Contract', thirdURL: "https://dashboard.ape.bond/bond/".concat((_a = bond === null || bond === void 0 ? void 0 : bond.billAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()), thirdURLTitle: 'View Insights', twitter: bond === null || bond === void 0 ? void 0 : bond.twitter, projectLink: bond === null || bond === void 0 ? void 0 : bond.projectLink, audit: bond === null || bond === void 0 ? void 0 : bond.audit, chain: (_b = bond.chainId) !== null && _b !== void 0 ? _b : ChainId.BSC }), width: "205px", placement: "bottomRight", transformTip: "translate(11%, 0%)" }, { children: _jsx(Svg, { icon: "more", width: "20px" }) })) }))] })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsx(Flex, __assign({ className: "column column-discount ".concat(getDiscountColor(bond === null || bond === void 0 ? void 0 : bond.discount)) }, { children: "".concat((_c = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _c === void 0 ? void 0 : _c.toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-arr" }, { children: "".concat(((((_d = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _d !== void 0 ? _d : 0) * 365) / vestingTime(bond.vestingTerm).days).toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-term" }, { children: vestingTime(bond.vestingTerm).days ? "".concat(vestingTime(bond.vestingTerm).days, " D") : '-' })), _jsx(Flex, __assign({ className: "column column-tokensremaining" }, { children: _jsx(ProgressBarWrapper, { title: '', value: _jsx(ProgressBar, { value: remainingPercentage(bond) }), style: {
330
- width: '127px',
331
- height: '25px',
332
- flexDirection: 'column',
333
- justifyContent: 'center',
334
- display: ['none', 'none', 'none', 'flex'],
335
- }, showTooltip: true, toolTip: "".concat(remainingTokensFormat(bond), " ").concat(bond.payoutTokenName, " (").concat(formatDollar({
336
- num: remainingTokensUsd(bond).toNumber(),
337
- isPrice: true,
338
- }), ")") }) })), _jsx(Flex, __assign({ className: "column column-hotbond" }, { children: _jsx(Flex, __assign({ className: "column column-icon" }, { children: hotBonds.includes(bond.billAddress.toLowerCase()) && ((_e = bond.discount) !== null && _e !== void 0 ? _e : 0) > 0 && (_jsx(Svg, { icon: "hot", width: "20px" })) })) }))] }))] }), bond.billAddress));
337
+ 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: [_jsxs(Flex, __assign({ className: "column column-tokens" }, { children: [_jsx(Flex, __assign({ className: "column column-tokenname" }, { children: "Tokens" })), _jsx(Flex, { className: "column column-tokenicons" })] })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsx(Flex, __assign({ className: "column column-discount" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Discount }), width: "230px", placement: "bottomLeft", transformTip: "translate(18%, -4%)" }, { children: ["Discount", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, __assign({ className: "column column-arr" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.ARR }), width: "230px", placement: "bottomLeft", transformTip: "translate(8%, -5%)" }, { children: ["ARR", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, __assign({ className: "column column-term" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Terms }), width: "230px", placement: "bottomRight", transformTip: "translate(11%, -5%)" }, { children: ["Terms", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, __assign({ className: "column column-tokensremaining" }, { children: _jsxs(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.TokensRemaining }), width: "230px", placement: "bottomRight", transformTip: "translate(12%, -4%)" }, { children: ["Tokens Remaining", _jsx(Flex, __assign({ className: "column header-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) }))] })) })), _jsx(Flex, { className: "column column-hotbond" })] }))] })), userOwnedBillsData.flat().map(function (data) {
338
+ return data.userOwnedBills.map(function (bill) {
339
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
340
+ return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill.bond); } }, { children: [_jsxs(Flex, __assign({ className: "column column-tokens" }, { children: [_jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bond: bill.bond }) })), _jsx(Flex, __assign({ className: "column column-tokenicons" }, { children: _jsx(TooltipBubble, __assign({ body: _jsx(Tooltip, { tokenContract: ((_a = bill.bond) === null || _a === void 0 ? void 0 : _a.payoutToken) || '', secondURL: getBillContractURL(bill.bond), secondURLTitle: 'View Bond Contract', thirdURL: "https://dashboard.ape.bond/bond/".concat((_c = (_b = bill.bond) === null || _b === void 0 ? void 0 : _b.billAddress) === null || _c === void 0 ? void 0 : _c.toLowerCase()), thirdURLTitle: 'View Insights', twitter: (_d = bill.bond) === null || _d === void 0 ? void 0 : _d.twitter, projectLink: (_e = bill.bond) === null || _e === void 0 ? void 0 : _e.projectLink, audit: (_f = bill.bond) === null || _f === void 0 ? void 0 : _f.audit, chain: (_g = bill.bond.chainId) !== null && _g !== void 0 ? _g : ChainId.BSC }), width: "205px", placement: "bottomRight", transformTip: "translate(11%, 0%)" }, { children: _jsx(Svg, { icon: "more", width: "20px" }) })) }))] })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsx(Flex, __assign({ className: "column column-discount ".concat(getDiscountColor((_h = bill.bond) === null || _h === void 0 ? void 0 : _h.discount)) }, { children: "".concat((_k = (_j = bill.bond) === null || _j === void 0 ? void 0 : _j.discount) === null || _k === void 0 ? void 0 : _k.toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-arr" }, { children: "".concat(((((_m = (_l = bill.bond) === null || _l === void 0 ? void 0 : _l.discount) !== null && _m !== void 0 ? _m : 0) * 365) / vestingTime(bill.bond.vestingTerm).days).toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-term" }, { children: vestingTime(bill.bond.vestingTerm).days ? "".concat(vestingTime(bill.bond.vestingTerm).days, " D") : '-' })), _jsx(Flex, __assign({ className: "column column-tokensremaining" }, { children: _jsx(ProgressBarWrapper, { title: '', value: _jsx(ProgressBar, { value: remainingPercentage(bill.bond) }), style: {
341
+ width: '127px',
342
+ height: '25px',
343
+ flexDirection: 'column',
344
+ justifyContent: 'center',
345
+ display: ['none', 'none', 'none', 'flex'],
346
+ }, showTooltip: true, toolTip: "".concat(remainingTokensFormat(bill.bond), " ").concat(bill.bond.payoutTokenName, " (").concat(formatDollar({
347
+ num: remainingTokensUsd(bill.bond).toNumber(),
348
+ isPrice: true,
349
+ }), ")") }) })), _jsx(Flex, __assign({ className: "column column-hotbond" }, { children: _jsx(Flex, __assign({ className: "column column-icon" }, { children: hotBonds.includes(bill.bond.billAddress.toLowerCase()) && ((_o = bill.bond.discount) !== null && _o !== void 0 ? _o : 0) > 0 && (_jsx(Svg, { icon: "hot", width: "20px" })) })) }))] }))] }), bill.bond.billAddress));
350
+ });
339
351
  })] }))] })));
340
352
  };
341
353
  export default YourBonds;
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.274",
6
+ "version": "1.0.275",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",