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

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
@@ -75436,6 +75445,7 @@ const YourBondsModalSolana = ({ billId, onDismiss }) => {
75436
75445
  const UserBondRowSolana = ({ bill }) => {
75437
75446
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
75438
75447
  // Hooks
75448
+ const SDKConfig = useSDKConfig();
75439
75449
  const { setVisible } = useWalletModal();
75440
75450
  const { publicKey: accountSolana, signTransaction } = useSOLAccount();
75441
75451
  const { addToastError, addToastSuccess } = usePopups();
@@ -75481,7 +75491,7 @@ const UserBondRowSolana = ({ bill }) => {
75481
75491
  return userPayoutAta;
75482
75492
  });
75483
75493
  const handleClaim = () => __awaiter$9(void 0, void 0, void 0, function* () {
75484
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
75494
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
75485
75495
  try {
75486
75496
  setLoadingTx(true);
75487
75497
  const earnTokenAddress = (_c = (_b = (_a = bill === null || bill === void 0 ? void 0 : bill.bond) === null || _a === void 0 ? void 0 : _a.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[(_d = bill === null || bill === void 0 ? void 0 : bill.bond) === null || _d === void 0 ? void 0 : _d.chainId];
@@ -75549,6 +75559,11 @@ const UserBondRowSolana = ({ bill }) => {
75549
75559
  catch (error) {
75550
75560
  console.error('Claim failed:', error);
75551
75561
  addToastError((_k = error === null || error === void 0 ? void 0 : error.message) !== null && _k !== void 0 ? _k : 'Unknown error');
75562
+ reportError({
75563
+ apiUrl: (_l = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _l === void 0 ? void 0 : _l.apiV2,
75564
+ error,
75565
+ extraInfo: { type: 'claim', bill, error },
75566
+ });
75552
75567
  }
75553
75568
  finally {
75554
75569
  setLoadingTx(false);
@@ -81278,19 +81293,16 @@ const calculateBondsData = (queryClient) => __awaiter$9(void 0, void 0, void 0,
81278
81293
  }, {});
81279
81294
  try {
81280
81295
  // First, we try to fetch from realtime API
81281
- console.time('BondsData');
81282
81296
  const [solBonds, evmResponse] = yield Promise.all([
81283
81297
  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
81298
  yield axios.get(`${realTimeApiURL}/bonds`),
81285
81299
  ]);
81286
- console.timeEnd('BondsData');
81287
81300
  return [...solBonds, ...evmResponse.data.bonds];
81288
81301
  }
81289
81302
  catch (_a) {
81290
81303
  // If realtime fails, we trigger the fallback strategy on the client
81291
- console.timeEnd('BondsData');
81292
- console.time('Fallback BondsData');
81293
81304
  if (bondList) {
81305
+ console.time('Fallback BondsData');
81294
81306
  const billData = yield Promise.all([
81295
81307
  ...chains.map((chainId) => __awaiter$9(void 0, void 0, void 0, function* () {
81296
81308
  var _a;
@@ -81307,7 +81319,6 @@ const calculateBondsData = (queryClient) => __awaiter$9(void 0, void 0, void 0,
81307
81319
  console.timeEnd('Fallback BondsData');
81308
81320
  return billData.flat();
81309
81321
  }
81310
- console.timeEnd('Fallback BondsData');
81311
81322
  return [];
81312
81323
  }
81313
81324
  });
@@ -85106,7 +85117,7 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
85106
85117
  setInputTokenString(newInputToken);
85107
85118
  }, []);
85108
85119
  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;
85120
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
85110
85121
  if (!accountSolana || !bondData || !inputValue || !inputToken || !bondData)
85111
85122
  return;
85112
85123
  track({
@@ -85197,44 +85208,49 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
85197
85208
  // Sign tx
85198
85209
  transaction.partialSign(nftMint);
85199
85210
  const signedTx = yield (signTransaction === null || signTransaction === void 0 ? void 0 : signTransaction(transaction));
85200
- // Send tx
85211
+ // Sends tx, generates hash
85201
85212
  const txId = yield connection.sendRawTransaction(signedTx.serialize(), {
85202
85213
  skipPreflight: false,
85203
85214
  preflightCommitment: 'confirmed',
85204
85215
  });
85216
+ // awaits hash confirmation on chain - commitment "confirmed"
85205
85217
  yield connection.confirmTransaction({
85206
85218
  signature: txId,
85207
85219
  blockhash,
85208
85220
  lastValidBlockHeight,
85209
85221
  }, '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
- }
85222
+ console.log('tx confirmed');
85223
+ // axios
85224
+ // .post(`${SDKConfig?.urls?.apiV2}/bills/solana/ingest`, {
85225
+ // signature: txId,
85226
+ // })
85227
+ // .catch((e) => {
85228
+ // console.error(e)
85229
+ // })
85230
+ track({
85231
+ event: 'bond',
85232
+ chain: bondChain,
85233
+ data: {
85234
+ cat: 'lp-buy',
85235
+ type: (_d = bondData === null || bondData === void 0 ? void 0 : bondData.billType) !== null && _d !== void 0 ? _d : '',
85236
+ typedValue: inputValue,
85237
+ principalToken: (_e = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken.symbol) !== null && _e !== void 0 ? _e : '',
85238
+ earnToken: (_f = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken.symbol) !== null && _f !== void 0 ? _f : '',
85239
+ address: remove0xPrefix((_g = bondData === null || bondData === void 0 ? void 0 : bondData.contractAddress) === null || _g === void 0 ? void 0 : _g[bondData.chainId]),
85240
+ usdAmount: parseFloat(inputValue) * ((_h = inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price) !== null && _h !== void 0 ? _h : 0),
85241
+ },
85242
+ });
85243
+ // waits 3 seconds before triggering after-purchase flow
85244
+ yield new Promise((resolve) => setTimeout(resolve, 3000));
85245
+ console.timeEnd('3 seconds elapsed. trigger bonds refetch');
85246
+ addToastSuccess(txId, bondChain);
85247
+ setBillId === null || setBillId === void 0 ? void 0 : setBillId(nftMint.publicKey.toString());
85232
85248
  }
85233
85249
  catch (error) {
85234
85250
  console.error('Error during bond purchase:', error);
85235
85251
  addToastError((error === null || error === void 0 ? void 0 : error.message) || 'Unknown error');
85236
85252
  reportError$1({
85237
- apiUrl: (_m = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _m === void 0 ? void 0 : _m.apiV2,
85253
+ apiUrl: (_j = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _j === void 0 ? void 0 : _j.apiV2,
85238
85254
  error: error.message,
85239
85255
  extraInfo: { type: 'solanaBuyBond', error: error.message },
85240
85256
  chainId: bondChain,
@@ -85310,7 +85326,7 @@ const ModalHandler = ({ onDismiss, bondAddress, bondChain, }) => {
85310
85326
  const [buyTxHash, setBuyTxHash] = useState('');
85311
85327
  // Hooks
85312
85328
  const { data: bondsData } = useBondsData();
85313
- const { refetch } = useUserBonds();
85329
+ const { refetch } = useUserBonds(true);
85314
85330
  const locationPath = window.location.pathname;
85315
85331
  const { data: txReceipt } = useMonitorTx(buyTxHash, bondChain);
85316
85332
  // EVM - Look for billId on tx logs
@@ -86202,7 +86218,7 @@ const Bonds = () => {
86202
86218
  useHotBonds();
86203
86219
  const { favTokens } = useFavoriteTokens();
86204
86220
  const { data: bondData, refetch } = useBondsData();
86205
- useUserBonds();
86221
+ // useUserBonds()
86206
86222
  const { data: allBonds } = useBondsList();
86207
86223
  const { data: allPreBonds } = useBondsListPreTGE();
86208
86224
  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.12",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",