@ape.swap/bonds-sdk 4.1.0-test.10 → 4.1.0-test.11

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/main.js CHANGED
@@ -65216,9 +65216,7 @@ function useTokenPrices() {
65216
65216
  return useQuery({
65217
65217
  queryKey: [QUERY_KEYS.TOKEN_PRICES],
65218
65218
  queryFn: () => __awaiter$9(this, void 0, void 0, function* () {
65219
- console.time('PriceGetter');
65220
65219
  const prices = yield getTokenPrices(priceApi, apiv2);
65221
- console.timeEnd('PriceGetter');
65222
65220
  return prices;
65223
65221
  }),
65224
65222
  refetchInterval: 30000, // 30 sec
@@ -65484,7 +65482,8 @@ function fetchUserOwnedSolanaBonds(user, bondData, tokenPrices) {
65484
65482
  if (!user)
65485
65483
  return [];
65486
65484
  try {
65487
- console.log('fetching SOL bonds');
65485
+ console.log('fetch-SOL-bonds');
65486
+ console.time('fetch-SOL-bonds');
65488
65487
  const results = [];
65489
65488
  const userBase58 = new PublicKey(user).toBase58();
65490
65489
  const connection = new Connection(getRPC(types$1.ChainId.SOL), 'confirmed');
@@ -65564,7 +65563,7 @@ function fetchUserOwnedSolanaBonds(user, bondData, tokenPrices) {
65564
65563
  userOwnedBills: userBills,
65565
65564
  });
65566
65565
  }
65567
- console.log('finished fetching solana bonds');
65566
+ console.timeEnd('fetch-SOL-bonds');
65568
65567
  return results;
65569
65568
  }
65570
65569
  catch (err) {
@@ -65634,7 +65633,7 @@ const useSOLAccount = () => {
65634
65633
  return Object.assign(Object.assign({}, account), { publicKey: solAddress ? solPublicKey : account.publicKey });
65635
65634
  };
65636
65635
 
65637
- function useUserBonds() {
65636
+ function useUserBonds(dontFetch) {
65638
65637
  var _a, _b, _c;
65639
65638
  // First fetch the full list of bonds
65640
65639
  const { data: bondList } = useBondsList();
@@ -65650,7 +65649,7 @@ function useUserBonds() {
65650
65649
  queryKey: [QUERY_KEYS.USER_BONDS, address, publicKey, (_c = (_b = Object.keys(tokenPrices !== null && tokenPrices !== void 0 ? tokenPrices : {})) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : null],
65651
65650
  queryFn: () => getUserBonds(address, solanaAccount, bondList, chains, tokenPrices, apiUrl),
65652
65651
  refetchInterval: 120000, // TODO rollback this
65653
- enabled: !!bondList && !!(address || solanaAccount) && !!tokenPrices,
65652
+ enabled: !!bondList && !!(address || solanaAccount) && !!tokenPrices && !dontFetch,
65654
65653
  refetchOnWindowFocus: false,
65655
65654
  refetchOnMount: false,
65656
65655
  refetchOnReconnect: false,
@@ -65708,7 +65707,17 @@ const getUserBonds = (account, solanaAccount, bondList, chains, tokenPrices, api
65708
65707
  acc[key].billIds.push(parseInt(data.id));
65709
65708
  return acc;
65710
65709
  }, {}));
65711
- const response = yield axios.post(`${apiUrl}/bills/multi-batch`, body);
65710
+ let response;
65711
+ try {
65712
+ response = yield axios.post(`${apiUrl}/bills/multi-batch`, body);
65713
+ }
65714
+ catch (e) {
65715
+ console.error(e);
65716
+ console.log('multibatch failed, using only on-chain data');
65717
+ console.timeEnd('getUserBonds');
65718
+ return onChainData;
65719
+ }
65720
+ console.log('multibatch success');
65712
65721
  // Enrich on-chain data with API data
65713
65722
  const enrichedData = onChainData.map((userBond) => {
65714
65723
  var _a, _b;
@@ -75264,7 +75273,7 @@ const UserBondRow = ({ bill }) => {
75264
75273
  };
75265
75274
 
75266
75275
  const YourBondsModalSolana = ({ billId, onDismiss }) => {
75267
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
75276
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
75268
75277
  // Hooks
75269
75278
  const SDKConfig = useSDKConfig();
75270
75279
  const { publicKey: accountSolana, signTransaction } = useSOLAccount();
@@ -75396,36 +75405,36 @@ const YourBondsModalSolana = ({ billId, onDismiss }) => {
75396
75405
  setImgLoaded(true);
75397
75406
  };
75398
75407
  const [onTransferBondModal] = useModal(jsx$2(TransferBondModal, { userBill: userBill }), true, true, `transferModal${userBill === null || userBill === void 0 ? void 0 : userBill.id}}`);
75399
- return (jsx$2(Modal, { className: "modal", children: jsxs(Flex$1, { className: "yourbondsmodal-content", children: [jsx$2(Flex$1, { className: "yourbondsmodal-header", children: jsx$2(Flex$1, { className: "svg-close", onClick: onDismiss, children: jsx$2(Svg, { icon: "close" }) }) }), jsxs(Flex$1, { className: "yourbondsmodal table-container", children: [jsxs(Flex$1, { className: "yourbondsmodal bondimage", children: [(bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.image) && (jsx$2("img", { src: `${bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.image}?img-width=720`, onLoad: handleImageLoad, alt: "solana-NFT", style: { zIndex: 2, width: '100%', height: '100%' } })), !imgLoaded && (jsx$2(Flex$1, { sx: {
75408
+ return (jsx$2(Modal, { className: "modal", children: jsxs(Flex$1, { className: "yourbondsmodal-content", children: [jsx$2(Flex$1, { className: "yourbondsmodal-header", children: jsx$2(Flex$1, { className: "svg-close", onClick: onDismiss, children: jsx$2(Svg, { icon: "close" }) }) }), jsxs(Flex$1, { className: "yourbondsmodal table-container", children: [jsxs(Flex$1, { className: "yourbondsmodal bondimage", children: [(bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.image) ? (jsx$2("img", { src: `${bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.image}?img-width=720`, onLoad: handleImageLoad, alt: "solana-NFT", style: { zIndex: 2, width: '100%', height: '100%' } })) : (userBill && (jsx$2("img", { src: `https://ape.bond/solBonds/${(_e = (_d = (_c = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _c === void 0 ? void 0 : _c.earnToken) === null || _d === void 0 ? void 0 : _d.symbol) === null || _e === void 0 ? void 0 : _e.toLowerCase()}.png`, alt: "Solana Bonds Banner", onLoad: handleImageLoad, style: { zIndex: 2, width: '100%', height: '100%' } }))), (!imgLoaded || !userBill) && (jsx$2(Flex$1, { sx: {
75400
75409
  position: 'absolute',
75401
75410
  top: 'calc(50% - 24px)',
75402
75411
  right: 'calc(50% - 50px)',
75403
75412
  justifyContent: 'center',
75404
75413
  alignItems: 'center',
75405
75414
  zIndex: 1,
75406
- }, children: jsx$2(Spinner, { width: 100 }) }))] }), jsxs(Flex$1, { className: "yourbondsmodal yourbondinfo", children: [jsxs(Flex$1, { className: "yourbondinfo title-container", children: [jsx$2(Flex$1, { className: "title-container bondicon", children: userBill && (jsx$2(TokenImage, { symbol: (_d = (_c = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _c === void 0 ? void 0 : _c.showcaseTokenName) !== null && _d !== void 0 ? _d : (_f = (_e = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _e === void 0 ? void 0 : _e.earnToken) === null || _f === void 0 ? void 0 : _f.symbol, size: 40, chain: (_g = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _g === void 0 ? void 0 : _g.chainId })) }), jsx$2(Flex$1, { className: "title-container tokenname", children: (_j = (_h = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _h === void 0 ? void 0 : _h.showcaseTokenName) !== null && _j !== void 0 ? _j : (_k = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _k === void 0 ? void 0 : _k.earnToken.symbol }), jsx$2(Flex$1, { className: "title-container tokentags", children: (_m = (_l = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _l === void 0 ? void 0 : _l.tags) === null || _m === void 0 ? void 0 : _m.slice(0, 1).map((tag) => {
75415
+ }, children: jsx$2(Spinner, { width: 100 }) }))] }), jsxs(Flex$1, { className: "yourbondsmodal yourbondinfo", children: [jsxs(Flex$1, { className: "yourbondinfo title-container", children: [jsx$2(Flex$1, { className: "title-container bondicon", children: userBill && (jsx$2(TokenImage, { symbol: (_g = (_f = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _f === void 0 ? void 0 : _f.showcaseTokenName) !== null && _g !== void 0 ? _g : (_j = (_h = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _h === void 0 ? void 0 : _h.earnToken) === null || _j === void 0 ? void 0 : _j.symbol, size: 40, chain: (_k = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _k === void 0 ? void 0 : _k.chainId })) }), jsx$2(Flex$1, { className: "title-container tokenname", children: (_m = (_l = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _l === void 0 ? void 0 : _l.showcaseTokenName) !== null && _m !== void 0 ? _m : (_o = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _o === void 0 ? void 0 : _o.earnToken.symbol }), jsx$2(Flex$1, { className: "title-container tokentags", children: (_q = (_p = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _p === void 0 ? void 0 : _p.tags) === null || _q === void 0 ? void 0 : _q.slice(0, 1).map((tag) => {
75407
75416
  return (jsx$2(Flex$1, { sx: { marginRight: '10px' }, children: jsx$2(ListTag, { text: tag === null || tag === void 0 ? void 0 : tag.toUpperCase() }) }, tag));
75408
- }) }), jsxs(Text, { sx: { color: 'text', opacity: '0.6', fontSize: ['12px', '12px', '12px', '16px'] }, children: ["ID # ", userBill === null || userBill === void 0 ? void 0 : userBill.id] })] }), jsxs(Flex$1, { className: "yourbondinfo blocks-container", children: [((_o = bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.data) === null || _o === void 0 ? void 0 : _o.deposit) && (jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "You Spent" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.YouSpent }), width: "270px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsx$2(Flex$1, { className: "yourbondinfo-block info", children: jsx$2(Flex$1, { className: "block-info text", children: jsxs(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: ["$", (_p = bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.data) === null || _p === void 0 ? void 0 : _p.dollarValue.toFixed(2)] }) }) })] })), jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Fully Vested" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.FullyVested }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon" }), jsx$2(Flex$1, { className: "block-info text", children: jsxs(Flex$1, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: [vestingTimeRemainingString(userBill), isPendingCliff && (jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsxs(Flex$1, { children: ["Bond will be claimable in", ' ', `${cliffCountdown.days !== 0 ? `${cliffCountdown.days} days` : cliffCountdown.hours !== 0 ? `${cliffCountdown.hours} hours` : `${cliffCountdown.minutes} mins`}`, "."] }), width: "180px", placement: "bottomRight", transformTip: "translate(13%, 0%)", children: jsx$2(Flex$1, { sx: { opacity: 0.6, ml: '6px' }, children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }))] }) })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-pending", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Pending" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Pending }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_r = (_q = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _q === void 0 ? void 0 : _q.showcaseTokenName) !== null && _r !== void 0 ? _r : (_t = (_s = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _s === void 0 ? void 0 : _s.earnToken) === null || _t === void 0 ? void 0 : _t.symbol, size: 25, chain: (_u = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _u === void 0 ? void 0 : _u.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(pending(userBill), 4) }), jsx$2(Text, { sx: {
75417
+ }) }), jsxs(Text, { sx: { color: 'text', opacity: '0.6', fontSize: ['12px', '12px', '12px', '16px'] }, children: ["ID # ", userBill === null || userBill === void 0 ? void 0 : userBill.id] })] }), jsxs(Flex$1, { className: "yourbondinfo blocks-container", children: [((_r = bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.data) === null || _r === void 0 ? void 0 : _r.deposit) && (jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "You Spent" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.YouSpent }), width: "270px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsx$2(Flex$1, { className: "yourbondinfo-block info", children: jsx$2(Flex$1, { className: "block-info text", children: jsxs(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: ["$", (_s = bondNFTData === null || bondNFTData === void 0 ? void 0 : bondNFTData.data) === null || _s === void 0 ? void 0 : _s.dollarValue.toFixed(2)] }) }) })] })), jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Fully Vested" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.FullyVested }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon" }), jsx$2(Flex$1, { className: "block-info text", children: jsxs(Flex$1, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: [vestingTimeRemainingString(userBill), isPendingCliff && (jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsxs(Flex$1, { children: ["Bond will be claimable in", ' ', `${cliffCountdown.days !== 0 ? `${cliffCountdown.days} days` : cliffCountdown.hours !== 0 ? `${cliffCountdown.hours} hours` : `${cliffCountdown.minutes} mins`}`, "."] }), width: "180px", placement: "bottomRight", transformTip: "translate(13%, 0%)", children: jsx$2(Flex$1, { sx: { opacity: 0.6, ml: '6px' }, children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }))] }) })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-pending", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Pending" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Pending }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_u = (_t = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _t === void 0 ? void 0 : _t.showcaseTokenName) !== null && _u !== void 0 ? _u : (_w = (_v = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _v === void 0 ? void 0 : _v.earnToken) === null || _w === void 0 ? void 0 : _w.symbol, size: 25, chain: (_x = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _x === void 0 ? void 0 : _x.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(pending(userBill), 4) }), jsx$2(Text, { sx: {
75409
75418
  fontSize: ['10px', '10px', '10px', '12px'],
75410
75419
  fontWeight: [500, 500, 500, 400],
75411
75420
  paddingLeft: '10px',
75412
- }, children: `($${pendingUSD(userBill).toFixed(2)})` })] })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-claimable", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Claimable" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Claimable }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_w = (_v = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _v === void 0 ? void 0 : _v.showcaseTokenName) !== null && _w !== void 0 ? _w : (_y = (_x = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _x === void 0 ? void 0 : _x.earnToken) === null || _y === void 0 ? void 0 : _y.symbol, size: 25, chain: (_z = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _z === void 0 ? void 0 : _z.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(claimable(userBill), 4) }), jsx$2(Text, { sx: {
75421
+ }, children: `($${pendingUSD(userBill).toFixed(2)})` })] })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-claimable", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Claimable" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Claimable }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_z = (_y = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _y === void 0 ? void 0 : _y.showcaseTokenName) !== null && _z !== void 0 ? _z : (_1 = (_0 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _0 === void 0 ? void 0 : _0.earnToken) === null || _1 === void 0 ? void 0 : _1.symbol, size: 25, chain: (_2 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _2 === void 0 ? void 0 : _2.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(claimable(userBill), 4) }), jsx$2(Text, { sx: {
75413
75422
  fontSize: ['10px', '10px', '10px', '12px'],
75414
75423
  fontWeight: [500, 500, 500, 400],
75415
75424
  paddingLeft: '10px',
75416
- }, children: `($${claimableUSD(userBill).toFixed(2)})` })] })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Claimed" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Claimed }), width: "250px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_1 = (_0 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _0 === void 0 ? void 0 : _0.showcaseTokenName) !== null && _1 !== void 0 ? _1 : (_3 = (_2 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _2 === void 0 ? void 0 : _2.earnToken) === null || _3 === void 0 ? void 0 : _3.symbol, size: 25, chain: (_4 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _4 === void 0 ? void 0 : _4.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(claimed(userBill), 4) }), jsx$2(Text, { sx: {
75425
+ }, children: `($${claimableUSD(userBill).toFixed(2)})` })] })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Claimed" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Claimed }), width: "250px", placement: "bottomLeft", transformTip: "translate(-5%, 0%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_4 = (_3 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _3 === void 0 ? void 0 : _3.showcaseTokenName) !== null && _4 !== void 0 ? _4 : (_6 = (_5 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _5 === void 0 ? void 0 : _5.earnToken) === null || _6 === void 0 ? void 0 : _6.symbol, size: 25, chain: (_7 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _7 === void 0 ? void 0 : _7.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(claimed(userBill), 4) }), jsx$2(Text, { sx: {
75417
75426
  fontSize: ['10px', '10px', '10px', '12px'],
75418
75427
  fontWeight: [500, 500, 500, 400],
75419
75428
  paddingLeft: '10px',
75420
- }, children: `($${claimedUSD(userBill).toFixed(2)})` })] })] })] })] }), ((_5 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _5 === void 0 ? void 0 : _5.warningCard) && (jsx$2(Flex$1, { sx: {
75429
+ }, children: `($${claimedUSD(userBill).toFixed(2)})` })] })] })] })] }), ((_8 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _8 === void 0 ? void 0 : _8.warningCard) && (jsx$2(Flex$1, { sx: {
75421
75430
  width: '100%',
75422
75431
  background: '#DE62F366',
75423
75432
  justifyContent: 'center',
75424
75433
  borderRadius: 'normal',
75425
- }, children: jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, p: '2px 10px' }, children: jsx$2(SafeHTMLComponent, { html: (_6 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _6 === void 0 ? void 0 : _6.warningCard }) }) })), jsxs(Flex$1, { className: "yourbondinfo button-container", children: [jsx$2(Flex$1, { className: "button-container claim", children: userBill && !accountSolana ? (jsxs(Button, { className: "switch-button", disabled: claimable(userBill) === 0 || loadingTx, onClick: (event) => {
75434
+ }, children: jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, p: '2px 10px' }, children: jsx$2(SafeHTMLComponent, { html: (_9 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _9 === void 0 ? void 0 : _9.warningCard }) }) })), jsxs(Flex$1, { className: "yourbondinfo button-container", children: [jsx$2(Flex$1, { className: "button-container claim", children: userBill && !accountSolana ? (jsxs(Button, { className: "switch-button", disabled: claimable(userBill) === 0 || loadingTx, onClick: (event) => {
75426
75435
  event.stopPropagation();
75427
75436
  setVisible(true);
75428
- }, children: ["Switch to ", NETWORK_LABEL[(_7 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _7 === void 0 ? void 0 : _7.chainId]] })) : (jsx$2(Button, { className: "claim-button", disabled: claimable(userBill) === 0 || loadingTx || !userBill || isPendingCliff, load: loadingTx, onClick: (event) => {
75437
+ }, children: ["Switch to ", NETWORK_LABEL[(_10 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _10 === void 0 ? void 0 : _10.chainId]] })) : (jsx$2(Button, { className: "claim-button", disabled: claimable(userBill) === 0 || loadingTx || !userBill || isPendingCliff, load: loadingTx, onClick: (event) => {
75429
75438
  event.stopPropagation();
75430
75439
  handleClaim();
75431
75440
  }, children: isPendingCliff
@@ -81278,19 +81287,16 @@ const calculateBondsData = (queryClient) => __awaiter$9(void 0, void 0, void 0,
81278
81287
  }, {});
81279
81288
  try {
81280
81289
  // First, we try to fetch from realtime API
81281
- console.time('BondsData');
81282
81290
  const [solBonds, evmResponse] = yield Promise.all([
81283
81291
  yield fetchBondsData(types$1.ChainId.SOL, reducedBonds[types$1.ChainId.SOL], apiUrl, tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[types$1.ChainId.SOL]),
81284
81292
  yield axios.get(`${realTimeApiURL}/bonds`),
81285
81293
  ]);
81286
- console.timeEnd('BondsData');
81287
81294
  return [...solBonds, ...evmResponse.data.bonds];
81288
81295
  }
81289
81296
  catch (_a) {
81290
81297
  // If realtime fails, we trigger the fallback strategy on the client
81291
- console.timeEnd('BondsData');
81292
- console.time('Fallback BondsData');
81293
81298
  if (bondList) {
81299
+ console.time('Fallback BondsData');
81294
81300
  const billData = yield Promise.all([
81295
81301
  ...chains.map((chainId) => __awaiter$9(void 0, void 0, void 0, function* () {
81296
81302
  var _a;
@@ -81307,7 +81313,6 @@ const calculateBondsData = (queryClient) => __awaiter$9(void 0, void 0, void 0,
81307
81313
  console.timeEnd('Fallback BondsData');
81308
81314
  return billData.flat();
81309
81315
  }
81310
- console.timeEnd('Fallback BondsData');
81311
81316
  return [];
81312
81317
  }
81313
81318
  });
@@ -85106,7 +85111,7 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
85106
85111
  setInputTokenString(newInputToken);
85107
85112
  }, []);
85108
85113
  const handleBuyCallback = () => __awaiter$9(void 0, void 0, void 0, function* () {
85109
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
85114
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
85110
85115
  if (!accountSolana || !bondData || !inputValue || !inputToken || !bondData)
85111
85116
  return;
85112
85117
  track({
@@ -85197,44 +85202,49 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
85197
85202
  // Sign tx
85198
85203
  transaction.partialSign(nftMint);
85199
85204
  const signedTx = yield (signTransaction === null || signTransaction === void 0 ? void 0 : signTransaction(transaction));
85200
- // Send tx
85205
+ // Sends tx, generates hash
85201
85206
  const txId = yield connection.sendRawTransaction(signedTx.serialize(), {
85202
85207
  skipPreflight: false,
85203
85208
  preflightCommitment: 'confirmed',
85204
85209
  });
85210
+ // awaits hash confirmation on chain - commitment "confirmed"
85205
85211
  yield connection.confirmTransaction({
85206
85212
  signature: txId,
85207
85213
  blockhash,
85208
85214
  lastValidBlockHeight,
85209
85215
  }, 'confirmed');
85210
- const txStatus = yield connection.getSignatureStatus(txId, { searchTransactionHistory: true });
85211
- if (((_d = txStatus === null || txStatus === void 0 ? void 0 : txStatus.value) === null || _d === void 0 ? void 0 : _d.confirmationStatus) === 'confirmed' || ((_e = txStatus === null || txStatus === void 0 ? void 0 : txStatus.value) === null || _e === void 0 ? void 0 : _e.confirmationStatus) === 'finalized') {
85212
- console.log('success!');
85213
- addToastSuccess(txId, bondChain);
85214
- setBillId === null || setBillId === void 0 ? void 0 : setBillId(nftMint.publicKey.toString());
85215
- axios.post(`${(_f = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _f === void 0 ? void 0 : _f.apiV2}/bills/solana/ingest`, {
85216
- signature: txId,
85217
- });
85218
- track({
85219
- event: 'bond',
85220
- chain: bondChain,
85221
- data: {
85222
- cat: 'lp-buy',
85223
- type: (_g = bondData === null || bondData === void 0 ? void 0 : bondData.billType) !== null && _g !== void 0 ? _g : '',
85224
- typedValue: inputValue,
85225
- principalToken: (_h = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken.symbol) !== null && _h !== void 0 ? _h : '',
85226
- earnToken: (_j = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken.symbol) !== null && _j !== void 0 ? _j : '',
85227
- address: remove0xPrefix((_k = bondData === null || bondData === void 0 ? void 0 : bondData.contractAddress) === null || _k === void 0 ? void 0 : _k[bondData.chainId]),
85228
- usdAmount: parseFloat(inputValue) * ((_l = inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price) !== null && _l !== void 0 ? _l : 0),
85229
- },
85230
- });
85231
- }
85216
+ axios
85217
+ .post(`${(_d = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _d === void 0 ? void 0 : _d.apiV2}/bills/solana/ingest`, {
85218
+ signature: txId,
85219
+ })
85220
+ .catch((e) => {
85221
+ console.error(e);
85222
+ });
85223
+ track({
85224
+ event: 'bond',
85225
+ chain: bondChain,
85226
+ data: {
85227
+ cat: 'lp-buy',
85228
+ type: (_e = bondData === null || bondData === void 0 ? void 0 : bondData.billType) !== null && _e !== void 0 ? _e : '',
85229
+ typedValue: inputValue,
85230
+ principalToken: (_f = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken.symbol) !== null && _f !== void 0 ? _f : '',
85231
+ earnToken: (_g = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken.symbol) !== null && _g !== void 0 ? _g : '',
85232
+ address: remove0xPrefix((_h = bondData === null || bondData === void 0 ? void 0 : bondData.contractAddress) === null || _h === void 0 ? void 0 : _h[bondData.chainId]),
85233
+ usdAmount: parseFloat(inputValue) * ((_j = inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price) !== null && _j !== void 0 ? _j : 0),
85234
+ },
85235
+ });
85236
+ console.time('asd');
85237
+ // waits 3 seconds before triggering after-purchase flow
85238
+ yield new Promise((resolve) => setTimeout(resolve, 3000));
85239
+ console.timeEnd('asd');
85240
+ addToastSuccess(txId, bondChain);
85241
+ setBillId === null || setBillId === void 0 ? void 0 : setBillId(nftMint.publicKey.toString());
85232
85242
  }
85233
85243
  catch (error) {
85234
85244
  console.error('Error during bond purchase:', error);
85235
85245
  addToastError((error === null || error === void 0 ? void 0 : error.message) || 'Unknown error');
85236
85246
  reportError$1({
85237
- apiUrl: (_m = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _m === void 0 ? void 0 : _m.apiV2,
85247
+ apiUrl: (_k = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _k === void 0 ? void 0 : _k.apiV2,
85238
85248
  error: error.message,
85239
85249
  extraInfo: { type: 'solanaBuyBond', error: error.message },
85240
85250
  chainId: bondChain,
@@ -85310,7 +85320,7 @@ const ModalHandler = ({ onDismiss, bondAddress, bondChain, }) => {
85310
85320
  const [buyTxHash, setBuyTxHash] = useState('');
85311
85321
  // Hooks
85312
85322
  const { data: bondsData } = useBondsData();
85313
- const { refetch } = useUserBonds();
85323
+ const { refetch } = useUserBonds(true);
85314
85324
  const locationPath = window.location.pathname;
85315
85325
  const { data: txReceipt } = useMonitorTx(buyTxHash, bondChain);
85316
85326
  // EVM - Look for billId on tx logs
@@ -86202,7 +86212,7 @@ const Bonds = () => {
86202
86212
  useHotBonds();
86203
86213
  const { favTokens } = useFavoriteTokens();
86204
86214
  const { data: bondData, refetch } = useBondsData();
86205
- useUserBonds();
86215
+ // useUserBonds()
86206
86216
  const { data: allBonds } = useBondsList();
86207
86217
  const { data: allPreBonds } = useBondsListPreTGE();
86208
86218
  const { data: chainFilterOption, setChainFilterOption } = useChainFilterOption();
@@ -2,5 +2,5 @@ import { UseQueryResult } from '@tanstack/react-query';
2
2
  import { BillsConfig, ChainId } from '@ape.swap/apeswap-lists';
3
3
  import { UserBill } from '../../types/yourbonds';
4
4
  import { TokenPrices } from '../tokenPrices/useTokenPrices';
5
- export default function useUserBonds(): UseQueryResult<UserBill[]>;
5
+ export default function useUserBonds(dontFetch?: boolean): UseQueryResult<UserBill[]>;
6
6
  export declare const getUserBonds: (account: string, solanaAccount: string, bondList: BillsConfig[], chains: number[], tokenPrices: Partial<Record<ChainId, TokenPrices[]>>, apiUrl?: string) => Promise<UserBill[]>;
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": "4.1.0-test.10",
6
+ "version": "4.1.0-test.11",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",