@ape.swap/bonds-sdk 4.0.0-test.15 → 4.0.0-test.17

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 (2) hide show
  1. package/dist/main.js +23 -15
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -79899,17 +79899,20 @@ const UserBondRowPreTGE = ({ userBond }) => {
79899
79899
  const redeemableIn = formatTimeLeft(((_b = userBond === null || userBond === void 0 ? void 0 : userBond.redeemTime) !== null && _b !== void 0 ? _b : 0) - new Date().getTime() / 1000, true, true);
79900
79900
  const depositAmount = getBalanceNumber(new BigNumber$1((_d = (_c = userBond === null || userBond === void 0 ? void 0 : userBond.accountInfo) === null || _c === void 0 ? void 0 : _c.depositAmount) !== null && _d !== void 0 ? _d : '0'), (_f = (_e = userBond === null || userBond === void 0 ? void 0 : userBond.lpToken) === null || _e === void 0 ? void 0 : _e.decimals) === null || _f === void 0 ? void 0 : _f[userBond === null || userBond === void 0 ? void 0 : userBond.chainId]);
79901
79901
  const truePricePaid = getBalanceNumber(new BigNumber$1((_h = (_g = userBond === null || userBond === void 0 ? void 0 : userBond.accountInfo) === null || _g === void 0 ? void 0 : _g.truePricePaid) !== null && _h !== void 0 ? _h : '0'), (_k = (_j = userBond === null || userBond === void 0 ? void 0 : userBond.lpToken) === null || _j === void 0 ? void 0 : _j.decimals) === null || _k === void 0 ? void 0 : _k[userBond === null || userBond === void 0 ? void 0 : userBond.chainId]);
79902
+ const initialRelease = userBond === null || userBond === void 0 ? void 0 : userBond.initialRelease;
79902
79903
  const vestingTimePeriods = getTimePeriods((_l = userBond.vestingTerm) !== null && _l !== void 0 ? _l : 0, false);
79903
79904
  const vestingString = hasRedeemed
79904
79905
  ? getPendingVestingString(userBond === null || userBond === void 0 ? void 0 : userBond.userOwnedBillsData)
79905
- : `${vestingTimePeriods.months} Months`;
79906
+ : initialRelease === 1
79907
+ ? `0 D`
79908
+ : `${vestingTimePeriods.months} Months`;
79906
79909
  const userAllocation = depositAmount / ((_m = userBond === null || userBond === void 0 ? void 0 : userBond.initPrice) !== null && _m !== void 0 ? _m : 0);
79907
- const initialRelease = !hasRedeemed && saleFinalized && (userBond === null || userBond === void 0 ? void 0 : userBond.initialRelease) ? userAllocation * (userBond === null || userBond === void 0 ? void 0 : userBond.initialRelease) : 0;
79910
+ const initialReleaseTokens = !hasRedeemed && saleFinalized && (userBond === null || userBond === void 0 ? void 0 : userBond.initialRelease) ? userAllocation * (userBond === null || userBond === void 0 ? void 0 : userBond.initialRelease) : 0;
79908
79911
  // pendingRewards variable follows the naming of the SC, but it actually means currently claimable tokens
79909
79912
  const pendingRewards = getBalanceNumber(new BigNumber$1((_p = (_o = userBond === null || userBond === void 0 ? void 0 : userBond.userOwnedBillsData) === null || _o === void 0 ? void 0 : _o.pendingRewards) !== null && _p !== void 0 ? _p : '0'), (_r = (_q = userBond === null || userBond === void 0 ? void 0 : userBond.earnToken) === null || _q === void 0 ? void 0 : _q.decimals) === null || _r === void 0 ? void 0 : _r[userBond.chainId]);
79910
79913
  // payout variable follows the naming of the SC, but it actually means total tokens vested
79911
79914
  const payout = getBalanceNumber(new BigNumber$1((_t = (_s = userBond === null || userBond === void 0 ? void 0 : userBond.userOwnedBillsData) === null || _s === void 0 ? void 0 : _s.payout) !== null && _t !== void 0 ? _t : '0'), (_v = (_u = userBond === null || userBond === void 0 ? void 0 : userBond.earnToken) === null || _u === void 0 ? void 0 : _u.decimals) === null || _v === void 0 ? void 0 : _v[userBond.chainId]);
79912
- const claimableAmount = hasRedeemed ? pendingRewards : initialRelease;
79915
+ const claimableAmount = hasRedeemed ? pendingRewards : initialReleaseTokens;
79913
79916
  const claimableUSD = claimableAmount * ((_w = userBond.initPrice) !== null && _w !== void 0 ? _w : 0);
79914
79917
  const pendingAmount = hasRedeemed ? payout : depositAmount / truePricePaid;
79915
79918
  const pendingUSD = pendingAmount * ((_x = userBond === null || userBond === void 0 ? void 0 : userBond.earnTokenPrice) !== null && _x !== void 0 ? _x : 0);
@@ -85994,6 +85997,8 @@ const BuyBond$1 = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isP
85994
85997
  const maxPrice = new BigNumber$1(trueBondPrice !== null && trueBondPrice !== void 0 ? trueBondPrice : '0').times(102).div(100).toFixed(0); // multiply it by 1.02
85995
85998
  const rawAmount = adjustDecimals(inputValue);
85996
85999
  const amount = new BigNumber$1(rawAmount).times(new BigNumber$1(10).pow(decimals !== null && decimals !== void 0 ? decimals : 18)).toString();
86000
+ console.log(maxPrice);
86001
+ console.log(trueBondPrice);
85997
86002
  const shouldUseSig = (bondData === null || bondData === void 0 ? void 0 : bondData.billVersion) === types$1.BillVersion.V4 && SDKConfig.useTiers;
85998
86003
  const args = shouldUseSig ? [amount, maxPrice, account, tierProofSig] : [amount, maxPrice, account];
85999
86004
  const hash = yield writeContractAsync({
@@ -86285,7 +86290,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, isProjectView, setBillId }
86285
86290
  setInputTokenString(newInputToken);
86286
86291
  }, []);
86287
86292
  const handleBuyCallback = () => __awaiter$9(void 0, void 0, void 0, function* () {
86288
- var _a, _b, _c, _d, _e, _f, _g;
86293
+ var _a, _b, _c, _d, _e, _f;
86289
86294
  if (!accountSolana || !bondData || !inputValue || !inputToken || !bondData)
86290
86295
  return;
86291
86296
  try {
@@ -86296,12 +86301,13 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, isProjectView, setBillId }
86296
86301
  const amountBigInt = BigInt(depositAmount.toFixed(0));
86297
86302
  const user = accountSolana;
86298
86303
  const trueBondPriceWithoutFee = (_b = (_a = bondData === null || bondData === void 0 ? void 0 : bondData.trueBondPrices) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.trueBondPrice;
86299
- const feeInPrincipal = (_c = bondData.feeInPrincipal) !== null && _c !== void 0 ? _c : 0;
86300
- const slippage = feeInPrincipal + 2;
86304
+ const slippage = 4;
86301
86305
  const maxPrice = new BigNumber$1(trueBondPriceWithoutFee !== null && trueBondPriceWithoutFee !== void 0 ? trueBondPriceWithoutFee : '0')
86302
86306
  .times((100 + slippage) / 100)
86303
86307
  .dividedBy(new BigNumber$1(1e6))
86304
86308
  .toFixed(0);
86309
+ console.log(maxPrice);
86310
+ console.log(trueBondPriceWithoutFee);
86305
86311
  // Static addresses
86306
86312
  const bondIssuancePda = new PublicKey(bondData.contractAddress[bondData.chainId]);
86307
86313
  const principalMint = new PublicKey(bondData.lpToken.address[bondData.chainId]);
@@ -86381,10 +86387,10 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, isProjectView, setBillId }
86381
86387
  if (nftMint.publicKey.toString()) {
86382
86388
  setBillId === null || setBillId === void 0 ? void 0 : setBillId(nftMint.publicKey.toString());
86383
86389
  }
86384
- const inputAmountUSD = parseFloat(inputValue) * parseFloat((_d = bondData === null || bondData === void 0 ? void 0 : bondData.principalTokenPrice) !== null && _d !== void 0 ? _d : '0');
86385
- axios.post(`${(_e = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _e === void 0 ? void 0 : _e.apiV2}/bills/galxe/quest`, {
86390
+ const inputAmountUSD = parseFloat(inputValue) * parseFloat((_c = bondData === null || bondData === void 0 ? void 0 : bondData.principalTokenPrice) !== null && _c !== void 0 ? _c : '0');
86391
+ axios.post(`${(_d = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _d === void 0 ? void 0 : _d.apiV2}/bills/galxe/quest`, {
86386
86392
  wallet: accountSolana === null || accountSolana === void 0 ? void 0 : accountSolana.toString(),
86387
- bond: (_f = bondData === null || bondData === void 0 ? void 0 : bondData.contractAddress) === null || _f === void 0 ? void 0 : _f[bondData === null || bondData === void 0 ? void 0 : bondData.chainId],
86393
+ bond: (_e = bondData === null || bondData === void 0 ? void 0 : bondData.contractAddress) === null || _e === void 0 ? void 0 : _e[bondData === null || bondData === void 0 ? void 0 : bondData.chainId],
86388
86394
  amount: inputAmountUSD,
86389
86395
  });
86390
86396
  }
@@ -86392,7 +86398,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, isProjectView, setBillId }
86392
86398
  console.error('Error during bond purchase:', error);
86393
86399
  addToastError((error === null || error === void 0 ? void 0 : error.message) || 'Unknown error');
86394
86400
  reportError$1({
86395
- apiUrl: (_g = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _g === void 0 ? void 0 : _g.apiV2,
86401
+ apiUrl: (_f = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _f === void 0 ? void 0 : _f.apiV2,
86396
86402
  error: error.message,
86397
86403
  extraInfo: { type: 'solanaBuyBond', error: error.message },
86398
86404
  chainId: bondChain,
@@ -86447,8 +86453,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, isProjectView, setBillId }
86447
86453
  !accountSolana ||
86448
86454
  !inputValue ||
86449
86455
  parseFloat(inputValue) === 0 ||
86450
- exceedsMaxBuy ||
86451
- exceedsBalance, onClick: handleOpenModal, sx: { width: ['100%', '100%', '100%', '65%'] }, children: exceedsMaxBuy ? 'Exceeds Max Buy' : exceedsBalance ? 'Insufficient balance' : `buy` })] })) }) })] }) })) : (jsx$2(Fragment$1, {}));
86456
+ exceedsMaxBuy, onClick: handleOpenModal, sx: { width: ['100%', '100%', '100%', '65%'] }, children: exceedsMaxBuy ? 'Exceeds Max Buy' : exceedsBalance ? 'Insufficient balance' : `buy` })] })) }) })] }) })) : (jsx$2(Fragment$1, {}));
86452
86457
  };
86453
86458
 
86454
86459
  const BuyBondModal = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, setBillId, }) => {
@@ -88215,7 +88220,7 @@ const styles$5 = {
88215
88220
  };
88216
88221
 
88217
88222
  const Toast = ({ popIndex, popup }) => {
88218
- var _a, _b, _c, _d, _e;
88223
+ var _a, _b, _c, _d, _e, _f;
88219
88224
  const { variant, title, description, url } = popup;
88220
88225
  const { removePopup } = usePopups();
88221
88226
  const [show, setShow] = useState(true);
@@ -88233,11 +88238,14 @@ const Toast = ({ popIndex, popup }) => {
88233
88238
  ((_c = popup === null || popup === void 0 ? void 0 : popup.description) === null || _c === void 0 ? void 0 : _c.includes('Slippage')) ||
88234
88239
  ((_d = popup === null || popup === void 0 ? void 0 : popup.description) === null || _d === void 0 ? void 0 : _d.includes('Return amount is not enough'));
88235
88240
  const isTimeoutError = (_e = popup === null || popup === void 0 ? void 0 : popup.description) === null || _e === void 0 ? void 0 : _e.includes('Blockhash not found');
88241
+ const isInsufficientFundsError = (_f = popup === null || popup === void 0 ? void 0 : popup.description) === null || _f === void 0 ? void 0 : _f.includes('insufficient funds');
88236
88242
  const parsedErrorString = isSlippageError
88237
88243
  ? 'Slippage error. Try increasing Slippage in the cog icon ⚙️.'
88238
88244
  : isTimeoutError
88239
- ? 'Tx timeout. Please try again'
88240
- : popup === null || popup === void 0 ? void 0 : popup.description;
88245
+ ? 'Tx timeout. Please try again.'
88246
+ : isInsufficientFundsError
88247
+ ? 'Insufficient funds.'
88248
+ : popup === null || popup === void 0 ? void 0 : popup.description;
88241
88249
  return (jsx$2(AnimatePresence, { children: show && (jsxs(motion.div, { initial: { right: '-300px' }, animate: { right: '10px' }, transition: { duration: 0.5 }, exit: { right: '-300px' }, sx: Object.assign(Object.assign({}, styles$5.alert), { top: 108 * popIndex, zIndex: 103 }), children: [jsx$2(Flex, { children: jsx$2(Svg, { icon: variant, color: variant, width: "30px" }) }), jsxs(Flex, { sx: styles$5.content, children: [jsx$2(Text, { sx: { color: variant, fontSize: '14px', fontWeight: 500 }, children: title }), description && (jsx$2(Text, { sx: {
88242
88250
  fontSize: '12px',
88243
88251
  fontWeight: 400,
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.0.0-test.15",
6
+ "version": "4.0.0-test.17",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",