@ape.swap/bonds-sdk 4.2.2-test.0 → 4.2.3-test.0

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.
Files changed (58) hide show
  1. package/dist/main.js +87 -56
  2. package/dist/state/bonds/useBondsList.d.ts +2 -2
  3. package/dist/state/useSDKConfig.d.ts +2 -0
  4. package/dist/types/yourbonds.d.ts +1 -0
  5. package/package.json +1 -1
  6. package/dist/config/abi/types/Banana.d.ts +0 -394
  7. package/dist/config/abi/types/Bond.d.ts +0 -758
  8. package/dist/config/abi/types/BondNft.d.ts +0 -556
  9. package/dist/config/abi/types/EnsPublicResolver.d.ts +0 -437
  10. package/dist/config/abi/types/EnsRegistrar.d.ts +0 -254
  11. package/dist/config/abi/types/Erc20.d.ts +0 -156
  12. package/dist/config/abi/types/Erc20_bytes32.d.ts +0 -50
  13. package/dist/config/abi/types/JungleChef.d.ts +0 -245
  14. package/dist/config/abi/types/LaunchBonds.d.ts +0 -1306
  15. package/dist/config/abi/types/LensContract.d.ts +0 -276
  16. package/dist/config/abi/types/LockVeAbond.d.ts +0 -1173
  17. package/dist/config/abi/types/MigrationBond.d.ts +0 -1074
  18. package/dist/config/abi/types/MigrationFveAbond.d.ts +0 -284
  19. package/dist/config/abi/types/MiniComplexRewarder.d.ts +0 -423
  20. package/dist/config/abi/types/Multicallv2.d.ts +0 -139
  21. package/dist/config/abi/types/Multicallv3.d.ts +0 -98
  22. package/dist/config/abi/types/NonFungibleApes.d.ts +0 -492
  23. package/dist/config/abi/types/NonFungibleBananas.d.ts +0 -468
  24. package/dist/config/abi/types/PriceGetter.d.ts +0 -676
  25. package/dist/config/abi/types/PriceGetterLinea.d.ts +0 -756
  26. package/dist/config/abi/types/PriceGetterV2.d.ts +0 -692
  27. package/dist/config/abi/types/SousChef.d.ts +0 -542
  28. package/dist/config/abi/types/Treasury.d.ts +0 -274
  29. package/dist/config/abi/types/Weth.d.ts +0 -206
  30. package/dist/config/abi/types/Zap.d.ts +0 -484
  31. package/dist/config/abi/types/common.d.ts +0 -22
  32. package/dist/config/abi/types/factories/Banana__factory.d.ts +0 -475
  33. package/dist/config/abi/types/factories/BondNft__factory.d.ts +0 -723
  34. package/dist/config/abi/types/factories/Bond__factory.d.ts +0 -799
  35. package/dist/config/abi/types/factories/EnsPublicResolver__factory.d.ts +0 -649
  36. package/dist/config/abi/types/factories/EnsRegistrar__factory.d.ts +0 -338
  37. package/dist/config/abi/types/factories/Erc20__factory.d.ts +0 -175
  38. package/dist/config/abi/types/factories/Erc20_bytes32__factory.d.ts +0 -30
  39. package/dist/config/abi/types/factories/JungleChef__factory.d.ts +0 -247
  40. package/dist/config/abi/types/factories/LaunchBonds__factory.d.ts +0 -1560
  41. package/dist/config/abi/types/factories/LensContract__factory.d.ts +0 -254
  42. package/dist/config/abi/types/factories/LockVeAbond__factory.d.ts +0 -1698
  43. package/dist/config/abi/types/factories/MigrationBond__factory.d.ts +0 -1268
  44. package/dist/config/abi/types/factories/MigrationFveAbond__factory.d.ts +0 -262
  45. package/dist/config/abi/types/factories/MiniComplexRewarder__factory.d.ts +0 -448
  46. package/dist/config/abi/types/factories/Multicallv2__factory.d.ts +0 -115
  47. package/dist/config/abi/types/factories/Multicallv3__factory.d.ts +0 -76
  48. package/dist/config/abi/types/factories/NonFungibleApes__factory.d.ts +0 -617
  49. package/dist/config/abi/types/factories/NonFungibleBananas__factory.d.ts +0 -576
  50. package/dist/config/abi/types/factories/PriceGetterLinea__factory.d.ts +0 -1105
  51. package/dist/config/abi/types/factories/PriceGetterV2__factory.d.ts +0 -1027
  52. package/dist/config/abi/types/factories/PriceGetter__factory.d.ts +0 -999
  53. package/dist/config/abi/types/factories/SousChef__factory.d.ts +0 -511
  54. package/dist/config/abi/types/factories/Treasury__factory.d.ts +0 -235
  55. package/dist/config/abi/types/factories/Weth__factory.d.ts +0 -220
  56. package/dist/config/abi/types/factories/Zap__factory.d.ts +0 -695
  57. package/dist/config/abi/types/factories/index.d.ts +0 -25
  58. package/dist/config/abi/types/index.d.ts +0 -51
package/dist/main.js CHANGED
@@ -63031,6 +63031,7 @@ const HELIUS_SOL_RPC_ENDPOINTS = [
63031
63031
  'https://mainnet.helius-rpc.com/?api-key=c097651d-ae13-4ab4-ae4c-fef7e48d4561', // n0mbr3al3at0r10@gmail.com
63032
63032
  'https://mainnet.helius-rpc.com/?api-key=a5c4ea36-fa6b-4bcc-a7a4-e10012b9ea7e', // RandomApe personal mail
63033
63033
  ];
63034
+ // export const HELIUS_SOL_RPC_ENDPOINTS = ['https://devnet.helius-rpc.com/?api-key=095f6fc7-1be0-4d94-a737-4a5ee0d82ea5'] //devnet
63034
63035
  // Function to get a random Helius SOL RPC endpoint
63035
63036
  const getRandomHeliusRPC = () => {
63036
63037
  const randomIndex = Math.floor(Math.random() * HELIUS_SOL_RPC_ENDPOINTS.length);
@@ -63123,7 +63124,7 @@ const stagingUrls = {
63123
63124
  };
63124
63125
  const useSDKConfig = (config) => {
63125
63126
  const urls = process.env.NODE_ENV === 'production' ? defaultUrls : stagingUrls;
63126
- const initialData = Object.assign(Object.assign({ referenceId: '', chains: [], hotBondChains: [main.ChainId.BSC, main.ChainId.MATIC], useHotBonds: true, connector: 'default', useTiers: false, useTGEBonds: false, showLowValueBonds: false, bondPartner: undefined, namingPreference: 'Bonus', useCardsView: false, blockSales: false }, config), { urls: Object.assign(Object.assign({}, urls), config === null || config === void 0 ? void 0 : config.urls), highestCompatibleVersion: '2.2.0' });
63127
+ const initialData = Object.assign(Object.assign({ referenceId: '', chains: [], hotBondChains: [main.ChainId.BSC, main.ChainId.MATIC], useHotBonds: true, connector: 'default', useTiers: false, useTGEBonds: false, showLowValueBonds: false, bondPartner: undefined, namingPreference: 'Bonus', useCardsView: false, blockSales: false, customBranch: '' }, config), { urls: Object.assign(Object.assign({}, urls), config === null || config === void 0 ? void 0 : config.urls), highestCompatibleVersion: '2.2.0' });
63127
63128
  const { data } = useQuery({
63128
63129
  queryKey: [QUERY_KEYS.SDK_CONFIG],
63129
63130
  queryFn: () => {
@@ -63139,7 +63140,7 @@ const useURLByEnvironment = (key) => {
63139
63140
  return (_a = config === null || config === void 0 ? void 0 : config.urls) === null || _a === void 0 ? void 0 : _a[key];
63140
63141
  };
63141
63142
 
63142
- function reportError$1(_a) {
63143
+ function reportError(_a) {
63143
63144
  return __awaiter$9(this, arguments, void 0, function* ({ apiUrl, error, extraInfo = {}, chainId, account, rpc, }) {
63144
63145
  const isClient = typeof window !== 'undefined';
63145
63146
  const url = isClient ? window.location.href : null;
@@ -63241,7 +63242,7 @@ const fetchUserPoints = (account, useTiers, apiUrl) => __awaiter$9(void 0, void
63241
63242
  }
63242
63243
  catch (e) {
63243
63244
  console.error(e);
63244
- reportError$1({
63245
+ reportError({
63245
63246
  apiUrl,
63246
63247
  error: e,
63247
63248
  extraInfo: { type: 'fetchUserPoints', e },
@@ -63614,23 +63615,25 @@ const getBonusColor = (premiumString) => {
63614
63615
  };
63615
63616
 
63616
63617
  function useBondsList() {
63617
- const realTime = useURLByEnvironment('realTimeApi');
63618
- const apiUrl = useURLByEnvironment('apiV2');
63618
+ const queryClient = useQueryClient();
63619
63619
  return useQuery({
63620
63620
  queryKey: [QUERY_KEYS.BONDS_LIST],
63621
- queryFn: () => getBondsList(realTime, apiUrl),
63621
+ queryFn: () => getBondsList(queryClient),
63622
63622
  staleTime: Infinity,
63623
63623
  refetchInterval: 300000, // 5 min
63624
63624
  refetchOnWindowFocus: false,
63625
63625
  });
63626
63626
  }
63627
- const getBondsList = (realTimeapiURL, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
63627
+ const getBondsList = (queryClient) => __awaiter$9(void 0, void 0, void 0, function* () {
63628
+ const { urls, customBranch } = queryClient === null || queryClient === void 0 ? void 0 : queryClient.getQueryData([QUERY_KEYS.SDK_CONFIG]);
63629
+ const realTimeApiURL = urls['realTimeApi'];
63630
+ const apiUrl = urls['apiV2'];
63628
63631
  try {
63629
- const response = yield axios.get(`${realTimeapiURL}/utils/bonds`);
63632
+ const response = yield axios.get(`${realTimeApiURL}/utils/bonds${customBranch ? `?branch=${customBranch}` : ''}`);
63630
63633
  return response.data;
63631
63634
  }
63632
63635
  catch (e) {
63633
- reportError$1({
63636
+ reportError({
63634
63637
  apiUrl,
63635
63638
  error: e,
63636
63639
  extraInfo: { type: 'getBondsList', e },
@@ -64818,7 +64821,7 @@ const getTokenPrices = (priceApi, apiv2) => __awaiter$9(void 0, void 0, void 0,
64818
64821
  return response.data;
64819
64822
  }
64820
64823
  catch (error) {
64821
- reportError$1({
64824
+ reportError({
64822
64825
  apiUrl: apiv2,
64823
64826
  error,
64824
64827
  extraInfo: { type: 'getTokenPrices', error },
@@ -65132,6 +65135,7 @@ function fetchUserOwnedSolanaBonds(user, bondData, tokenPrices) {
65132
65135
  totalPayout: bondAccount.payout.toString(),
65133
65136
  truePricePaid: bondAccount.truePricePaid.toString(),
65134
65137
  lastBlockTimestamp: bondAccount.lastClaimTimestamp.toString(),
65138
+ vestingStartTimestamp: bondAccount.vestingStartTimestamp.toString(),
65135
65139
  pendingRewards,
65136
65140
  billNftAddress: collection,
65137
65141
  payoutClaimed: bondAccount.payoutClaimed.toString(),
@@ -65220,7 +65224,6 @@ const useSOLAccount = () => {
65220
65224
  return Object.assign(Object.assign({}, account), { publicKey: solAddress ? solPublicKey : account.publicKey });
65221
65225
  };
65222
65226
 
65223
- // import dummyJson from './dummy.json'
65224
65227
  function useUserBonds() {
65225
65228
  var _a, _b;
65226
65229
  // First fetch the full list of bonds
@@ -65325,7 +65328,7 @@ const getUserBonds = (account, solanaAccount, bondList, queryClient) => __awaite
65325
65328
  }
65326
65329
  catch (e) {
65327
65330
  console.error(e);
65328
- reportError$1({
65331
+ reportError({
65329
65332
  apiUrl,
65330
65333
  error: e,
65331
65334
  extraInfo: { type: 'getUserBonds', bondList, chains, e },
@@ -65991,7 +65994,7 @@ const ClaimAllModal = () => {
65991
65994
  catch (error) {
65992
65995
  console.error('Claim All failed:', error);
65993
65996
  addToastError(error.message);
65994
- reportError$1({
65997
+ reportError({
65995
65998
  apiUrl: (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2,
65996
65999
  error,
65997
66000
  extraInfo: { type: 'claimAll', bondsOfSelectedChain, error },
@@ -69937,7 +69940,7 @@ const TransferAction$1 = ({ userBill, toAddress, disabled, }) => {
69937
69940
  console.error('Transfer failed:', error);
69938
69941
  setLoadingTx(false);
69939
69942
  addToastError(error.shortMessage);
69940
- reportError$1({
69943
+ reportError({
69941
69944
  apiUrl: (_d = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _d === void 0 ? void 0 : _d.apiV2,
69942
69945
  error,
69943
69946
  extraInfo: { type: 'transfer', userBill, error },
@@ -70089,7 +70092,7 @@ const getPreTGEList = (apiRealTimeURL, apiUrl) => __awaiter$9(void 0, void 0, vo
70089
70092
  return response.data;
70090
70093
  }
70091
70094
  catch (e) {
70092
- reportError$1({
70095
+ reportError({
70093
70096
  apiUrl,
70094
70097
  error: e,
70095
70098
  extraInfo: { type: 'getPreTGEList', e },
@@ -75241,7 +75244,7 @@ const fetchBondsDataPreTGE = (chain, tokenPrices, preTGEBonds, apiUrl) => __awai
75241
75244
  const chunkSize = vals.length / preTGEBonds.length;
75242
75245
  const chunkedBills = lodashExports.chunk(vals, chunkSize);
75243
75246
  const returnedBills = chunkedBills === null || chunkedBills === void 0 ? void 0 : chunkedBills.map((chunk, index) => {
75244
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
75247
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
75245
75248
  const bondConfig = preTGEBonds === null || preTGEBonds === void 0 ? void 0 : preTGEBonds.find((bill) => (bill === null || bill === void 0 ? void 0 : bill.index) === preTGEBondsIds[index]);
75246
75249
  const [trueBillPrice, terms, totalPrincipalBilled, finalized, minPoints, maxPoints, startVestingTimestamp] = chunk;
75247
75250
  const [, , vestingTerm, , , initialRelease, totalRaise, maxTotalPayout] = terms;
@@ -75251,12 +75254,12 @@ const fetchBondsDataPreTGE = (chain, tokenPrices, preTGEBonds, apiUrl) => __awai
75251
75254
  return ((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.tokenAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) ===
75252
75255
  ((_d = (_c = (_b = bondConfig === null || bondConfig === void 0 ? void 0 : bondConfig.lpToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bondConfig === null || bondConfig === void 0 ? void 0 : bondConfig.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase());
75253
75256
  })) === null || _e === void 0 ? void 0 : _e.price) !== null && _f !== void 0 ? _f : 0;
75254
- const earnTokenPrice = (_h = (_g = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[bondConfig === null || bondConfig === void 0 ? void 0 : bondConfig.chainId]) === null || _g === void 0 ? void 0 : _g.find((tokenPrice) => {
75257
+ const earnTokenPrice = (_j = (_h = (_g = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[bondConfig === null || bondConfig === void 0 ? void 0 : bondConfig.chainId]) === null || _g === void 0 ? void 0 : _g.find((tokenPrice) => {
75255
75258
  var _a, _b, _c, _d;
75256
75259
  return ((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.tokenAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) ===
75257
75260
  ((_d = (_c = (_b = bondConfig === null || bondConfig === void 0 ? void 0 : bondConfig.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bondConfig === null || bondConfig === void 0 ? void 0 : bondConfig.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase());
75258
- })) === null || _h === void 0 ? void 0 : _h.price;
75259
- const principalTokenPrice = (_j = lpPrice === null || lpPrice === void 0 ? void 0 : lpPrice.toString()) !== null && _j !== void 0 ? _j : '0';
75261
+ })) === null || _h === void 0 ? void 0 : _h.price) !== null && _j !== void 0 ? _j : 0;
75262
+ const principalTokenPrice = (_k = lpPrice === null || lpPrice === void 0 ? void 0 : lpPrice.toString()) !== null && _k !== void 0 ? _k : '0';
75260
75263
  const payoutTokenPrice = earnTokenPrice ? earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.toString() : initPrice === null || initPrice === void 0 ? void 0 : initPrice.toString();
75261
75264
  const bonus = Math.round((bondConfig.tgePrice / initPrice) * 100 - 100);
75262
75265
  const data = Object.assign(Object.assign({}, bondConfig), { initialRelease: initialRelease / 10000, vestingTerm: vestingTerm === null || vestingTerm === void 0 ? void 0 : vestingTerm.toNumber(), trueBondPrices: [
@@ -75267,7 +75270,7 @@ const fetchBondsDataPreTGE = (chain, tokenPrices, preTGEBonds, apiUrl) => __awai
75267
75270
  bonusWithFee: bonus, // placeholder, wont be used
75268
75271
  },
75269
75272
  ], maxTotalPayout: maxTotalPayout === null || maxTotalPayout === void 0 ? void 0 : maxTotalPayout.toString(), totalPrincipalBilled: totalPrincipalBilled === null || totalPrincipalBilled === void 0 ? void 0 : totalPrincipalBilled.toString(), payoutTokenPrice,
75270
- principalTokenPrice, totalRaise: totalRaise === null || totalRaise === void 0 ? void 0 : totalRaise.toString(), finalized: finalized[0], minPoints: minPoints.toString(), maxPoints: maxPoints.toString(), startVestingTimestamp: startVestingTimestamp === null || startVestingTimestamp === void 0 ? void 0 : startVestingTimestamp.toString(), initTime: { [bondConfig.chainId]: terms.startTime.toNumber() }, finishTime: terms.endTime.toNumber(), initPrice, soldOut: finalized[0] || ((_k = terms.endTime.toNumber()) !== null && _k !== void 0 ? _k : 0) < Date.now() / 1000 || bondConfig.soldOut });
75273
+ principalTokenPrice, totalRaise: totalRaise === null || totalRaise === void 0 ? void 0 : totalRaise.toString(), finalized: finalized[0], minPoints: minPoints.toString(), maxPoints: maxPoints.toString(), startVestingTimestamp: startVestingTimestamp === null || startVestingTimestamp === void 0 ? void 0 : startVestingTimestamp.toString(), initTime: { [bondConfig.chainId]: terms.startTime.toNumber() }, finishTime: terms.endTime.toNumber(), initPrice, soldOut: finalized[0] || ((_l = terms.endTime.toNumber()) !== null && _l !== void 0 ? _l : 0) < Date.now() / 1000 || bondConfig.soldOut });
75271
75274
  return data;
75272
75275
  });
75273
75276
  data.push(returnedBills);
@@ -75275,7 +75278,7 @@ const fetchBondsDataPreTGE = (chain, tokenPrices, preTGEBonds, apiUrl) => __awai
75275
75278
  }
75276
75279
  catch (e) {
75277
75280
  console.error(e);
75278
- reportError$1({
75281
+ reportError({
75279
75282
  apiUrl,
75280
75283
  error: e,
75281
75284
  extraInfo: { type: 'getLaunchBondsPublicData', preTGEBonds, chain, e },
@@ -75393,7 +75396,7 @@ const fetchBondsData = (chainId, bills, apiUrl, tokenPrices) => __awaiter$9(void
75393
75396
  }
75394
75397
  catch (e) {
75395
75398
  console.error(e);
75396
- reportError$1({
75399
+ reportError({
75397
75400
  apiUrl,
75398
75401
  error: e,
75399
75402
  extraInfo: { type: 'getBondsData', e },
@@ -75403,7 +75406,7 @@ const fetchBondsData = (chainId, bills, apiUrl, tokenPrices) => __awaiter$9(void
75403
75406
  });
75404
75407
  const cleanBillsData = (billIds, chunkedBills, chainId, bills, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
75405
75408
  const data = yield Promise.all(chunkedBills === null || chunkedBills === void 0 ? void 0 : chunkedBills.map((chunk, index) => __awaiter$9(void 0, void 0, void 0, function* () {
75406
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
75409
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
75407
75410
  const bill = bills === null || bills === void 0 ? void 0 : bills.find((bill) => (bill === null || bill === void 0 ? void 0 : bill.index) === billIds[index]);
75408
75411
  const lpPrice = (_b = (_a = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find((tokenPrice) => {
75409
75412
  var _a, _b, _c, _d;
@@ -75454,7 +75457,7 @@ const cleanBillsData = (billIds, chunkedBills, chainId, bills, tokenPrices) => _
75454
75457
  ];
75455
75458
  }
75456
75459
  const cleanedData = Object.assign(Object.assign({}, bill), { feeInPayout,
75457
- feeInPrincipal, showcaseTokenName: (_l = (_k = (_j = bill === null || bill === void 0 ? void 0 : bill.showcaseToken) === null || _j === void 0 ? void 0 : _j.symbol) !== null && _k !== void 0 ? _k : bill === null || bill === void 0 ? void 0 : bill.earnToken.symbol) !== null && _l !== void 0 ? _l : '', trueBondPrices, principalTokenPrice: (_m = lpPrice === null || lpPrice === void 0 ? void 0 : lpPrice.toString()) !== null && _m !== void 0 ? _m : '0', payoutTokenPrice: (_o = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.toString()) !== null && _o !== void 0 ? _o : '0', tokensRemaining: treasuryBalance
75460
+ feeInPrincipal, showcaseTokenName: (_l = (_k = (_j = bill === null || bill === void 0 ? void 0 : bill.showcaseToken) === null || _j === void 0 ? void 0 : _j.symbol) !== null && _k !== void 0 ? _k : bill === null || bill === void 0 ? void 0 : bill.earnToken.symbol) !== null && _l !== void 0 ? _l : '', trueBondPrices, principalTokenPrice: lpPrice === null || lpPrice === void 0 ? void 0 : lpPrice.toString(), payoutTokenPrice: earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.toString(), tokensRemaining: treasuryBalance
75458
75461
  ? Math.min(treasuryBalance, tokensRemaining).toString()
75459
75462
  : tokensRemaining.toString(), maxTotalPayout: maxTotalPayout === null || maxTotalPayout === void 0 ? void 0 : maxTotalPayout.toString(), maxPayout: maxPayout === null || maxPayout === void 0 ? void 0 : maxPayout.toString(), totalPayoutGiven: totalPayoutGiven === null || totalPayoutGiven === void 0 ? void 0 : totalPayoutGiven.toString(), vestingTerm: typeof vestingTerm === 'number' ? vestingTerm : vestingTerm.toNumber() });
75460
75463
  return cleanedData;
@@ -75520,7 +75523,7 @@ const calculateBondsData = (queryClient) => __awaiter$9(void 0, void 0, void 0,
75520
75523
  yield fetchBondsData(main.ChainId.SOL, reducedBonds[main.ChainId.SOL], apiUrl, tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[main.ChainId.SOL]),
75521
75524
  yield axios.get(`${realTimeApiURL}/bonds`),
75522
75525
  ]);
75523
- return [...solBonds, ...evmResponse.data.bonds];
75526
+ return [...solBonds, ...evmResponse.data.bonds].filter((bond) => chains.includes(bond.chainId));
75524
75527
  }
75525
75528
  catch (_a) {
75526
75529
  // If realtime fails, we trigger the fallback strategy on the client
@@ -75621,7 +75624,7 @@ const Actions = ({ userBill }) => {
75621
75624
  console.error('Claim Failed:', error);
75622
75625
  setLoadingTx(false);
75623
75626
  addToastError(error.message);
75624
- reportError$1({
75627
+ reportError({
75625
75628
  apiUrl: (_g = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _g === void 0 ? void 0 : _g.apiV2,
75626
75629
  error,
75627
75630
  extraInfo: { type: 'redeem', userBill, error },
@@ -75717,7 +75720,10 @@ const ActionsSolana = ({ userBill }) => {
75717
75720
  return userPayoutAta;
75718
75721
  });
75719
75722
  const handleClaim = () => __awaiter$9(void 0, void 0, void 0, function* () {
75720
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
75723
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
75724
+ // Early return guard - prevent double execution
75725
+ if (loadingTx || !accountSolana || !userBill)
75726
+ return;
75721
75727
  try {
75722
75728
  setLoadingTx(true);
75723
75729
  const earnTokenAddress = (_c = (_b = (_a = userBill === null || userBill === void 0 ? void 0 : userBill.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 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _d === void 0 ? void 0 : _d.chainId];
@@ -75726,6 +75732,7 @@ const ActionsSolana = ({ userBill }) => {
75726
75732
  return;
75727
75733
  const payoutMint = new PublicKey(earnTokenAddress);
75728
75734
  const bondIssuancePda = new PublicKey(contractAddress);
75735
+ const bondPricingPda = derivePda('bond_pricing', bondIssuancePda, PROGRAM_ID);
75729
75736
  const nftMint = new PublicKey(userBill.asset);
75730
75737
  const [bondTermPda] = PublicKey.findProgramAddressSync([new TextEncoder().encode('bond_term'), bondIssuancePda.toBuffer()], PROGRAM_ID);
75731
75738
  const [bondPda] = PublicKey.findProgramAddressSync([new TextEncoder().encode('bond'), bondIssuancePda.toBuffer(), nftMint.toBuffer()], PROGRAM_ID);
@@ -75742,6 +75749,7 @@ const ActionsSolana = ({ userBill }) => {
75742
75749
  { pubkey: bondPda, isSigner: false, isWritable: true },
75743
75750
  { pubkey: bondTermPda, isSigner: false, isWritable: false },
75744
75751
  { pubkey: bondIssuancePda, isSigner: false, isWritable: false },
75752
+ { pubkey: bondPricingPda, isSigner: false, isWritable: true },
75745
75753
  { pubkey: accountSolana, isSigner: true, isWritable: true }, // user
75746
75754
  { pubkey: nftMint, isSigner: false, isWritable: true },
75747
75755
  { pubkey: userPayoutAta, isSigner: false, isWritable: true },
@@ -75760,14 +75768,17 @@ const ActionsSolana = ({ userBill }) => {
75760
75768
  // Build Transaction
75761
75769
  const transaction = new Transaction().add(instruction);
75762
75770
  transaction.feePayer = accountSolana;
75763
- const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash('confirmed');
75771
+ // Get fresh blockhash right before signing
75772
+ const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash('finalized');
75764
75773
  transaction.recentBlockhash = blockhash;
75765
75774
  if (!signTransaction)
75766
75775
  return;
75767
75776
  const signedTx = yield signTransaction(transaction);
75777
+ // Send with better error handling
75768
75778
  const txHash = yield connection.sendRawTransaction(signedTx.serialize(), {
75769
75779
  skipPreflight: false,
75770
- preflightCommitment: 'confirmed',
75780
+ preflightCommitment: 'finalized',
75781
+ maxRetries: 0, // Don't auto-retry to avoid duplicates
75771
75782
  });
75772
75783
  yield connection.confirmTransaction({
75773
75784
  signature: txHash,
@@ -75780,13 +75791,18 @@ const ActionsSolana = ({ userBill }) => {
75780
75791
  refetch();
75781
75792
  addToastSuccess(txHash, main.ChainId.SOL);
75782
75793
  }
75783
- setLoadingTx(false);
75784
75794
  }
75785
75795
  catch (error) {
75786
75796
  console.error('Claim failed:', error);
75787
- addToastError((_k = error === null || error === void 0 ? void 0 : error.message) !== null && _k !== void 0 ? _k : 'Unknown error');
75797
+ // Better error messaging for duplicate transactions
75798
+ if ((_k = error === null || error === void 0 ? void 0 : error.message) === null || _k === void 0 ? void 0 : _k.includes('already been processed')) {
75799
+ addToastError('Transaction already processed. Please wait and try again.');
75800
+ }
75801
+ else {
75802
+ addToastError((_l = error === null || error === void 0 ? void 0 : error.message) !== null && _l !== void 0 ? _l : 'Unknown error');
75803
+ }
75788
75804
  reportError({
75789
- apiUrl: (_l = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _l === void 0 ? void 0 : _l.apiV2,
75805
+ apiUrl: (_m = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _m === void 0 ? void 0 : _m.apiV2,
75790
75806
  error,
75791
75807
  extraInfo: { type: 'claim', userBill, error },
75792
75808
  });
@@ -75797,7 +75813,8 @@ const ActionsSolana = ({ userBill }) => {
75797
75813
  });
75798
75814
  return (jsxs(Fragment$1, { children: [jsx$2(Button, { variant: "secondary", disabled: claimable(userBill) === 0 || loadingTx || !userBill || isPendingCliff, load: loadingTx, onClick: (event) => {
75799
75815
  event.stopPropagation();
75800
- handleClaim();
75816
+ if (!loadingTx)
75817
+ handleClaim();
75801
75818
  }, sx: { fontSize: '14px', width: '100%' }, children: isPendingCliff
75802
75819
  ? `Claimable in ${cliffCountdown.days !== 0 ? `${cliffCountdown.days} days` : cliffCountdown.hours !== 0 ? `${cliffCountdown.hours} hours` : `${cliffCountdown.minutes} mins`}`
75803
75820
  : 'Claim' }), jsx$2(Button, { sx: { fontSize: '14px', width: '100%' }, onClick: () => canPurchaseAgain
@@ -76047,7 +76064,7 @@ const UserBondRow = ({ bill }) => {
76047
76064
  setLoadingTx(false);
76048
76065
  console.error('Claim failed:', error);
76049
76066
  addToastError(error.message);
76050
- reportError$1({
76067
+ reportError({
76051
76068
  apiUrl: (_g = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _g === void 0 ? void 0 : _g.apiV2,
76052
76069
  error,
76053
76070
  extraInfo: { type: 'claim', bill, error },
@@ -76113,9 +76130,9 @@ const UserBondRowSolana = ({ bill }) => {
76113
76130
  const earnTokenPrice = parseFloat((_b = (_a = bill === null || bill === void 0 ? void 0 : bill.bond) === null || _a === void 0 ? void 0 : _a.payoutTokenPrice) !== null && _b !== void 0 ? _b : '0');
76114
76131
  const vestingCliff = (_c = bill === null || bill === void 0 ? void 0 : bill.bond) === null || _c === void 0 ? void 0 : _c.vestingCliff;
76115
76132
  const currentTime = Math.round(new Date().getTime() / 1000);
76116
- const lastBlockTimestamp = parseInt((_d = bill === null || bill === void 0 ? void 0 : bill.lastBlockTimestamp) !== null && _d !== void 0 ? _d : '0');
76117
- const isPendingCliff = vestingCliff ? currentTime - lastBlockTimestamp < vestingCliff : false;
76118
- const cliffCountdown = getTimePeriods(lastBlockTimestamp + (vestingCliff !== null && vestingCliff !== void 0 ? vestingCliff : 0) - currentTime, true);
76133
+ const vestingStartTimestamp = parseInt((_d = bill === null || bill === void 0 ? void 0 : bill.vestingStartTimestamp) !== null && _d !== void 0 ? _d : '0');
76134
+ const isPendingCliff = vestingCliff ? currentTime - vestingStartTimestamp < vestingCliff : false;
76135
+ const cliffCountdown = getTimePeriods(vestingStartTimestamp + (vestingCliff !== null && vestingCliff !== void 0 ? vestingCliff : 0) - currentTime, true);
76119
76136
  const [onOpenPurchasedBond] = useModal(jsx$2(YourBondsModal, { userBill: bill }));
76120
76137
  const ensureUserPayoutAtaExists = (_a) => __awaiter$9(void 0, [_a], void 0, function* ({ connection, payer, payoutMint, user, }) {
76121
76138
  const userPayoutAta = yield getAssociatedTokenAddress(payoutMint, user);
@@ -76147,7 +76164,10 @@ const UserBondRowSolana = ({ bill }) => {
76147
76164
  return userPayoutAta;
76148
76165
  });
76149
76166
  const handleClaim = () => __awaiter$9(void 0, void 0, void 0, function* () {
76150
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
76167
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
76168
+ // Early return guard - prevent double execution
76169
+ if (loadingTx || !accountSolana)
76170
+ return;
76151
76171
  try {
76152
76172
  setLoadingTx(true);
76153
76173
  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];
@@ -76156,6 +76176,7 @@ const UserBondRowSolana = ({ bill }) => {
76156
76176
  return;
76157
76177
  const payoutMint = new PublicKey(earnTokenAddress);
76158
76178
  const bondIssuancePda = new PublicKey(contractAddress);
76179
+ const bondPricingPda = derivePda('bond_pricing', bondIssuancePda, PROGRAM_ID);
76159
76180
  const nftMint = new PublicKey(bill.asset);
76160
76181
  const [bondTermPda] = PublicKey.findProgramAddressSync([new TextEncoder().encode('bond_term'), bondIssuancePda.toBuffer()], PROGRAM_ID);
76161
76182
  const [bondPda] = PublicKey.findProgramAddressSync([new TextEncoder().encode('bond'), bondIssuancePda.toBuffer(), nftMint.toBuffer()], PROGRAM_ID);
@@ -76172,6 +76193,7 @@ const UserBondRowSolana = ({ bill }) => {
76172
76193
  { pubkey: bondPda, isSigner: false, isWritable: true },
76173
76194
  { pubkey: bondTermPda, isSigner: false, isWritable: false },
76174
76195
  { pubkey: bondIssuancePda, isSigner: false, isWritable: false },
76196
+ { pubkey: bondPricingPda, isSigner: false, isWritable: true },
76175
76197
  { pubkey: accountSolana, isSigner: true, isWritable: true }, // user
76176
76198
  { pubkey: nftMint, isSigner: false, isWritable: true },
76177
76199
  { pubkey: userPayoutAta, isSigner: false, isWritable: true },
@@ -76190,14 +76212,17 @@ const UserBondRowSolana = ({ bill }) => {
76190
76212
  // Build Transaction
76191
76213
  const transaction = new Transaction().add(instruction);
76192
76214
  transaction.feePayer = accountSolana;
76193
- const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash('confirmed');
76215
+ // Get fresh blockhash right before signing
76216
+ const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash('finalized');
76194
76217
  transaction.recentBlockhash = blockhash;
76195
76218
  if (!signTransaction)
76196
76219
  return;
76197
76220
  const signedTx = yield signTransaction(transaction);
76221
+ // Send with better error handling
76198
76222
  const txHash = yield connection.sendRawTransaction(signedTx.serialize(), {
76199
76223
  skipPreflight: false,
76200
- preflightCommitment: 'confirmed',
76224
+ preflightCommitment: 'finalized',
76225
+ maxRetries: 0, // Don't auto-retry to avoid duplicates
76201
76226
  });
76202
76227
  yield connection.confirmTransaction({
76203
76228
  signature: txHash,
@@ -76210,13 +76235,18 @@ const UserBondRowSolana = ({ bill }) => {
76210
76235
  refetch();
76211
76236
  addToastSuccess(txHash, main.ChainId.SOL);
76212
76237
  }
76213
- setLoadingTx(false);
76214
76238
  }
76215
76239
  catch (error) {
76216
76240
  console.error('Claim failed:', error);
76217
- addToastError((_k = error === null || error === void 0 ? void 0 : error.message) !== null && _k !== void 0 ? _k : 'Unknown error');
76241
+ // Better error messaging for duplicate transactions
76242
+ if ((_k = error === null || error === void 0 ? void 0 : error.message) === null || _k === void 0 ? void 0 : _k.includes('already been processed')) {
76243
+ addToastError('Transaction already processed. Please wait and try again.');
76244
+ }
76245
+ else {
76246
+ addToastError((_l = error === null || error === void 0 ? void 0 : error.message) !== null && _l !== void 0 ? _l : 'Unknown error');
76247
+ }
76218
76248
  reportError({
76219
- apiUrl: (_l = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _l === void 0 ? void 0 : _l.apiV2,
76249
+ apiUrl: (_m = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _m === void 0 ? void 0 : _m.apiV2,
76220
76250
  error,
76221
76251
  extraInfo: { type: 'claim', bill, error },
76222
76252
  });
@@ -76240,7 +76270,8 @@ const UserBondRowSolana = ({ bill }) => {
76240
76270
  setVisible(true);
76241
76271
  }, fullWidth: true, children: ["Connect to ", NETWORK_LABEL[(_p = bill === null || bill === void 0 ? void 0 : bill.bond) === null || _p === void 0 ? void 0 : _p.chainId]] })) : (jsx$2(Button, { className: "button", disabled: claimable(bill) === 0 || loadingTx || isPendingCliff, load: loadingTx, onClick: (event) => {
76242
76272
  event.stopPropagation();
76243
- handleClaim();
76273
+ if (!loadingTx)
76274
+ handleClaim();
76244
76275
  }, fullWidth: true, children: isPendingCliff
76245
76276
  ? `Claimable in ${cliffCountdown.days !== 0 ? `${cliffCountdown.days} days` : cliffCountdown.hours !== 0 ? `${cliffCountdown.hours} hours` : `${cliffCountdown.minutes} mins`}`
76246
76277
  : 'Claim' })) })] })] }));
@@ -76357,7 +76388,7 @@ const fetchPreTGEUserBonds = (chains, tokenPrices, preTGEList, account, apiUrl)
76357
76388
  }
76358
76389
  catch (e) {
76359
76390
  console.error(e);
76360
- reportError$1({
76391
+ reportError({
76361
76392
  apiUrl,
76362
76393
  error: e,
76363
76394
  extraInfo: { type: 'fetchPreTGEUserBonds', bond, e },
@@ -76371,7 +76402,7 @@ const fetchPreTGEUserBonds = (chains, tokenPrices, preTGEList, account, apiUrl)
76371
76402
  }
76372
76403
  catch (e) {
76373
76404
  console.log(e);
76374
- reportError$1({
76405
+ reportError({
76375
76406
  apiUrl,
76376
76407
  error: e,
76377
76408
  extraInfo: { type: 'fetchPreTGEUserBonds', e },
@@ -76413,7 +76444,7 @@ const PreTgeActions = ({ userBond }) => {
76413
76444
  .catch((e) => {
76414
76445
  var _a;
76415
76446
  console.error(e.message);
76416
- reportError$1({
76447
+ reportError({
76417
76448
  apiUrl: (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2,
76418
76449
  error: e.message,
76419
76450
  extraInfo: { type: 'redeemLaunchBond', error: e.message },
@@ -76444,7 +76475,7 @@ const PreTgeActions = ({ userBond }) => {
76444
76475
  .catch((e) => {
76445
76476
  var _a;
76446
76477
  console.error(e.message);
76447
- reportError$1({
76478
+ reportError({
76448
76479
  apiUrl: (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2,
76449
76480
  error: e.message,
76450
76481
  extraInfo: { type: 'claimLaunchBond', error: e.message },
@@ -76856,7 +76887,7 @@ const getTokensBalance = (account, tokens, chainId, apiUrl) => __awaiter$9(void
76856
76887
  return [...balancesToken, ...balancesNative];
76857
76888
  }
76858
76889
  catch (e) {
76859
- reportError$1({
76890
+ reportError({
76860
76891
  apiUrl,
76861
76892
  error: e,
76862
76893
  extraInfo: { type: 'getTokensBalance', tokens, e },
@@ -78030,7 +78061,7 @@ const useApproval = (amount, currency, spender, account, chainId) => {
78030
78061
  setConfirmingTxOnWallet(false);
78031
78062
  console.error('Approval failed:', error);
78032
78063
  addToastError((error === null || error === void 0 ? void 0 : error.shortMessage) || (error === null || error === void 0 ? void 0 : error.details) || (error === null || error === void 0 ? void 0 : error.message));
78033
- reportError$1({
78064
+ reportError({
78034
78065
  apiUrl,
78035
78066
  error,
78036
78067
  extraInfo: { type: 'approval', tokenAddress: tokenAddress, spenderAddress: spender, error },
@@ -78349,7 +78380,7 @@ const ZapModal = ({ onDismiss, outputToken, account, chainId }) => {
78349
78380
  console.error(e);
78350
78381
  setPendingTx(false);
78351
78382
  addToastError(e === null || e === void 0 ? void 0 : e.shortMessage);
78352
- reportError$1({
78383
+ reportError({
78353
78384
  apiUrl: (_c = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _c === void 0 ? void 0 : _c.apiV2,
78354
78385
  error: e,
78355
78386
  extraInfo: { type: 'zap-lp', zapData, e },
@@ -78955,7 +78986,7 @@ const getTierProofSig = (apiAddress, account, bondAddress, chainId) => __awaiter
78955
78986
  return response.data.tierProofSignature;
78956
78987
  }
78957
78988
  catch (e) {
78958
- reportError$1({
78989
+ reportError({
78959
78990
  apiUrl: apiAddress,
78960
78991
  error: e,
78961
78992
  extraInfo: { type: 'getTierProofSig', bondAddress, e },
@@ -79364,7 +79395,7 @@ const BuyComponent = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond,
79364
79395
  }
79365
79396
  catch (error) {
79366
79397
  console.error('Buy error', error);
79367
- reportError$1({
79398
+ reportError({
79368
79399
  apiUrl: (_h = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _h === void 0 ? void 0 : _h.apiV2,
79369
79400
  error,
79370
79401
  extraInfo: { type: 'buyBond', bondData, error },
@@ -79428,7 +79459,7 @@ const BuyComponent = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond,
79428
79459
  catch (e) {
79429
79460
  console.log(e);
79430
79461
  addToastError(e.shortMessage);
79431
- reportError$1({
79462
+ reportError({
79432
79463
  apiUrl: (_l = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _l === void 0 ? void 0 : _l.apiV2,
79433
79464
  error: e,
79434
79465
  extraInfo: { type: 'zapBuyBond', bondData, zapData, e },
@@ -79752,7 +79783,7 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
79752
79783
  catch (error) {
79753
79784
  console.error('Error during bond purchase:', error);
79754
79785
  addToastError((error === null || error === void 0 ? void 0 : error.message) || 'Unknown error');
79755
- reportError$1({
79786
+ reportError({
79756
79787
  apiUrl: (_j = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _j === void 0 ? void 0 : _j.apiV2,
79757
79788
  error: error.message,
79758
79789
  extraInfo: { type: 'solanaBuyBond', error: error.message },
@@ -85553,7 +85584,7 @@ const getHotBondsContracts = (apiUrl) => __awaiter$9(void 0, void 0, void 0, fun
85553
85584
  return response.data.map((bond) => bond.BondAddress.toLowerCase());
85554
85585
  }
85555
85586
  catch (e) {
85556
- reportError$1({
85587
+ reportError({
85557
85588
  apiUrl,
85558
85589
  error: e,
85559
85590
  extraInfo: { type: 'getHotBondsContracts', e },
@@ -1,4 +1,4 @@
1
- import { UseQueryResult } from '@tanstack/react-query';
1
+ import { QueryClient, UseQueryResult } from '@tanstack/react-query';
2
2
  import { BillsConfig } from '@ape.swap/apeswap-lists';
3
3
  export default function useBondsList(): UseQueryResult<BillsConfig[]>;
4
- export declare const getBondsList: (realTimeapiURL: string, apiUrl: string) => Promise<BillsConfig[]>;
4
+ export declare const getBondsList: (queryClient: QueryClient) => Promise<BillsConfig[]>;
@@ -14,6 +14,7 @@ export interface SDKPropsDTO {
14
14
  theme?: any;
15
15
  highestCompatibleVersion?: string;
16
16
  blockSales?: boolean;
17
+ customBranch?: string;
17
18
  }
18
19
  export interface SDKProps {
19
20
  referenceId: string;
@@ -33,6 +34,7 @@ export interface SDKProps {
33
34
  solAddress?: string;
34
35
  useCardsView?: boolean;
35
36
  blockSales?: boolean;
37
+ customBranch?: string;
36
38
  }
37
39
  export declare const useSDKConfig: (config?: SDKPropsDTO) => SDKProps;
38
40
  export type URLKeys = 'apiV2' | 'realTimeApi' | 'mainUrl' | 'priceApi';
@@ -13,6 +13,7 @@ export interface UserBill {
13
13
  totalPayout?: string;
14
14
  truePricePaid: string;
15
15
  lastBlockTimestamp: string;
16
+ vestingStartTimestamp?: string;
16
17
  pendingRewards: string;
17
18
  billNftAddress: string;
18
19
  payoutClaimed: string;
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.2.2-test.0",
6
+ "version": "4.2.3-test.0",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",