@ape.swap/bonds-sdk 3.0.87 → 3.0.89-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.
package/dist/main.js CHANGED
@@ -58352,15 +58352,17 @@ const stagingUrls = {
58352
58352
  };
58353
58353
  const useSDKConfig = (config) => {
58354
58354
  const urls = process.env.NODE_ENV === 'production' ? defaultUrls : stagingUrls;
58355
+ const initialData = Object.assign(Object.assign({ referenceId: '', chains: [], useHotBonds: true, useRainbowKit: false, useTiers: false, useTGEBonds: false, showLowValueBonds: false, bondPartner: undefined }, config), { urls: Object.assign(Object.assign({}, urls), config === null || config === void 0 ? void 0 : config.urls), highestCompatibleVersion: '2.1.2' });
58355
58356
  const { data } = useQuery({
58356
58357
  queryKey: [QUERY_KEYS.SDK_CONFIG],
58357
- initialData: Object.assign(Object.assign({ useHotBonds: true, useRainbowKit: false, useTiers: false, useTGEBonds: false, showLowValueBonds: false }, config), { urls: Object.assign(Object.assign({}, urls), config === null || config === void 0 ? void 0 : config.urls), highestCompatibleVersion: '2.1.2' }),
58358
+ initialData,
58358
58359
  });
58359
58360
  return data;
58360
58361
  };
58361
58362
  const useURLByEnvironment = (key) => {
58363
+ var _a;
58362
58364
  const config = useSDKConfig();
58363
- return config === null || config === void 0 ? void 0 : config.urls[key];
58365
+ return (_a = config === null || config === void 0 ? void 0 : config.urls) === null || _a === void 0 ? void 0 : _a[key];
58364
58366
  };
58365
58367
 
58366
58368
  function reportError$1(_a) {
@@ -73496,10 +73498,11 @@ const PreTgeActions = ({ userBond }) => {
73496
73498
  var _a, _b;
73497
73499
  //Hooks
73498
73500
  const { writeContractAsync } = useWriteContract();
73499
- const { address: account } = useAccount();
73501
+ const { address: account, chainId } = useAccount();
73500
73502
  const SDKConfig = useSDKConfig();
73501
73503
  const { addToastError } = usePopups();
73502
73504
  const { refetch } = usePreTGEUserBonds();
73505
+ const { switchChain } = useSwitchChain();
73503
73506
  //State
73504
73507
  const [loading, setLoading] = useState(false);
73505
73508
  const [hash, setHash] = useState('');
@@ -73515,7 +73518,7 @@ const PreTgeActions = ({ userBond }) => {
73515
73518
  const handleRedeem = () => __awaiter$9(void 0, void 0, void 0, function* () {
73516
73519
  setLoading(true);
73517
73520
  writeContractAsync({
73518
- address: userBond.contractAddress,
73521
+ address: userBond.contractAddress[userBond.chainId],
73519
73522
  abi: launchBondsABI_V2_2_0,
73520
73523
  functionName: 'redeem',
73521
73524
  chain: userBond.chainId,
@@ -73545,7 +73548,7 @@ const PreTgeActions = ({ userBond }) => {
73545
73548
  if (!((_a = userBond === null || userBond === void 0 ? void 0 : userBond.userOwnedBillsData) === null || _a === void 0 ? void 0 : _a.id))
73546
73549
  return;
73547
73550
  writeContractAsync({
73548
- address: userBond.contractAddress,
73551
+ address: userBond.contractAddress[userBond.chainId],
73549
73552
  abi: launchBondsABI_V2_2_0,
73550
73553
  functionName: 'claim',
73551
73554
  args: [(_b = userBond === null || userBond === void 0 ? void 0 : userBond.userOwnedBillsData) === null || _b === void 0 ? void 0 : _b.id],
@@ -73577,7 +73580,7 @@ const PreTgeActions = ({ userBond }) => {
73577
73580
  }
73578
73581
  /* eslint-disable react-hooks/exhaustive-deps */
73579
73582
  }, [hash, isSuccess, isLoadingOnChain]);
73580
- return (jsx$2(Button, { disabled: !saleFinalized || loading || isLoadingOnChain, load: loading || isLoadingOnChain, fullWidth: true, sx: {
73583
+ return chainId !== userBond.chainId && saleFinalized ? (jsxs(Button, { onClick: () => switchChain({ chainId: userBond === null || userBond === void 0 ? void 0 : userBond.chainId }), sx: { fontSize: '14px', height: '30px' }, fullWidth: true, children: ["Switch to ", NETWORK_LABEL[userBond === null || userBond === void 0 ? void 0 : userBond.chainId]] })) : (jsx$2(Button, { disabled: !saleFinalized || loading || isLoadingOnChain, load: loading || isLoadingOnChain, fullWidth: true, sx: {
73581
73584
  fontSize: '14px',
73582
73585
  height: '30px',
73583
73586
  background: !saleFinalized && 'var(--theme-ui-colors-white4) !important',
@@ -80144,7 +80147,7 @@ const BondRowsWithTitle = ({ chain, bonds, showHotBonds }) => {
80144
80147
  const totalPrincipalBilled = Math.round(getBalanceNumber(new BigNumber$1((_c = bond === null || bond === void 0 ? void 0 : bond.totalPrincipalBilled) !== null && _c !== void 0 ? _c : '0'), (_e = (_d = bond === null || bond === void 0 ? void 0 : bond.lpToken) === null || _d === void 0 ? void 0 : _d.decimals) === null || _e === void 0 ? void 0 : _e[bond === null || bond === void 0 ? void 0 : bond.chainId])) / ((_f = bond.initPrice) !== null && _f !== void 0 ? _f : 0);
80145
80148
  const raiseGoal = Math.round(getBalanceNumber(new BigNumber$1((_g = bond === null || bond === void 0 ? void 0 : bond.totalRaise) !== null && _g !== void 0 ? _g : '0'), (_j = (_h = bond === null || bond === void 0 ? void 0 : bond.lpToken) === null || _h === void 0 ? void 0 : _h.decimals) === null || _j === void 0 ? void 0 : _j[bond === null || bond === void 0 ? void 0 : bond.chainId])) / ((_k = bond.initPrice) !== null && _k !== void 0 ? _k : 0);
80146
80149
  const tokensRemaining = raiseGoal - totalPrincipalBilled;
80147
- const tokensRemainingUSD = tokensRemaining * parseFloat((_l = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _l !== void 0 ? _l : '0');
80150
+ const tokensRemainingUSD = tokensRemaining * ((_l = bond === null || bond === void 0 ? void 0 : bond.initPrice) !== null && _l !== void 0 ? _l : 0);
80148
80151
  const percentageAvailable = 100 - Math.floor((totalPrincipalBilled * 100) / raiseGoal);
80149
80152
  const earnToken = (_m = bond === null || bond === void 0 ? void 0 : bond.earnToken) === null || _m === void 0 ? void 0 : _m.symbol;
80150
80153
  return (jsx$2(BondRow, { bondAddress: (_o = bond.contractAddress) === null || _o === void 0 ? void 0 : _o[bond.chainId], bondChain: bond.chainId, payoutToken: bond.earnToken, billType: bond.billType, tag: (_p = bond.tags) === null || _p === void 0 ? void 0 : _p[0], bonus: `${(_r = (_q = bond === null || bond === void 0 ? void 0 : bond.trueBondPrices) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.bonus}%`, percentageAvailable: percentageAvailable, remainingTokensString: `${formatNumberSI(tokensRemaining, 0)} ${earnToken} ($${formatNumberSI(tokensRemainingUSD, 2)})`, vestingTermString: `${getTimePeriods((_s = bond.vestingTerm) !== null && _s !== void 0 ? _s : 0).months} Mo`, projectURL: bond.projectLink, twitterURL: bond.twitter, auditURL: bond.audit }, `${bond.contractAddress}-${bond.chainId}-${index}`));
@@ -80412,7 +80415,10 @@ const Bonds = () => {
80412
80415
  const filterOptions = ['ALL', 'FAVORITES', ...topTags, 'SOLD OUT'];
80413
80416
  const billsToRender = useMemo(() => {
80414
80417
  let billsToReturn = filterOption === 'SOLD OUT' ? [...(allPreBonds !== null && allPreBonds !== void 0 ? allPreBonds : []), ...(allBonds !== null && allBonds !== void 0 ? allBonds : [])] : (sortedBonds !== null && sortedBonds !== void 0 ? sortedBonds : []);
80415
- billsToReturn = billsToReturn === null || billsToReturn === void 0 ? void 0 : billsToReturn.filter((bill) => isBondSupported(SDKConfig.highestCompatibleVersion, bill.version));
80418
+ billsToReturn = billsToReturn === null || billsToReturn === void 0 ? void 0 : billsToReturn.filter((bill) => {
80419
+ return (isBondSupported(SDKConfig.highestCompatibleVersion, bill.version) &&
80420
+ (bill.onlyPartner ? SDKConfig.bondPartner === bill.bondPartner : true));
80421
+ });
80416
80422
  if (searchQuery) {
80417
80423
  billsToReturn = billsToReturn === null || billsToReturn === void 0 ? void 0 : billsToReturn.filter((bill) => {
80418
80424
  var _a, _b;
@@ -80424,6 +80430,9 @@ const Bonds = () => {
80424
80430
  return 'minTier' in bill ? bill.minTier === null || bill.minTier === undefined : true; //TODO: check this
80425
80431
  });
80426
80432
  }
80433
+ if (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.bondPartner) {
80434
+ billsToReturn = billsToReturn === null || billsToReturn === void 0 ? void 0 : billsToReturn.filter((bill) => bill.bondPartner === SDKConfig.bondPartner);
80435
+ }
80427
80436
  if (topTags.includes(filterOption)) {
80428
80437
  billsToReturn = billsToReturn === null || billsToReturn === void 0 ? void 0 : billsToReturn.filter((bill) => { var _a; return (_a = bill === null || bill === void 0 ? void 0 : bill.tags) === null || _a === void 0 ? void 0 : _a.includes(filterOption); });
80429
80438
  }
@@ -1,29 +1,29 @@
1
- export interface SDKProps {
1
+ export interface SDKPropsDTO {
2
2
  referenceId: string;
3
3
  chains: number[];
4
- useRainbowKit: boolean;
4
+ useRainbowKit?: boolean;
5
5
  useHotBonds?: boolean;
6
6
  useTiers?: boolean;
7
7
  useTGEBonds?: boolean;
8
8
  showLowValueBonds?: boolean;
9
+ bondPartner?: string;
9
10
  urls?: Partial<Record<URLKeys, string>>;
10
11
  theme?: any;
12
+ highestCompatibleVersion?: string;
11
13
  }
12
- export declare const useSDKConfig: (config?: SDKProps) => {
13
- urls: {
14
- apiV2: string;
15
- realTimeApi: string;
16
- mainUrl: string;
17
- };
18
- highestCompatibleVersion: string;
19
- referenceId?: string | undefined;
20
- chains?: number[] | undefined;
14
+ export interface SDKProps {
15
+ referenceId: string;
16
+ chains: number[];
21
17
  useRainbowKit: boolean;
22
18
  useHotBonds: boolean;
23
19
  useTiers: boolean;
24
20
  useTGEBonds: boolean;
25
21
  showLowValueBonds: boolean;
26
- theme?: any;
27
- };
22
+ bondPartner?: string;
23
+ urls: Record<URLKeys, string>;
24
+ theme: any;
25
+ highestCompatibleVersion?: string;
26
+ }
27
+ export declare const useSDKConfig: (config?: SDKPropsDTO) => SDKProps;
28
28
  export type URLKeys = 'apiV2' | 'realTimeApi' | 'mainUrl';
29
29
  export declare const useURLByEnvironment: (key: URLKeys) => string;
@@ -1,7 +1,7 @@
1
1
  import { BondsData } from '../../types/bonds';
2
2
  import { SortOptions } from './Bonds';
3
3
  import { BillsConfig } from '@ape.swap/apeswap-lists';
4
- export declare const isBondSoldOut: (bill: BondsData, showLowValueBonds: boolean) => boolean;
4
+ export declare const isBondSoldOut: (bill: BondsData, showLowValueBonds?: boolean) => boolean;
5
5
  export declare const sortBonds: (sortConfig?: SortOptions, bonds?: BondsData[]) => BondsData[];
6
6
  export declare const vestingTime: (vestingTerm?: number) => {
7
7
  years: number;
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": "3.0.87",
6
+ "version": "3.0.89-test.0",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",
@@ -68,7 +68,7 @@
68
68
  "yalc": "^1.0.0-pre.53"
69
69
  },
70
70
  "dependencies": {
71
- "@ape.swap/apeswap-lists": "4.3.25",
71
+ "@ape.swap/apeswap-lists": "4.3.26-test.0",
72
72
  "@emotion/react": "11.11.4",
73
73
  "bignumber.js": "^9.1.2",
74
74
  "chart.js": "4.2.0",